From 14d27eb3be6698fdb5cf67fdb034556428643c0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ferit=20Yi=C4=9Fit=20BALABAN?= Date: Sat, 16 Jul 2022 01:41:13 +0300 Subject: [PATCH] Improved algorithm aimed to be used with polybar --- nowplaying.sh | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/nowplaying.sh b/nowplaying.sh index cc202a9..eb8b188 100755 --- a/nowplaying.sh +++ b/nowplaying.sh @@ -1,8 +1,17 @@ #!/bin/bash -s=$( playerctl -f '{{trunc(xesam:artist, 20)}} - {{trunc(xesam:title, 30)}}' metadata ) -if [ $? -eq 0 ]; then - echo "$s" +stat=$( playerctl status ) +msg=$( playerctl -f '{{trunc(xesam:artist, 15)}} - {{trunc(xesam:title, 30)}}' metadata ) +if [ "$stat" = "Playing" ]; then + if [ "$msg" = " - " ]; then + echo "No metadata" + else + echo "$msg" + fi else - echo "" + if [ "$stat" = "Paused" ]; then + echo "Paused" + else + echo "" + fi fi exit 0