sway: add OSD to the pactl volume control bindings
This commit is contained in:
parent
6a03cb022b
commit
3a04082a7e
3 changed files with 48 additions and 5 deletions
32
scripts/notify-volume
Executable file
32
scripts/notify-volume
Executable file
|
|
@ -0,0 +1,32 @@
|
|||
#!/bin/sh
|
||||
|
||||
set -ex
|
||||
|
||||
if ! command -v notify-send >/dev/null || ! command -v pactl > /dev/null; then
|
||||
exit 0;
|
||||
fi
|
||||
|
||||
# pactl output depends on the current locale
|
||||
export LANG=C.UTF-8 LC_ALL=C.UTF-8
|
||||
|
||||
SINK=${1:-@DEFAULT_SINK@}
|
||||
VOLUME=$(pactl get-sink-volume "$SINK")
|
||||
# get first percent value
|
||||
VOLUME=${VOLUME%%%*}
|
||||
VOLUME=${VOLUME##* }
|
||||
|
||||
TEXT="Volume: ${VOLUME}%"
|
||||
case $(pactl get-sink-mute "$SINK") in
|
||||
*yes)
|
||||
TEXT="Volume: muted"
|
||||
VOLUME=0
|
||||
;;
|
||||
esac
|
||||
|
||||
notify-send \
|
||||
--app-name sway \
|
||||
--expire-time 800 \
|
||||
--hint string:x-canonical-private-synchronous:volume \
|
||||
--hint "int:value:$VOLUME" \
|
||||
--transient \
|
||||
"${TEXT}"
|
||||
Loading…
Add table
Add a link
Reference in a new issue