From ad6b65015e842c042745ef39eebc1c2a3225beaa Mon Sep 17 00:00:00 2001 From: Vincent Bernat Date: Thu, 18 May 2023 12:22:43 +0200 Subject: [PATCH] rofi-mediaplayer: factoring --- bin/rofi-mediaplayer | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/bin/rofi-mediaplayer b/bin/rofi-mediaplayer index ea94f76..a6761b1 100755 --- a/bin/rofi-mediaplayer +++ b/bin/rofi-mediaplayer @@ -21,6 +21,8 @@ if [ $ROFI_RETV -ge 10 ] && [ $ROFI_RETV -le 28 ]; then ROFI_RETV=1 fi +playerctl="playerctl -p $mediaplayer" + case $ROFI_RETV in 0) # Prompt @@ -41,15 +43,15 @@ media-playback-pause Pause media-playback-stop Stop go-next Next track multimedia-volume-control Open mixer panel -com.spotify.Client Open ${Mediaplayer} +com.spotify.Client Open Spotify EOF # Player status - status=$(playerctl -p $mediaplayer status) + status=$($playerctl status) case $status in Playing|Paused) - title="$(playerctl -p $mediaplayer metadata xesam:title | sed -e 's/&/\&/g' -e 's/${title} (${artist})" ;; esac @@ -57,13 +59,13 @@ EOF ;; 1) case $ROFI_INFO in - 1) playerctl -p $mediaplayer previous ;; - 2) playerctl -p $mediaplayer play ;; - 3) playerctl -p $mediaplayer pause ;; - 4) playerctl -p $mediaplayer stop ;; - 5) playerctl -p $mediaplayer next ;; + 1) $playerctl previous ;; + 2) $playerctl play ;; + 3) $playerctl pause ;; + 4) $playerctl stop ;; + 5) $playerctl next ;; 6) i3-msg '[class="Pavucontrol"] focus' || i3-msg exec exec pavucontrol ;; - 7) i3-msg '[class="'${Mediaplayer}'"] focus' || i3-msg exec exec ${mediaplayer} ;; + 7) i3-msg '[class="Spotify"] focus' || i3-msg exec exec spotify ;; esac >&2 ;; esac