diff options
| author | Robert Günzler <r@gnzler.io> | 2021-11-02 18:43:03 +0100 |
|---|---|---|
| committer | Robert Günzler <r@gnzler.io> | 2021-11-02 19:06:52 +0100 |
| commit | b8a8e073f4df1af7ad0d5e76886a11d1de909a05 (patch) | |
| tree | 9bd6b9b4c132ad6c328bcc872f3cc574ac07ba43 /.config/waybar/modules | |
| parent | 051355bbcce0bc1143c72039895d68937006e66a (diff) | |
waybar: update config
Diffstat (limited to '.config/waybar/modules')
| -rw-r--r-- | .config/waybar/modules/mpris.awk | 57 | ||||
| -rwxr-xr-x | .config/waybar/modules/mpris.sh | 4 |
2 files changed, 59 insertions, 2 deletions
diff --git a/.config/waybar/modules/mpris.awk b/.config/waybar/modules/mpris.awk new file mode 100644 index 0000000..af3a271 --- /dev/null +++ b/.config/waybar/modules/mpris.awk @@ -0,0 +1,57 @@ +BEGIN { + # system("jq -Mnc {}"); +} + +{ + gsub(/"/,"") + gsub(/'/,"\047") + # print "DEBUG: " $0 + + artist=$1 + album=$2 + title=$3 + position=$4 + player=$5 + status=$6 +} + +($0 == "") || (status ~ /stopped/) { + system("jq -Mnc {}") + exit +} +(status ~ /playing/) { + icon="" +} +(status ~ /paused/) { + icon="" +} +(artist != "") && (album != "") { + text=sprintf("%s - %s - %s (%s)", artist, album, title, position) + tooltip=sprintf("%s\nby %s\nfrom %s\n(%s)", title, artist, album, player) +} +(artist == "") { + text=sprintf("%s - %s (%s)", album, title, position) + tooltip=sprintf("%s\nfrom %s\n(%s)", title, album, player) +} +(album == "") { + text=sprintf("%s - %s (%s)", artist, title, position) + tooltip=sprintf("%s\nby %s\n(%s)", title, artist, player) +} +(artist == "") && (album == "") { + text=sprintf("%s (%s)", title, position) + tooltip=sprintf("%s\n(%s)", title, player) +} +# edge cases to beautify the output +(player == "tdesktop") && (title ~ /Unknown Track/) { + text="telegram voice message" +} + +{ + system(sprintf("jq -rMnc --arg class \"%s\" --arg text \"%s %s\" --arg tt \"%s\" '{ class: $class, text: $text|@html, tooltip: $tt|@html }'", \ + status, + icon, + text, + tooltip)) +} + +END {} diff --git a/.config/waybar/modules/mpris.sh b/.config/waybar/modules/mpris.sh index 5f33f5e..4654a09 100755 --- a/.config/waybar/modules/mpris.sh +++ b/.config/waybar/modules/mpris.sh @@ -1,6 +1,6 @@ #!/bin/bash -set -eo pipefail +set -e [ -n "$DEBUG" ] && set -x -playerctl -sF metadata -f '"{{artist}}","{{album}}","{{title}}","{{duration(position)}}","{{playerName}}","{{lc(status)}}"' | awk -F',' -f "${HOME}/.config/waybar/modules/mpris.awk" +playerctl -sF metadata -f '"{{artist}}","{{album}}","{{title}}","{{duration(position)}}","{{playerName}}","{{lc(status)}}"' 2>/dev/null | awk -F',' -f "${HOME}/.config/waybar/modules/mpris.awk" |