-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathvolume
More file actions
executable file
·66 lines (57 loc) · 1.69 KB
/
volume
File metadata and controls
executable file
·66 lines (57 loc) · 1.69 KB
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/usr/bin/env bash
#
# Saumon i3blocks scripts
# volume (pulseaudio volume display and control)
#
if ! command -v pactl >/dev/null; then
echo " !dep "
exit 33
fi
case $BLOCK_BUTTON in
2) pgrep pavucontrol || pavucontrol & ;;& # middle click: bring up volume mixer
3) pactl set-sink-mute @DEFAULT_SINK@ toggle ;;& # right click: toggle mute
4) pactl set-sink-volume @DEFAULT_SINK@ +4% ;;& # scroll up: increase vol by 4%
5) pactl set-sink-volume @DEFAULT_SINK@ -4% ;;& # scroll down: decrease vol by 4%
2|3|4|5) pkill -RTMIN+10 i3blocks ;;
esac
active_sink=$(pactl get-default-sink)
sink=$(pactl list sinks | grep -A100 "Name: $active_sink")
if [[ "$sink" == *"bluez"* ]]; then isbluetooth=1; fi
if [[ "$sink" == *"Active Port: analog-output-headphone"* ]]; then isheadphone=1; fi
# I can we can use `pactl get-sink-mute @DEFAULT_SINK@` but it's less efficient :)
if [[ "$sink" == *"Mute: yes"* ]]; then ismuted=1; fi
volume=$(echo "$sink" | grep "Volume: " | head -1 | awk '{print $5}' | tr -d '%')
if [ -n "$isbluetooth" ]; then
if [ -n "$ismuted" ]; then
color="#997CC5"
else
color="#1E88E5"
fi
elif [ -n "$isheadphone" ]; then
if [ -n "$ismuted" ]; then
color="#FBC02D"
else
color="#F8E744"
fi
elif [ -n "$ismuted" ]; then
color="#EF6C00"
else
color="#dddddd"
fi
printf "<span color='%s'>" "$color"
if [ -n "$ismuted" ]; then
printf "<s> "
fi
if [ -n "$isbluetooth" ]; then
printf "<span fallback='true'> </span>"
fi
if [ "$volume" -ge 40 ]; then
printf "<span fallback='true'> </span>%s" "$volume"
else
printf "<span fallback='true'> </span>%s" "$volume"
fi
printf "<small>%%</small>"
if [ -n "$ismuted" ]; then
printf " </s>"
fi
echo "</span>"