aboutsummaryrefslogtreecommitdiff
path: root/dwm-audio
diff options
context:
space:
mode:
Diffstat (limited to 'dwm-audio')
-rwxr-xr-xdwm-audio50
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