From bbadea145d57d3c9cad8ac1d51683951838c94c9 Mon Sep 17 00:00:00 2001 From: InigoGutierrez Date: Wed, 3 Nov 2021 21:07:31 +0100 Subject: cmusShow.sh: Script to show current playing song. --- cmusShow.sh | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100755 cmusShow.sh (limited to 'cmusShow.sh') diff --git a/cmusShow.sh b/cmusShow.sh new file mode 100755 index 0000000..a28d8f2 --- /dev/null +++ b/cmusShow.sh @@ -0,0 +1,21 @@ +#!/bin/sh + +# Shows a notification with info about the current playing song. + +getCmusInfo() { + cmus-remote -Q | grep "^${1} " | cut -d' ' -f "${2}-" +} + +sToTime() { + min=$(( $1 / 60 )) + s=$(( $1 % 60 )) + [ "$s" -lt 10 ] && s="0${s}" + echo "${min}:${s}" +} + +artist="$(getCmusInfo 'tag artist' '3')" +album="$(getCmusInfo 'tag album' '3')" +title="$(getCmusInfo 'tag title' '3')" +position="$(getCmusInfo 'position' '2')" +duration="$(getCmusInfo 'duration' '2')" +dunstify -r "$(dunstifyIDs.sh cmusShow)" "${title}" "${artist} - ${album}\n$(sToTime ${position}) - $(sToTime ${duration})" -- cgit v1.2.1