aboutsummaryrefslogtreecommitdiff
path: root/dwm-audio
blob: 3ef43317f13cbeafc83c10ca667392f0b9e95d03 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
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