From 25808c12e41337e6c6b2dd7dc4c7db6b5bebfe6a Mon Sep 17 00:00:00 2001 From: InigoGutierrez Date: Tue, 13 Feb 2024 11:54:59 +0100 Subject: Updated cmusShow.sh and vol.sh to give more info. --- cmusShow.sh | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) (limited to 'cmusShow.sh') diff --git a/cmusShow.sh b/cmusShow.sh index 8e36b3b..b61e908 100755 --- a/cmusShow.sh +++ b/cmusShow.sh @@ -1,12 +1,13 @@ #!/bin/sh -# Shows a notification with info about the current playing song. +# Shows a notification with info about the currently playing song. scriptName="${0##*/}" [ "$(pgrep "${scriptName}" | wc -l)" -gt "2" ] && exit 0 -notificationFreq=0.1 -steps=20 +notificationFreq=0.5 +steps=10 +iconSize='128' bluetoothInfo='' getCmusInfo() { @@ -20,6 +21,14 @@ sToTime() { echo "${min}:${s}" } +# Album art info + +playingFile="$(getCmusInfo 'file' '2')" +albumArt="/tmp/$(echo "$playingFile" | base64 -w0).png" +ffmpeg -y -i "$playingFile" -an -vf scale="${iconSize}:${iconSize}" "$albumArt" + +# Bluetooth info + if bluetoothctl info; then device="📻 $(bluetoothctl info | grep 'Name: ' | @@ -31,7 +40,6 @@ if bluetoothctl info; then bluetoothInfo="\n${device} - ${battery}" fi - i=0 while [ "$i" -lt "$steps" ]; do @@ -45,7 +53,15 @@ while [ "$i" -lt "$steps" ]; do position="$(getCmusInfo 'position' '2')" duration="$(getCmusInfo 'duration' '2')" - dunstify -r "$(dunstifyIDs.sh cmusShow)" -t 250 "${title}" "${artist} - ${album}\n${playingIcon} $(sToTime "${position}") - $(sToTime "${duration}")${bluetoothInfo}" + percentage="$(awk "BEGIN { print int(${position}/${duration}*100) }")" + + dunstify \ + -r "$(dunstifyIDs.sh cmusShow)" \ + -t 1000 \ + -i "$albumArt" \ + -h "int:value:${percentage}" \ + "${title}" \ + "${artist} - ${album}\n${playingIcon} $(sToTime "${position}") - $(sToTime "${duration}")${bluetoothInfo}" sleep "$notificationFreq" i=$((i+1)) -- cgit v1.2.1