diff options
author | InigoGutierrez <inigogf.95@gmail.com> | 2018-12-17 17:41:52 +0100 |
---|---|---|
committer | InigoGutierrez <inigogf.95@gmail.com> | 2018-12-17 17:41:52 +0100 |
commit | 36d25c89b87dea7bfaf5ad7df2765dba59fb6e15 (patch) | |
tree | 6f6b57741fb9403f6917962b79c970533f0297a4 /i3blocks | |
parent | dd5dbdb734de3efd177fe4440a9d385d17ee5e8d (diff) | |
download | scripts-36d25c89b87dea7bfaf5ad7df2765dba59fb6e15.tar.gz scripts-36d25c89b87dea7bfaf5ad7df2765dba59fb6e15.zip |
Updated music module.
Diffstat (limited to 'i3blocks')
-rwxr-xr-x | i3blocks/i3music.sh | 30 |
1 files changed, 16 insertions, 14 deletions
diff --git a/i3blocks/i3music.sh b/i3blocks/i3music.sh index 3aa764e..8dfd408 100755 --- a/i3blocks/i3music.sh +++ b/i3blocks/i3music.sh @@ -1,20 +1,22 @@ -#!/bin/bash +#!/bin/sh case $BLOCK_BUTTON in - 1) cmus-remote -r ;; - 2) cmus-remote -u ;; - 3) cmus-remote -n ;; + 1) pgrep -x cmus && cmus-remote -r ;; + 2) pgrep -x cmus && cmus-remote -u ;; + 3) pgrep -x cmus && cmus-remote -n ;; esac -status=$(cmus-remote -Q | grep status | awk '{print $2}') -artist=$(cmus-remote -Q | grep "tag artist " | cut -d' ' -f3-) -title=$(cmus-remote -Q | grep "tag title " | cut -d' ' -f3-) -[ -z $artist ] && artist="(unknown)" -[ -z $title ] && title=$(cmus-remote -Q | grep "file " | cut -d'/' -f5-) -if [ $status = "playing" ]; then - echo "$artist ─ $title" -elif [ $status = "paused" ]; then - echo "( $artist ─ $title )" +symbol=🎵 +pgrep -x cmus >/dev/null || (echo "$symbol" && exit) +stat="$(cmus-remote -Q | grep "status " | awk '{print $2}')" +artist="$(cmus-remote -Q | grep "tag artist " | cut -d' ' -f3-)" +title="$(cmus-remote -Q | grep "tag title " | cut -d' ' -f3-)" +[[ -z "$artist" ]] && artist="(unknown)" +[[ -z "$title" ]] && title="$(cmus-remote -Q | grep "file " | cut -d'/' -f5-)" +if [ "$stat" = "playing" ]; then + echo "$symbol $artist ─ $title" +elif [ "$stat" = "paused" ]; then + echo "( $symbol $artist ─ $title )" else - echo "$status" + echo "$symbol $stat" fi |