1
0
Fork 0

Change volume keybindings and monitoring

This commit is contained in:
Jeremy Kaplan 2016-12-15 20:36:34 -05:00
commit a9e6391d22
2 changed files with 15 additions and 5 deletions

View file

@ -68,9 +68,13 @@ def clock_update(_):
def volume_update(_): def volume_update(_):
info = subprocess.check_output(['pulseaudio-ctl', 'full-status']) info = subprocess.check_output(['pactl', 'list', 'sinks']).decode('utf-8')
info = info[:-1].decode('utf-8') info = (line.strip() for line in info[:-1].split('\n'))
volume, mute, _ = info.split(' ') for line in info:
if line.startswith('Volume:'):
volume = line.split('/')[1].strip()[:-1]
elif line.startswith('Mute:'):
mute = line.split(' ')[1].strip()
volume = int(volume) volume = int(volume)
muted = mute == 'yes' muted = mute == 'yes'
mute_icon = "-" if muted else "%" mute_icon = "-" if muted else "%"

View file

@ -19,8 +19,14 @@ super + shift + semicolon
i3lock -e -i ~/images/lockscreen.png i3lock -e -i ~/images/lockscreen.png
# volume keys # volume keys
XF86Audio{Mute,LowerVolume,RaiseVolume} XF86AudioMute
pulseaudio-ctl {mute,down,up} pactl set-sink-mute @DEFAULT_SINK@ toggle
XF86Audio{LowerVolume,RaiseVolume}
pactl set-sink-volume @DEFAULT_SINK@ {-,+}5%
XF86AudioMicMute
pactl set-source-mute @DEFAULT_SOURCE@ toggle
# #