]> git.sev.monster Git - dotfiles.git/blob - bin/tint2-alsa
1e851f29129701c27be338804261f3ca8e3d57c5
[dotfiles.git] / bin / tint2-alsa
1 #!/bin/sh
2 base=~/.icons/Paper-Mono-Dark/24x24/panel/audio-volume
3   high=$base-high.svg
4 medium=$base-medium.svg
5    low=$base-low.svg
6  muted=$base-muted.svg
7
8 # TODO: doesn't work if no master mixer, eg usb dac
9 ident="iface=MIXER,name=Master Playback Volume"
10 eval $(amixer cget "$ident" | grep -o 'max=\d\+')
11
12 while true; do
13         # XXX: assume mono, could be different
14         vol=$(amixer get Master | grep 'Mono:')
15         mute=$(echo "$vol" | cut -d ' ' -f 8)
16         vol=$(expr $(echo "$vol" | cut -d ' ' -f 5) \* 100 / $max \* 100 / 100)
17         if [ $mute = '[off]' ]; then
18                 echo $muted
19         elif [ $vol -ge 75 ]; then
20                 echo $high
21         elif [ $vol -ge 50 ]; then
22                 echo $medium
23         elif [ $vol -ge 25 ]; then
24                 echo $low
25         else
26                 echo $muted
27         fi
28         sleep 2
29 done
This page took 0.025293 seconds and 2 git commands to generate.