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 +++++++++++++++++++++----- vol.sh | 9 ++++++++- 2 files changed, 29 insertions(+), 6 deletions(-) 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)) diff --git a/vol.sh b/vol.sh index 180cfe6..6b8081f 100755 --- a/vol.sh +++ b/vol.sh @@ -8,5 +8,12 @@ else pactl set-sink-volume "$sink" "$1%" fi -dunstify -r "$(dunstifyIDs.sh "vol")" -t 500 "$(~/scripts/i3blocks/i3vol.sh)" +text="$(~/scripts/i3blocks/i3vol.sh)" +vol="$(echo "$text" | cut -d' ' -f2-)" + +dunstify -r "$(dunstifyIDs.sh "vol")" \ + -t 500 \ + -h "int:value:${vol}" \ + "$text" + [ -n "$STATUS_BAR" ] && pkill -SIGRTMIN+10 "$STATUS_BAR" -- cgit v1.2.1