From b469beb2df9ec132e45bd8cb4953b496db9c576b Mon Sep 17 00:00:00 2001 From: "ron.record" Date: Sun, 2 Jun 2024 13:51:47 -0700 Subject: [PATCH] Fixes for Ueberzug and tmux sessions in a Python virtual environment --- bin/mpcplus-tmux | 3 + bin/mppinit | 18 ++--- bin/mpplus | 83 ++++++++++++++-------- config/ueberzug/mpcplus-ueberzug | 2 + config/ueberzug/mpcplus_cover_art.sh | 3 + share/calliope/bandcamp2local | 2 + share/calliope/examples/online-to-local.sh | 2 + share/scripts/mppsplash-dual.sh | 3 + 8 files changed, 79 insertions(+), 37 deletions(-) diff --git a/bin/mpcplus-tmux b/bin/mpcplus-tmux index 6bedc301..2af62a07 100755 --- a/bin/mpcplus-tmux +++ b/bin/mpcplus-tmux @@ -53,6 +53,9 @@ start_tmux_session() { tmux set -g status off tmux send-keys "stty -echo" C-m tmux send-keys "tput civis -- invisible" C-m + [ -f ${HOME}/.venv/bin/activate ] && { + tmux send-keys "source ${HOME}/.venv/bin/activate" C-m + } tmux send-keys "export PS1=''" C-m tmux send-keys "clear" C-m tmux send-keys "${MPPCOMM}; exit" C-m diff --git a/bin/mppinit b/bin/mppinit index 04e65bf3..aac08e7e 100755 --- a/bin/mppinit +++ b/bin/mppinit @@ -336,8 +336,8 @@ install_ueberzug() { TEMP_WHL="/tmp/${TEMP_WHL}" wget --quiet -O "${TEMP_WHL}" "${DL_URL}" >/dev/null 2>&1 chmod 644 "${TEMP_WHL}" - ${PYTHON} -m pip install --user --upgrade "${TEMP_WHL}" >/dev/null 2>&1 - # rm -f "${TEMP_WHL}" + ${PYTHON} -m pip install --upgrade "${TEMP_WHL}" >/dev/null 2>&1 + rm -f "${TEMP_WHL}" } } } @@ -383,7 +383,7 @@ init_mopidy() { for extension in ${EXT_MOPIDY}; do printf "\n\tInstalling Mopidy extension ${extension}" - ${PYTHON} -m pip install --user --upgrade ${extension} >/dev/null 2>&1 + ${PYTHON} -m pip install --upgrade ${extension} >/dev/null 2>&1 done printf "\n" @@ -2064,9 +2064,9 @@ install_mpc() { git clone https://github.com/MusicPlayerDaemon/mpc.git cd mpc have_meson=$(type -p meson) - [ "${have_meson}" ] || ${PYTHON} -m pip install --user meson + [ "${have_meson}" ] || ${PYTHON} -m pip install --upgrade meson have_ninja=$(type -p ninja) - [ "${have_ninja}" ] || ${PYTHON} -m pip install --user ninja + [ "${have_ninja}" ] || ${PYTHON} -m pip install --upgrade ninja meson . output ninja -C output [ -x output/mpc ] && sudo cp output/mpc /usr/bin/mpc @@ -3087,7 +3087,7 @@ if [ "${PIP}" ]; then # - Uninstall Beets (python -m pip uninstall beets) # - pip install https://github.com/beetbox/beets/tarball/master ${PYTHON} -m pip uninstall beets >/dev/null 2>&1 - ${PYTHON} -m pip install --user \ + ${PYTHON} -m pip install --upgrade \ https://github.com/beetbox/beets/tarball/master >/dev/null 2>&1 BEETS= else @@ -3117,11 +3117,11 @@ if [ "${PIP}" ]; then YSCV=${YSCV:0:3} ${SCPTDIR}/vercomp.sh "${YSCV}" "${YMIN}" >/dev/null [ $? -eq 2 ] && { - ${PYTHON} -m pip install --user ${SCRB}==0.7.3 >/dev/null 2>&1 + ${PYTHON} -m pip install --upgrade ${SCRB}==0.7.3 >/dev/null 2>&1 } } else - ${PYTHON} -m pip install --user ${SCRB}==0.7.3 >/dev/null 2>&1 + ${PYTHON} -m pip install --upgrade ${SCRB}==0.7.3 >/dev/null 2>&1 fi [ "${quiet}" ] || printf "\n\tModules:" for pkg in unidecode six PySocks asciimatics beautifulsoup4 ${BEETS} \ @@ -3129,7 +3129,7 @@ if [ "${PIP}" ]; then PyYAML python-mpd2 requests sacad tmuxp ${YT_DLP} setuptools \ calliope-music bandcamp-downloader scdl flask-cors click; do printf " ${pkg}" - ${PYTHON} -m pip install --user --upgrade ${pkg} >/dev/null 2>&1 + ${PYTHON} -m pip install --upgrade ${pkg} >/dev/null 2>&1 done # Install fixed cpe script [ -f ${CCPTDIR}/cpe ] && { diff --git a/bin/mpplus b/bin/mpplus index 7c9e5b47..4a87a1cb 100755 --- a/bin/mpplus +++ b/bin/mpplus @@ -1406,6 +1406,7 @@ show_help_menu() { MTITLE="MusicPlayerPlus Help" while true do + clear FIG_TEXT="Help Menu" if [ "${use_figlet}" ] then @@ -1453,11 +1454,11 @@ show_help_menu() { [ "${have_kitty}" ] && options+=("Kitty Terminal Man Page") [ "${have_simple}" ] && options+=("Simple Terminal Man Page") [ "${have_tilix}" ] && options+=("Tilix Terminal Man Page") - options+=("Done / Back" "Quit") + options+=("Done / Back [b]" "Quit [q]") select opt in "${options[@]}" do case "$opt,$REPLY" in - "Done"*,*|*,"Done"*|"done"*,*|*,"done"*|"Back"*,*|*,"Back"*|"back"*,*|*,"back"*) + "Done"*,*|*,"Done"*|"done"*,*|*,"done"*|"Back"*,*|*,"Back"*|"back"*,*|*,"back"*|"b",*|*,"b") clear printf "\n" break 2 @@ -1612,7 +1613,7 @@ show_help_menu() { man tilix break ;; - "Quit",*|*,"Quit"|"quit",*|*,"quit") + "Quit",*|*,"Quit"|"quit",*|*,"quit"|"q",*|*,"q") printf "\nExiting MusicPlayerPlus\n" exit 0 ;; @@ -1631,6 +1632,7 @@ show_help_menu() { show_downloads_menu() { while true do + clear FIG_TEXT="Downloads" if [ "${use_figlet}" ] then @@ -1662,7 +1664,7 @@ show_downloads_menu() { } options+=("Toggle Dry Run (${usedrun})") } - options+=("Main menu" "Quit") + options+=("Main menu [m]" "Quit [q]") select opt in "${options[@]}" do case "$opt,$REPLY" in @@ -1672,7 +1674,7 @@ show_downloads_menu() { show_help_menu break ;; - "Main menu",*|*,"Main menu"|"Back",*|*,"Back"|"back",*|*,"back") + "Main menu"*,*|*,"Main menu"*|"Back",*|*,"Back"|"back",*|*,"back"|"m",*|*,"m") clear printf "\n" init_vars @@ -1733,10 +1735,14 @@ show_downloads_menu() { skip_it_so=1 break ;; - "Quit",*|*,"Quit"|"quit",*|*,"quit") + "Quit"*,*|*,"Quit"*|"quit",*|*,"quit"|"q",*|*,"q") printf "\nExiting\n" exit 0 ;; + *,*|*,*) + skip_it_so=1 + break + ;; esac REPLY= done @@ -1823,6 +1829,7 @@ show_logs_menu() { have_alsa=`type -p alsa-info` while true do + clear show_system_status FIG_TEXT="Service Logs Menu" if [ "${use_figlet}" ] @@ -1860,7 +1867,7 @@ show_logs_menu() { options+=("View Last.FM Scrobbler Log") } options+=("Manage Services") - options+=("Main menu" "Quit") + options+=("Main menu [m]" "Quit [q]") select opt in "${options[@]}" do case "$opt,$REPLY" in @@ -1870,7 +1877,7 @@ show_logs_menu() { show_help_menu break ;; - "Main menu",*|*,"Main menu"|"Back",*|*,"Back"|"back",*|*,"back") + "Main menu"*,*|*,"Main menu"*|"Back",*|*,"Back"|"back",*|*,"back"|"m",*|*,"m") clear printf "\n" init_vars @@ -1919,10 +1926,13 @@ show_logs_menu() { show_services_menu break ;; - "Quit",*|*,"Quit"|"quit",*|*,"quit") + "Quit"*,*|*,"Quit"*|"quit",*|*,"quit"|"q",*|*,"q") printf "\nExiting\n" exit 0 ;; + *,*|*,*) + break + ;; esac REPLY= done @@ -1933,6 +1943,7 @@ show_logs_menu() { show_services_menu() { while true do + clear show_system_status FIG_TEXT="Services Menu" if [ "${use_figlet}" ] @@ -2090,7 +2101,7 @@ show_services_menu() { options+=("Update/scan MPD music library") } options+=("View Music Service Logs") - options+=("Main menu" "Quit") + options+=("Main menu [m]" "Quit [q]") select opt in "${options[@]}" do case "$opt,$REPLY" in @@ -2100,7 +2111,7 @@ show_services_menu() { show_help_menu break ;; - "Main menu",*|*,"Main menu"|"Back",*|*,"Back"|"back",*|*,"back") + "Main menu"*,*|*,"Main menu"*|"Back",*|*,"Back"|"back",*|*,"back"|"m",*|*,"m") clear printf "\n" init_vars @@ -2442,10 +2453,13 @@ show_services_menu() { show_logs_menu break ;; - "Quit",*|*,"Quit"|"quit",*|*,"quit") + "Quit"*,*|*,"Quit"*|"quit",*|*,"quit"|"q",*|*,"q") printf "\nExiting\n" exit 0 ;; + *,*|*,*) + break + ;; esac REPLY= done @@ -2456,6 +2470,7 @@ show_services_menu() { show_fzmp_menu() { while true do + clear FIG_TEXT="Fuzzy Search" if [ "${use_figlet}" ] then @@ -2472,7 +2487,7 @@ show_fzmp_menu() { [ "${have_fzf}" ] && options+=("List genres in library") [ "${have_fzf}" ] && options+=("Search current playlist") [ "${have_fzf}" ] && options+=("List saved playlists") - options+=("Main menu" "Quit") + options+=("Main menu [m]" "Quit [q]") select opt in "${options[@]}" do case "$opt,$REPLY" in @@ -2482,7 +2497,7 @@ show_fzmp_menu() { show_help_menu break ;; - "Main menu",*|*,"Main menu"|"Back",*|*,"Back"|"back",*|*,"back") + "Main menu"*,*|*,"Main menu"*|"Back",*|*,"Back"|"back",*|*,"back"|"m",*|*,"m") clear printf "\n" init_vars @@ -2513,10 +2528,13 @@ show_fzmp_menu() { fzmp -P break ;; - "Quit",*|*,"Quit"|"quit",*|*,"quit") + "Quit"*,*|*,"Quit"*|"quit",*|*,"quit"|"q",*|*,"q") printf "\nExiting\n" exit 0 ;; + *,*|*,*) + break + ;; esac done done @@ -2525,6 +2543,7 @@ show_fzmp_menu() { show_ascii_menu() { while true do + clear FIG_TEXT="Asciimatics" if [ "${use_figlet}" ] then @@ -2558,8 +2577,8 @@ show_ascii_menu() { options=("Julia Set ASCIImatics Animation" "MPPlus ASCIImatics Animation" "Plasma ASCIImatics Animation" "Toggle Audio (${audiostat})") [ "${have_nema}" ] && options+=("Toggle Record Tmux Session (${recordstat})") options+=("Toggle Use Tmux (${usetmux})") - [ "${have_ascii}" ] && options+=("Asciiville Menu") - options+=("Main menu" "Quit") + [ "${have_ascii}" ] && options+=("Asciiville Menu [a]") + options+=("Main menu [m]" "Quit [q]") select opt in "${options[@]}" do case "$opt,$REPLY" in @@ -2570,7 +2589,7 @@ show_ascii_menu() { skip_it_so=1 break ;; - "Main menu",*|*,"Main menu"|"Back",*|*,"Back"|"back",*|*,"back") + "Main menu"*,*|*,"Main menu"*|"Back",*|*,"Back"|"back",*|*,"back"|"m",*|*,"m") clear printf "\n" init_vars @@ -2640,17 +2659,21 @@ show_ascii_menu() { skip_it_so=1 break ;; - "Asciiville"*,*|*,"Asciiville"*) + "Asciiville"*,*|*,"Asciiville"*|"a",*|*,"a") clear asciiville clear skip_it_so=1 break ;; - "Quit",*|*,"Quit"|"quit",*|*,"quit") + "Quit"*,*|*,"Quit"*|"quit",*|*,"quit"|"q",*|*,"q") printf "\nExiting\n" exit 0 ;; + *,*|*,*) + skip_it_so=1 + break + ;; esac REPLY= done @@ -2755,10 +2778,10 @@ select_music_dir() { } show_main_menu() { - clear - printf "\n" while true do + clear + printf "\n" if [ "${FULLSCREEN}" ] then fullstat="ON" @@ -2816,9 +2839,9 @@ show_main_menu() { options+=("Toggle Use Tmux (${usetmux})") [ "${have_nema}" ] && options+=("Toggle Record Tmux Session (${recordstat})") options+=("Toggle Fullscreen (${fullstat})") - [ "${have_mirror}" ] && options+=("MagicMirror Command Menu") - [ "${have_roon}" ] && options+=("RoonCommandLine Menu") - options+=("Quit") + [ "${have_mirror}" ] && options+=("MagicMirror Command Menu [m]") + [ "${have_roon}" ] && options+=("RoonCommandLine Menu [r]") + options+=("Quit [q]") select opt in "${options[@]}" do case "$opt,$REPLY" in @@ -3032,7 +3055,7 @@ show_main_menu() { skip_it_so=1 break ;; - "MagicMirror"*,*|*,"MagicMirror"*) + "MagicMirror"*,*|*,"MagicMirror"*|"m",*|*,"m") clear FIG_TEXT="Mirror Command" if [ "${use_figlet}" ] @@ -3047,7 +3070,7 @@ show_main_menu() { skip_it_so=1 break ;; - "RoonCommandLine"*,*|*,"RoonCommandLine"*) + "RoonCommandLine"*,*|*,"RoonCommandLine"*|"r",*|*,"r") clear FIG_TEXT="Roon Command" if [ "${use_figlet}" ] @@ -3062,10 +3085,14 @@ show_main_menu() { skip_it_so=1 break ;; - "Quit",*|*,"Quit"|"quit",*|*,"quit") + "Quit"*,*|*,"Quit"*|"quit",*|*,"quit"|"q",*|*,"q") printf "\nExiting\n" exit 0 ;; + *,*|*,*) + skip_it_so=1 + break + ;; esac REPLY= done diff --git a/config/ueberzug/mpcplus-ueberzug b/config/ueberzug/mpcplus-ueberzug index 717bb985..2c131a89 100755 --- a/config/ueberzug/mpcplus-ueberzug +++ b/config/ueberzug/mpcplus-ueberzug @@ -8,6 +8,8 @@ cleanup() { pkill mpcplus_cover_art.sh } +[ -f ${HOME}/.venv/bin/activate ] && source ${HOME}/.venv/bin/activate + USE_MPCPLUS=1 USE_NCMPCPP= CLIENT_COMM="mpcplus" diff --git a/config/ueberzug/mpcplus_cover_art.sh b/config/ueberzug/mpcplus_cover_art.sh index 61bd6c61..886b7ba6 100755 --- a/config/ueberzug/mpcplus_cover_art.sh +++ b/config/ueberzug/mpcplus_cover_art.sh @@ -16,6 +16,9 @@ MUSIC_DIR= } [ "${MUSIC_DIR}" ] || MUSIC_DIR="$HOME/Music" } + +[ -f ${HOME}/.venv/bin/activate ] && source ${HOME}/.venv/bin/activate + # Need to expand a tilda to $HOME music_library="${MUSIC_DIR/#\~/$HOME}" fallback_image="$HOME/.config/mpcplus/ueberzug/img/fallback.png" diff --git a/share/calliope/bandcamp2local b/share/calliope/bandcamp2local index d1e4158e..d782ead5 100755 --- a/share/calliope/bandcamp2local +++ b/share/calliope/bandcamp2local @@ -19,4 +19,6 @@ fi #LOCAL_ALBUMS="cpe tracker albums" LOCAL_ALBUMS="cpe beets albums" +[ -f ${HOME}/.venv/bin/activate ] && source ${HOME}/.venv/bin/activate + cpe diff --scope=album <($ONLINE_ALBUMS | cpe musicbrainz annotate -) <($LOCAL_ALBUMS) diff --git a/share/calliope/examples/online-to-local.sh b/share/calliope/examples/online-to-local.sh index 944ac6e3..79bd8099 100755 --- a/share/calliope/examples/online-to-local.sh +++ b/share/calliope/examples/online-to-local.sh @@ -6,4 +6,6 @@ ONLINE_ALBUMS="cpe bandcamp --user ssssam collection" LOCAL_ALBUMS="cpe tracker albums" #LOCAL_ALBUMS="cpe beets albums" +[ -f ${HOME}/.venv/bin/activate ] && source ${HOME}/.venv/bin/activate + cpe diff --scope=album <($ONLINE_ALBUMS | cpe musicbrainz annotate -) <($LOCAL_ALBUMS) diff --git a/share/scripts/mppsplash-dual.sh b/share/scripts/mppsplash-dual.sh index 1373fd5b..a68303a8 100755 --- a/share/scripts/mppsplash-dual.sh +++ b/share/scripts/mppsplash-dual.sh @@ -167,6 +167,9 @@ tmux set -g status off tmux send-keys "stty -echo" C-m tmux send-keys "tput civis -- invisible" C-m +[ -f ${HOME}/.venv/bin/activate ] && { + tmux send-keys "source ${HOME}/.venv/bin/activate" C-m +} tmux send-keys "export PS1=''" C-m tmux send-keys "clear" C-m [ "${DUAL}" ] && tmux split-window -h -p 50