diff options
author | InigoGutierrez <inigogf.95@gmail.com> | 2021-11-03 21:07:31 +0100 |
---|---|---|
committer | InigoGutierrez <inigogf.95@gmail.com> | 2021-11-03 21:07:31 +0100 |
commit | bbadea145d57d3c9cad8ac1d51683951838c94c9 (patch) | |
tree | 8b223b1ee83507608602e4bffb4ebb290fd95b9d | |
parent | 99eb846567c8cbac32ea2d26f0567f277241798d (diff) | |
download | scripts-bbadea145d57d3c9cad8ac1d51683951838c94c9.tar.gz scripts-bbadea145d57d3c9cad8ac1d51683951838c94c9.zip |
cmusShow.sh: Script to show current playing song.
-rwxr-xr-x | cmusShow.sh | 21 |
1 files changed, 21 insertions, 0 deletions
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})" |