diff options
author | Philip Wittamore <philip@wittamore.com> | 2025-05-08 09:19:03 +0200 |
---|---|---|
committer | Philip Wittamore <philip@wittamore.com> | 2025-05-08 09:19:03 +0200 |
commit | d421a29a74f509e44cc3532b2553361ff75bedec (patch) | |
tree | f6ec247d1f3da9f84ee5de0dc4fd86e88ae8dfc6 | |
parent | 8aca8c547605f536bc295dd1941de1ccb05d7b2e (diff) | |
download | scripts-d421a29a74f509e44cc3532b2553361ff75bedec.tar.gz scripts-d421a29a74f509e44cc3532b2553361ff75bedec.tar.bz2 scripts-d421a29a74f509e44cc3532b2553361ff75bedec.zip |
update
-rwxr-xr-x | dwm-audio | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/dwm-audio b/dwm-audio new file mode 100755 index 0000000..3ef4331 --- /dev/null +++ b/dwm-audio @@ -0,0 +1,50 @@ +#!/bin/bash + +# Manage Thinkpad Audio keys + +# retrieve colour from pywal cache +bar_colour=$(sed '4q;d' ~/.cache/wal/colors) + +msgTag="Audio" + +# Microphone +if [[ "$@" == "mictoggle" ]]; then + pamixer --default-source -t + micmute="$(pamixer --default-source --get-mute)" + if [[ "$micmute" == "true" ]]; then + # Mic muted notification + dunstify -t 1000 -a "Microphone" -u low -i microphone-sensitivity-muted-symbolic \ + -h string:x-dunst-stack-tag:$msgTag "Microphone muted" + else + # Mic unmuted notification + dunstify -t 1000 -a "Microphone" -u low -i microphone-sensitivity-high-symbolic \ + -h string:x-dunst-stack-tag:$msgTag "Microphone unmuted" + fi + exit 0 +fi + +# Speakers +if [[ "$@" == "voltoggle" ]]; then + pamixer --toggle-mute +elif [[ "$@" == "vollouder" ]]; then + pamixer -u + pamixer -i 10 +elif [[ "$@" == "volquieter" ]]; then + pamixer -u + pamixer -d 10 +fi + +volume="$(pamixer --get-volume-human)" +mute="$(pamixer --get-mute)" +if [[ $volume == 0 || "$mute" == "true" ]]; then + # Sound muted notification + dunstify -t 1000 -a "changeVolume" -u low -i audio-volume-muted-blocking-symbolic \ + -h string:x-dunst-stack-tag:$msgTag "Volume muted" + canberra-gtk-play -i audio-volume-change -d "changeVolume" +else + # Volume notification + dunstify -t 1000 -a "changeVolume" -u low -i audio-volume-high-symbolic \ + -h string:x-dunst-stack-tag:$msgTag -h int:value:"$volume" "Volume: ${volume}" \ + -h string:hlcolor:$bar_colour + canberra-gtk-play -i audio-volume-change -d "changeVolume" +fi |