Skip to content

Commit

Permalink
Add Open Mopidy to menus if it is running
Browse files Browse the repository at this point in the history
  • Loading branch information
ron.record committed Jul 15, 2024
1 parent 5a4fc2d commit 7315141
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 2 deletions.
11 changes: 10 additions & 1 deletion bin/mppinit
Original file line number Diff line number Diff line change
Expand Up @@ -2130,8 +2130,17 @@ init_navidrome() {

remove_navidrome() {
mppuser="${MPP_USER}"
varuser=$(stat -c '%U' /var/lib/navidrome)
if [ -d /var/lib/navidrome ]; then
varuser=$(stat -c '%U' /var/lib/navidrome)
else
varuser="${mppuser}"
fi
optuser=$(stat -c '%U' /opt/navidrome)
if [ -d /opt/navidrome ]; then
optuser=$(stat -c '%U' /opt/navidrome)
else
optuser="${mppuser}"
fi

[ "${mppuser}" == "${varuser}" ] || {
echo "The mppinit user: ${mppuser} does now own /var/lib/navidrome"
Expand Down
30 changes: 29 additions & 1 deletion bin/mpplus
Original file line number Diff line number Diff line change
Expand Up @@ -2315,7 +2315,14 @@ show_services_menu() {
heading "MusicPlayerPlus Services Menu" "Services Menu"
PS3="${BOLD}${PLEASE} command choice (numeric or text, 'h' for help): ${NORM}"
options=("Configure ALSA Sound [a]")
[ "${have_mopidy}" ] || options+=("Install Mopidy Server [im]")
if [ "${have_mopidy}" ]; then
if systemctl --user is-active mopidy.service >/dev/null 2>&1
then
options+=("Open Mopidy in Browser [om]")
fi
else
options+=("Install Mopidy Server [im]")
fi
if [ "${have_navi}" ]; then
if systemctl --user is-active navidrome.service >/dev/null 2>&1
then
Expand Down Expand Up @@ -2541,6 +2548,14 @@ show_services_menu() {
mpp_service status mopidy
break
;;
"Open Mopidy"*,*|*,"Open Mopidy"*|"om",*|*,"om")
if [ "${have_gio}" ]; then
gio open 'http://localhost:6680' >/dev/null 2>&1
else
xdg-open 'http://localhost:6680' >/dev/null 2>&1
fi
break
;;
"Open Navidrome"*,*|*,"Open Navidrome"*|"on",*|*,"on")
if [ "${have_gio}" ]; then
gio open 'http://localhost:4533' >/dev/null 2>&1
Expand Down Expand Up @@ -3210,6 +3225,10 @@ show_main_menu() {
[ "${have_simple}" ] && options+=("Launch ${MPD_CLIENT} with Simple [ls]")
[ "${have_tilix}" ] && options+=("Launch ${MPD_CLIENT} with Tilix [lt]")
[ "${have_cantata}" ] && options+=("Cantata Music Player Plus [C]")
if systemctl --user is-active mopidy.service >/dev/null 2>&1
then
options+=("Open Mopidy in Browser [om]")
fi
if systemctl --user is-active navidrome.service >/dev/null 2>&1
then
options+=("Open Navidrome in Browser [on]")
Expand Down Expand Up @@ -3379,6 +3398,15 @@ show_main_menu() {
skip_it_so=1
break
;;
"Open Mopidy"*,*|*,"Open Mopidy"*|"om",*|*,"om")
if [ "${have_gio}" ]; then
gio open 'http://localhost:6680' >/dev/null 2>&1
else
xdg-open 'http://localhost:6680' >/dev/null 2>&1
fi
skip_it_so=1
break
;;
"Open Navidrome"*,*|*,"Open Navidrome"*|"on",*|*,"on")
if [ "${have_gio}" ]; then
gio open 'http://localhost:4533' >/dev/null 2>&1
Expand Down

0 comments on commit 7315141

Please sign in to comment.