From e4797dd9324b36c83ff10f5721f1e9841600170d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ferit=20Yi=C4=9Fit=20BALABAN?= Date: Fri, 22 Apr 2022 02:23:06 +0300 Subject: [PATCH 1/2] Even less lines by using playerctl itself to format --- nowplaying.sh | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/nowplaying.sh b/nowplaying.sh index aade69e..c91980f 100755 --- a/nowplaying.sh +++ b/nowplaying.sh @@ -1,9 +1,5 @@ #!/bin/bash - if [ $(playerctl status) = 'Playing' ]; then - a=$( playerctl metadata artist ) - t=$( playerctl metadata title ) - echo "$a - $t" + echo $( playerctl -f '{{trunc(xesam:artist, 20)}} - {{trunc(xesam:title, 30)}}' metadata ) fi - exit 0 From f21f3f71f03c2cdb800d3f16b569e9e985564eda Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ferit=20Yi=C4=9Fit=20BALABAN?= Date: Fri, 22 Apr 2022 15:11:26 +0300 Subject: [PATCH 2/2] Fix error message when nothing is playing --- nowplaying.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/nowplaying.sh b/nowplaying.sh index c91980f..146e427 100755 --- a/nowplaying.sh +++ b/nowplaying.sh @@ -1,5 +1,8 @@ #!/bin/bash -if [ $(playerctl status) = 'Playing' ]; then +status=$( playerctl status ) +if [ $? -eq 0 ]; then echo $( playerctl -f '{{trunc(xesam:artist, 20)}} - {{trunc(xesam:title, 30)}}' metadata ) +else + echo "" fi exit 0