aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorInigoGutierrez <inigogf.95@gmail.com>2024-02-13 11:54:59 +0100
committerInigoGutierrez <inigogf.95@gmail.com>2024-02-13 11:54:59 +0100
commit25808c12e41337e6c6b2dd7dc4c7db6b5bebfe6a (patch)
tree5cb9321af043e9be61a95f144401d3e671b9ea0e
parent52f5c1d727bf07de425dae724c2da54b21cc0374 (diff)
downloadscripts-25808c12e41337e6c6b2dd7dc4c7db6b5bebfe6a.tar.gz
scripts-25808c12e41337e6c6b2dd7dc4c7db6b5bebfe6a.zip
Updated cmusShow.sh and vol.sh to give more info.
-rwxr-xr-xcmusShow.sh26
-rwxr-xr-xvol.sh9
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"