Compare commits
No commits in common. "4f91067458f15e3d87c751fc972c987fd8b5849e" and "a38d064439f978f19f2b5d460f313228dc0c9294" have entirely different histories.
4f91067458
...
a38d064439
@ -88,7 +88,7 @@
|
||||
separator_height = 2
|
||||
|
||||
# Padding between text and separator.
|
||||
padding = 4
|
||||
padding = 8
|
||||
|
||||
# Horizontal padding.
|
||||
horizontal_padding = 8
|
||||
|
@ -1,4 +1,5 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
# You can call this script like this:
|
||||
@ -7,40 +8,45 @@ set -euo pipefail
|
||||
# $./dunst-volume.sh mute
|
||||
|
||||
get_volume() {
|
||||
amixer -D pipewire get Master | grep '%' | head -n 1 | cut -d '[' -f 2 | cut -d '%' -f 1
|
||||
amixer -D pulse get Master | grep '%' | head -n 1 | cut -d '[' -f 2 | cut -d '%' -f 1
|
||||
}
|
||||
|
||||
is_mute() {
|
||||
amixer -D pipewire get Master | grep '%' | grep -oE '[^ ]+$' | grep off >/dev/null
|
||||
amixer -D pulse get Master | grep '%' | grep -oE '[^ ]+$' | grep off >/dev/null
|
||||
}
|
||||
|
||||
send_notification() {
|
||||
volume=$(get_volume)
|
||||
# Make the bar with the special character ─ (it's not dash -)
|
||||
# https://en.wikipedia.org/wiki/Box-drawing_character
|
||||
#bar=$(seq -s "─" $(($volume / 5)) | sed 's/[0-9]//g')
|
||||
# Send the notification
|
||||
dunstify -i audio-volume-high -r 2593 -a volume-script -h int:value:$volume "Volume - ${volume}%"
|
||||
#dunstify -i audio-volume-high -r 2593 -a volume-script "$volume $bar "
|
||||
dunstify -i audio-volume-high -a volume-script -h int:value:$volume "Volume"
|
||||
}
|
||||
|
||||
|
||||
volume=$(get_volume)
|
||||
|
||||
case $1 in
|
||||
up)
|
||||
send_notification
|
||||
# Set the volume on (if it was muted)
|
||||
amixer -D pipewire set Master on >/dev/null
|
||||
# Up the volume (+ 5%)
|
||||
amixer -D pipewire sset Master 5%+ >/dev/null
|
||||
send_notification
|
||||
;;
|
||||
down)
|
||||
send_notification
|
||||
amixer -D pipewire set Master on >/dev/null
|
||||
amixer -D pipewire sset Master 5%- >/dev/null
|
||||
send_notification
|
||||
;;
|
||||
mute)
|
||||
# Toggle mute
|
||||
amixer -D pipewire set Master 1+ toggle >/dev/null
|
||||
if is_mute; then
|
||||
volume=$(get_volume)
|
||||
dunstify -i audio-volume-muted -r 2593 -a volume-script -h int:value:$volume "Mute"
|
||||
dunstify -i audio-volume-muted -a volume-script -h int:value:$volume "Mute"
|
||||
else
|
||||
send_notification
|
||||
fi
|
||||
# Toggle mute
|
||||
amixer -D pipewire set Master 1+ toggle >/dev/null
|
||||
;;
|
||||
esac
|
||||
|
Loading…
Reference in New Issue
Block a user