From 24e51aba2e0d488430d52f50cc577963a7ce2a18 Mon Sep 17 00:00:00 2001 From: "ron.record" Date: Mon, 1 Jul 2024 16:32:03 -0700 Subject: [PATCH] Add Asciiville animation and MusicPlayerPlus splash screen to animations menu --- bin/mppanim | 8 +-- bin/mpplus | 96 +++++++++++++++++++-------------- bin/mppsplash | 24 +++++++-- bin/mppsplash-tmux | 11 +++- share/scripts/mppsplash-dual.sh | 23 ++++++-- 5 files changed, 109 insertions(+), 53 deletions(-) diff --git a/bin/mppanim b/bin/mppanim index 2127bbe3..1ad048ed 100755 --- a/bin/mppanim +++ b/bin/mppanim @@ -1,6 +1,6 @@ #!/bin/bash # -# asciifetch - display, animate, zoom MusicPlayerPlus splash screen using Kitty +# mppanim - display, animate, zoom MusicPlayerPlus splash screen using Kitty # # Written by Ronald Joe Record # @@ -31,7 +31,7 @@ else fi usage() { - printf "\nUsage: asciifetch [-a] [-f] [-k] [-q] [-z] [-u]" + printf "\nUsage: mppanim [-a] [-f] [-k] [-q] [-z] [-u]" printf "\nWhere:" printf "\n\t-a indicates animate display" printf "\n\t-f indicates fullscreen mode" @@ -74,7 +74,7 @@ cleanup() { tput cnorm tput cup ${terminal_height} 0 parent_name=$(ps -p ${PPID} -o comm=) - if [ "${parent_name}" == "asciifetch" ] + if [ "${parent_name}" == "mppanim" ] then exit 2 else @@ -151,7 +151,7 @@ zoom() { --override startup_session=none \ ${KITTY_QUIT_OPT} \ --listen-on unix:${sock_name} \ - asciifetch -k 2> /dev/null & + mppanim -k 2> /dev/null & kitty_pid=$! trap 'cleanup' USR1 wait_for_pid ${kitty_pid} > /dev/null 2>&1 & diff --git a/bin/mpplus b/bin/mpplus index 9544e901..2a6729fe 100755 --- a/bin/mpplus +++ b/bin/mpplus @@ -2023,13 +2023,10 @@ show_system_status() { } show_about() { - [ "${have_gum}" ] && [ "${have_figlet}" ] && { - have_mppanim=$(type -p mppanim) - [ "${have_mppanim}" ] && { - mppanim -a -q - [ $? -eq 0 ] || tput cup 0 0 2>/dev/null - sleep 3 - } + [ "${have_gum}" ] && [ "${have_figlet}" ] && [ "${have_mppanim}" ] && { + mppanim -a -q + [ $? -eq 0 ] || tput cup 0 0 2>/dev/null + sleep 3 } if [ -f "${MPP_DIR}/VERSION" ]; then . "${MPP_DIR}/VERSION" @@ -2932,34 +2929,37 @@ show_ascii_menu() { SPLASH=1 if [ "${AUDIO}" ] then - audiostat="(ON) " + audiostat="[ON] " else - audiostat="(OFF)" + audiostat="[OFF]" fi if [ "${RECORD}" ] then - recordstat="(ON) " + recordstat="[ON] " else - recordstat="(OFF)" + recordstat="[OFF]" fi if [ "${USE_TMUX}" ] then - usetmux="(ON) " + usetmux="[ON] " else - usetmux="(OFF)" + usetmux="[OFF]" fi skip_it_so= save_it_so= PS3="${BOLD}${PLEASE} command choice (numeric or text, 'h' for help): ${NORM}" - options=("Julia Set ASCIImatics Animation [j]") - options+=("MPPlus ASCIImatics Animation [s]") - options+=("Plasma ASCIImatics Animation [p]") + options=("Julia Set ASCIImatics Animation [J]") + options+=("MPPlus ASCIImatics Animation [M]") + options+=("Plasma ASCIImatics Animation [P]") + [ "${have_asciiart}" ] && options+=("Asciiville Animation [A]") + [ "${have_gum}" ] && [ "${have_figlet}" ] && [ "${have_mppanim}" ] && { + options+=("MusicPlayerPlus Splashscreen [S]") + } options+=("Toggle Audio ${audiostat} [a]") [ "${have_nema}" ] && options+=("Toggle Record Tmux ${recordstat} [r]") - options+=("Toggle Use Tmux ${usetmux} [t]") - [ "${have_ascii}" ] && options+=("Asciiville Menu [A]") - options+=("Main menu [m]") - options+=("Quit [q]") + options+=("Toggle Use Tmux ${usetmux} [t]") + options+=("Main menu [m]") + options+=("Quit [q]") select opt in "${options[@]}" do case "$opt,$REPLY" in @@ -2977,17 +2977,33 @@ show_ascii_menu() { show_main_menu break 2 ;; - "Julia Set ASCIImatics Animation"*,*|*,"Julia Set ASCIImatics Animation"*|"j",*|*,"j") + "MusicPlayerPlus Splash"*,* | *,"MusicPlayerPlus Splash"* | "S",* | *,"S") + tput clear + mppanim -a + [ $? -eq 0 ] || tput cup 0 0 2>/dev/null + mppanim -a -z + [ $? -eq 0 ] || tput cup 0 0 2>/dev/null + mppanim -a + [ $? -eq 0 ] || tput cup 0 0 2>/dev/null + skip_it_so=1 + break + ;; + "Asciiville Anim"*,* | *,"Asciiville Anim"* | "A",* | *,"A") + MPPSPLASH="${MPPSPLASH} -i" + MPPSPLASH_TMUX="${MPPSPLASH_TMUX} -l art" + break + ;; + "Julia Set ASCIImatics Animation"*,*|*,"Julia Set ASCIImatics Animation"*|"J",*|*,"J") MPPSPLASH="${MPPSPLASH} -j" MPPSPLASH_TMUX="${MPPSPLASH_TMUX} -l julia" break ;; - "MPPlus ASCIImatics Animation"*,*|*,"MPPlus ASCIImatics Animation"*|"s",*|*,"s") + "MPPlus ASCIImatics Animation"*,*|*,"MPPlus ASCIImatics Animation"*|"M",*|*,"M") MPPSPLASH="${MPPSPLASH} -m" MPPSPLASH_TMUX="${MPPSPLASH_TMUX} -l rocks" break ;; - "Plasma ASCIImatics Animation"*,*|*,"Plasma ASCIImatics Animation"*|"p",*|*,"p") + "Plasma ASCIImatics Animation"*,*|*,"Plasma ASCIImatics Animation"*|"P",*|*,"P") MPPSPLASH="${MPPSPLASH} -p" MPPSPLASH_TMUX="${MPPSPLASH_TMUX} -l plasma" break @@ -3040,13 +3056,6 @@ show_ascii_menu() { skip_it_so=1 break ;; - "Asciiville"*,*|*,"Asciiville"*|"A",*|*,"A") - clear_screen - asciiville - clear_screen - skip_it_so=1 - break - ;; "Quit"*,*|*,"Quit"*|"quit",*|*,"quit"|"q",*|*,"q") farewell_exit "Exiting MusicPlayerPlus" ;; @@ -3222,8 +3231,9 @@ show_main_menu() { [ "${have_cantata}" ] || options+=("Install Cantata MPD client [ic]") [ "${have_ymuse}" ] || options+=("Install YMuse MPD client [im]") [ "${have_ytm}" ] || options+=("Install YouTubeMusic Player [iy]") - [ "${have_mirror}" ] && options+=("MagicMirror Command Menu [m]") - [ "${have_roon}" ] && options+=("RoonCommandLine Menu [r]") + [ "${have_ascii}" ] && options+=("Asciiville Menu [am]") + [ "${have_mirror}" ] && options+=("MagicMirror Command Menu [mm]") + [ "${have_roon}" ] && options+=("RoonCommandLine Menu [rm]") options+=("About [A]") options+=("Info [i]") options+=("Quit [q]") @@ -3517,14 +3527,21 @@ show_main_menu() { skip_it_so=1 break ;; - "MagicMirror"*,*|*,"MagicMirror"*|"m",*|*,"m") + "Asciiville"*,*|*,"Asciiville"*|"am",*|*,"am") + clear_screen + asciiville + clear_screen + skip_it_so=1 + break + ;; + "MagicMirror"*,*|*,"MagicMirror"*|"mm",*|*,"mm") clear_screen mirror clear_screen skip_it_so=1 break ;; - "RoonCommandLine"*,*|*,"RoonCommandLine"*|"r",*|*,"r") + "RoonCommandLine"*,*|*,"RoonCommandLine"*|"rm",*|*,"rm") clear_screen roon clear_screen @@ -4117,6 +4134,7 @@ have_w3m=$(type -p w3m) have_ranger=$(type -p ranger) have_rich=$(type -p rich) have_ascii=$(type -p asciiville) +have_asciiart=$(type -p asciiart) if [ -d /usr/local/Roon ] then have_roon=$(type -p roon) @@ -4595,12 +4613,10 @@ then clear have_gum=$(type -p gum) have_figlet=$(type -p figlet) - [ "${have_gum}" ] && [ "${have_figlet}" ] && { - have_mppanim=$(type -p mppanim) - [ "${have_mppanim}" ] && { - mppanim -a -q - [ $? -eq 0 ] || tput cup 0 0 2>/dev/null - } + have_mppanim=$(type -p mppanim) + [ "${have_gum}" ] && [ "${have_figlet}" ] && [ "${have_mppanim}" ] && { + mppanim -a -q + [ $? -eq 0 ] || tput cup 0 0 2>/dev/null } show_main_menu else diff --git a/bin/mppsplash b/bin/mppsplash index 65b8f896..5ed17a41 100755 --- a/bin/mppsplash +++ b/bin/mppsplash @@ -7,10 +7,15 @@ SONG="${MUSEDIR}/Epic_Dramatic-Yuriy_Bespalov.wav" PLASMA_SONG="${MUSEDIR}/Chronos.mp3" ALTSONG="${MUSEDIR}/Kevin_MacLeod_-_Also_Sprach_Zarathustra.ogg" MPDCONF=~/.config/mpd/mpd.conf +have_ascii=$(type -p asciiart) usage() { printf "\nUsage: mppsplash [-A] [-a] [-b] [-C] [-c num] [-d] [-jJ] " - printf "[-m] [-p] [-s song] [-u]" + if [ "${have_ascii}" ]; then + printf "[-i] [-m] [-p] [-s song] [-u]" + else + printf "[-m] [-p] [-s song] [-u]" + fi printf "\nWhere:" printf "\n\t-A indicates use all effects" printf "\n\t-a indicates play audio during ASCIImatics display" @@ -18,6 +23,7 @@ usage() { printf "\n\t-C indicates use alternate comments in Plasma effect" printf "\n\t-c num specifies the number of times to cycle" printf "\n\t-d indicates enable debug mode" + [ "${have_ascii}" ] && printf "\n\t-i indicates use Ascii Art effect" printf "\n\t-j indicates use Julia Set effect" printf "\n\t-J indicates Julia Set with several runs using different parameters" printf "\n\t-m indicates use MusicPlayerPlus effect" @@ -33,6 +39,10 @@ usage() { exit 1 } +mppart() { + [ "${have_ascii}" ] && asciiart $* +} + set_cycles() { case $1 in julia) @@ -65,7 +75,7 @@ debug= longjulia= script="rocks" switch_comments= -while getopts "AabCc:djJmps:u" flag; do +while getopts "AabCc:dijJmps:u" flag; do case $flag in A) all=1 @@ -88,6 +98,9 @@ while getopts "AabCc:djJmps:u" flag; do d) debug="--debug" ;; + i) + script="art" + ;; j) script="julia" ;; @@ -172,7 +185,12 @@ if [ "${all}" ] then [ "${cycle}" ] || cycle="-c 1" numcycles=`echo ${cycle} | awk ' { print $2 } '` - for script in julia rocks plasma + if [ "${have_ascii}" ]; then + anims="art julia rocks plasma" + else + anims="julia rocks plasma" + fi + for script in ${anims} do set_cycles ${script} ${numcycles} mpp${script} -c ${usecycle} ${script_args} diff --git a/bin/mppsplash-tmux b/bin/mppsplash-tmux index 5c5e725b..ae1d7475 100755 --- a/bin/mppsplash-tmux +++ b/bin/mppsplash-tmux @@ -155,17 +155,24 @@ script_args="${script_args} ${CYCLE}" if [ "${DUDE}" ] then + [ "${PYLEFT}" == "art" ] && left_script_args="${left_script_args} -i -C" [ "${PYLEFT}" == "rocks" ] && left_script_args="${left_script_args} -m -C" [ "${PYLEFT}" == "plasma" ] && left_script_args="${left_script_args} -p -C" [ "${PYLEFT}" == "julia" ] && left_script_args="${left_script_args} -j -C" else + [ "${PYLEFT}" == "art" ] && left_script_args="${left_script_args} -i" [ "${PYLEFT}" == "rocks" ] && left_script_args="${left_script_args} -m" [ "${PYLEFT}" == "plasma" ] && left_script_args="${left_script_args} -p" [ "${PYLEFT}" == "julia" ] && left_script_args="${left_script_args} -j" fi -have_left=`type -p mpp${PYLEFT}` -[ "${have_left}" ] && PYLEFT="mpp${PYLEFT}" +if [ "${PYLEFT}" == "art" ]; then + have_left=`type -p asciiart` + [ "${have_left}" ] && PYLEFT="asciiart" +else + have_left=`type -p mpp${PYLEFT}` + [ "${have_left}" ] && PYLEFT="mpp${PYLEFT}" +fi [ "${USAGE}" ] && usage diff --git a/share/scripts/mppsplash-dual.sh b/share/scripts/mppsplash-dual.sh index 3683b409..24642d55 100755 --- a/share/scripts/mppsplash-dual.sh +++ b/share/scripts/mppsplash-dual.sh @@ -140,6 +140,8 @@ script_args="${script_args} ${CYCLE}" if [ "${DUDE}" ] then + [ "${PYLEFT}" == "art" ] && left_script_args="${left_script_args} -i -C" + [ "${PYRIGHT}" == "art" ] && right_script_args="${right_script_args} -i -C" [ "${PYLEFT}" == "rocks" ] && left_script_args="${left_script_args} -m -C" [ "${PYRIGHT}" == "rocks" ] && right_script_args="${right_script_args} -m -C" [ "${PYLEFT}" == "plasma" ] && left_script_args="${left_script_args} -p -C" @@ -147,6 +149,8 @@ then [ "${PYLEFT}" == "julia" ] && left_script_args="${left_script_args} -j -C" [ "${PYRIGHT}" == "julia" ] && right_script_args="${right_script_args} -j -C" else + [ "${PYLEFT}" == "art" ] && left_script_args="${left_script_args} -i" + [ "${PYRIGHT}" == "art" ] && right_script_args="${right_script_args} -i" [ "${PYLEFT}" == "rocks" ] && left_script_args="${left_script_args} -m" [ "${PYRIGHT}" == "rocks" ] && right_script_args="${right_script_args} -m" [ "${PYLEFT}" == "plasma" ] && left_script_args="${left_script_args} -p" @@ -155,10 +159,21 @@ else [ "${PYRIGHT}" == "julia" ] && right_script_args="${right_script_args} -j" fi -have_left=`type -p mpp${PYLEFT}` -[ "${have_left}" ] && PYLEFT="mpp${PYLEFT}" -have_right=`type -p mpp${PYRIGHT}` -[ "${have_right}" ] && PYRIGHT="mpp${PYRIGHT}" +if [ "${PYLEFT}" == "art" ]; then + have_left=`type -p asciiart` + [ "${have_left}" ] && PYLEFT="asciiart" +else + have_left=`type -p mpp${PYLEFT}` + [ "${have_left}" ] && PYLEFT="mpp${PYLEFT}" +fi + +if [ "${PYRIGHT}" == "art" ]; then + have_right=`type -p asciiart` + [ "${have_right}" ] && PYRIGHT="asciiart" +else + have_right=`type -p mpp${PYRIGHT}` + [ "${have_right}" ] && PYRIGHT="mpp${PYRIGHT}" +fi [ "${USAGE}" ] && usage