From 5269ce764ed652ea89b2f8e0f653daffd0eecd95 Mon Sep 17 00:00:00 2001 From: GroosL <59540625+GroosL@users.noreply.github.com> Date: Tue, 23 Mar 2021 09:17:03 -0300 Subject: [PATCH 1/2] cmus applet --- 720p/applets/applets/cmus.sh | 78 ++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 720p/applets/applets/cmus.sh diff --git a/720p/applets/applets/cmus.sh b/720p/applets/applets/cmus.sh new file mode 100644 index 0000000..6a5c8bf --- /dev/null +++ b/720p/applets/applets/cmus.sh @@ -0,0 +1,78 @@ +#!/usr/bin/env bash + +## Author : Aditya Shakya +## Mail : adi1090x@gmail.com +## Github : @adi1090x +## Twitter : @adi1090x + +style="$($HOME/.config/rofi/applets/applets/style.sh)" + +dir="$HOME/.config/rofi/applets/applets/configs/$style" +rofi_command="rofi -theme $dir/mpd.rasi" + +# Gets the current status of mpd (for us to parse it later on) +status="$(cmus-remote -C status)" +# Defines the Play / Pause option content +if [[ $status == *"[playing]"* ]]; then + play_pause="" +else + play_pause="" +fi +active="" +urgent="" + +# Display if repeat mode is on / off +tog_repeat="" +if [[ $status == *"repeat true"* ]]; then + active="-a 4" +elif [[ $status == *"repeat false"* ]]; then + urgent="-u 4" +else + tog_repeat=" Parsing error" +fi + +# Display if random mode is on / off +tog_random="" +if [[ $status == *"shuffle true"* ]]; then + [ -n "$active" ] && active+=",5" || active="-a 5" +elif [[ $status == *"shuffle false"* ]]; then + [ -n "$urgent" ] && urgent+=",5" || urgent="-u 5" +else + tog_random=" Parsing error" +fi +stop="" +next="" +previous="" + +# Variable passed to rofi +options="$previous\n$play_pause\n$stop\n$next\n$tog_repeat\n$tog_random" + +# Get the current playing song +song=$(echo -n $(cmus-remote -C status | grep title | cut -c 11-)) +# If mpd isn't running it will return an empty string, we don't want to display that +if [[ -z "$current" ]]; then + current="-" +fi + +# Spawn the mpd menu with the "Play / Pause" entry selected by default +chosen="$(echo -e "$options" | $rofi_command -p " $song" -dmenu $active $urgent -selected-row 1)" +case $chosen in + $previous) + cmus-remote --prev && notify-send -u low -t 1800 " $song" + ;; + $play_pause) + cmus-remote --pause && notify-send -u low -t 1800 " $song" + ;; + $stop) + cmus-remote --stop + ;; + $next) + cmus-remote --next && notify-send -u low -t 1800 " $song" + ;; + $tog_repeat) + cmus-remote --repeat + ;; + $tog_random) + cmus-remote --shuffle + ;; +esac From ad991683134c6a5352426129ab839bc30175b137 Mon Sep 17 00:00:00 2001 From: GroosL <59540625+GroosL@users.noreply.github.com> Date: Tue, 23 Mar 2021 09:25:22 -0300 Subject: [PATCH 2/2] Update cmus.sh --- 720p/applets/applets/cmus.sh | 5 ----- 1 file changed, 5 deletions(-) diff --git a/720p/applets/applets/cmus.sh b/720p/applets/applets/cmus.sh index 6a5c8bf..0946c2a 100644 --- a/720p/applets/applets/cmus.sh +++ b/720p/applets/applets/cmus.sh @@ -1,10 +1,5 @@ #!/usr/bin/env bash -## Author : Aditya Shakya -## Mail : adi1090x@gmail.com -## Github : @adi1090x -## Twitter : @adi1090x - style="$($HOME/.config/rofi/applets/applets/style.sh)" dir="$HOME/.config/rofi/applets/applets/configs/$style"