diff options
author | Karel Kočí <karel.koci@nic.cz> | 2020-10-08 07:36:47 +0200 |
---|---|---|
committer | Karel Kočí <karel.koci@nic.cz> | 2020-10-08 07:36:57 +0200 |
commit | 1552cdb455cd342590f22adc3d647cefc7f99b14 (patch) | |
tree | 6e2a1980b003907c4c80178d1543729df0efd38d /config | |
parent | 2d6b90df351156ed9208a8e5a850ea691dc3c29d (diff) | |
download | myconfigs-1552cdb455cd342590f22adc3d647cefc7f99b14.tar.gz myconfigs-1552cdb455cd342590f22adc3d647cefc7f99b14.tar.bz2 myconfigs-1552cdb455cd342590f22adc3d647cefc7f99b14.zip |
Revert "Add mpd-remote to i3blocks"
This reverts commit 3bf0736b56948274961db6cbdf6b28453fdffbdf.
This also improves bash code.
Diffstat (limited to 'config')
-rw-r--r-- | config/i3blocks/config | 5 | ||||
-rwxr-xr-x | config/i3blocks/scripts/mpd | 63 |
2 files changed, 16 insertions, 52 deletions
diff --git a/config/i3blocks/config b/config/i3blocks/config index 985f12e..dc3d306 100644 --- a/config/i3blocks/config +++ b/config/i3blocks/config @@ -8,11 +8,6 @@ command=~/.config/i3blocks/scripts/mpd interval=5 signal=12 -[mpd-remote] -command=~/.config/i3blocks/scripts/mpd -interval=5 -instance=remote - [volume] label=♪ instance=Master diff --git a/config/i3blocks/scripts/mpd b/config/i3blocks/scripts/mpd index 914def6..b0fbd6d 100755 --- a/config/i3blocks/scripts/mpd +++ b/config/i3blocks/scripts/mpd @@ -1,67 +1,36 @@ #!/bin/bash -HOST_HOME="10.8.2.51" -HOST="" -# Let's be sneaky and verify that we are on relevant network before we try to ping -if ip a | grep -q 'inet 10.8.2.' && \ - ping -c 1 -w 1 "$HOST_HOME" >/dev/null 2>&1; then - # TODO check that mpd is running? - HOST="-h $HOST_HOME" -fi - -STATUS="$(mpc $HOST status)" +status="$(mpc -f "♫ %artist%, %album%, %title%" status)" -# Handle remote volume -if [ "$BLOCK_INSTANCE" = "remote" ]; then - [ -n "$HOST" ] || exit 0 - case "$BLOCK_BUTTON" in - 1) - mpc $HOST volume 40 >/dev/null - ;; - 3) - mpc $HOST volume 0 >/dev/null - ;; - 4) - mpc $HOST volume +2 >/dev/null - ;; - 5) - mpc $HOST volume -2 >/dev/null - ;; - esac - - if echo "$STATUS" | grep -qE "(playing|paused)"; then - echo "♫ $(mpc $HOST volume | sed 's/volume: //')" - fi - exit 0 -fi - -# Handle user input case "$BLOCK_BUTTON" in 1) - mpc $HOST toggle >/dev/null + mpc toggle >/dev/null ;; 2) - mpc $HOST stop >/dev/null + mpc stop >/dev/null ;; 3) - nohup urxvt -title "Music player daemon client" -e ncmpcpp $HOST 2>&1 >/dev/null & + nohup urxvt -title "Music player daemon client" -e ncmpcpp 2>&1 >/dev/null & ;; 4) - mpc $HOST prev >/dev/null + mpc prev >/dev/null ;; 5) - mpc $HOST next >/dev/null + mpc next >/dev/null ;; esac -if echo "$STATUS" | grep -qE "(playing|paused)"; then - echo `mpc $HOST -f "♫ %artist%, %album%, %title%" status | head -1` +if [[ "$status" == *[*(playing|paused)]* ]]; then + echo "$status" | head -1 echo - if echo "$STATUS" | grep -q playing; then - echo "#00ff00" - elif echo "$STATUS" | grep -q paused; then - echo "#ffff00" - fi + case "$status" in + *"[playing]"*) + echo "#ffff00" + ;; + *"[paused]"*) + echo "#00ff00" + ;; + esac else echo "♫" fi |