diff --git a/dotfiles/.local/bin/commands b/dotfiles/.local/bin/commands new file mode 100755 index 0000000..1b0bacc --- /dev/null +++ b/dotfiles/.local/bin/commands @@ -0,0 +1,45 @@ +#!/usr/bin/python3 +import traceback +import sys +import subprocess + +msg = '' + +try: + if sys.argv[1] == 'media-play-pause': + subprocess.check_call(['playerctl', 'play-pause']) + msg = subprocess.check_output(['playerctl', 'status']).decode('utf-8').strip() + elif sys.argv[1] == 'media-lower-volume': + subprocess.check_call([ + 'pactl', + 'set-sink-volume', + '@DEFAULT_SINK@', + '-5%' + ]) + msg = subprocess.check_output([ + 'pactl', + 'get-sink-volume', + '@DEFAULT_SINK@' + ]).decode('utf-8').strip() + elif sys.argv[1] == 'media-raise-volume': + subprocess.check_call([ + 'pactl', + 'set-sink-volume', + '@DEFAULT_SINK@', + '+5%' + ]) + msg = subprocess.check_output([ + 'pactl', + 'get-sink-volume', + '@DEFAULT_SINK@' + ]).decode('utf-8').strip() + else: + raise NotImplementedError +except: + msg = 'not implemented\n%s' % traceback.format_exc() + +subprocess.check_call([ + 'notify-send', + 'commands', + msg +]) diff --git a/dotfiles/.xbindkeysrc b/dotfiles/.xbindkeysrc index f43854e..9085f9e 100644 --- a/dotfiles/.xbindkeysrc +++ b/dotfiles/.xbindkeysrc @@ -42,7 +42,13 @@ "pactl set-sink-mute @DEFAULT_SINK@ toggle; (pactl get-sink-mute @DEFAULT_SINK@ | grep -Po no > /dev/null); echo $? > /sys/class/leds/hda::mute/brightness" XF86AudioMute -"playerctl play-pause" +"commands media-raise-volume" + XF86AudioRaiseVolume + +"commands media-lower-volume" + XF86AudioLowerVolume + +"commands media-play-pause" XF86AudioPlay #"xbindkeys_show"