diff options
| -rw-r--r-- | py3status/modules/player_control.py | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/py3status/modules/player_control.py b/py3status/modules/player_control.py index e6e526c..4f00602 100644 --- a/py3status/modules/player_control.py +++ b/py3status/modules/player_control.py @@ -29,11 +29,13 @@ class Py3status: Configuration parameters: - debug: enable verbose logging (bool) (default: False) - supported_players: supported players (str) (whitespace separated list) + - volume_tick: percentage volume change on mouse wheel (int) (positive number or None to disable it) """ - supported_players = 'audacious' debug = False + supported_players = 'audacious' + volume_tick = 1 def __init__(self): self.status = 'stop' @@ -48,6 +50,13 @@ class Py3status: except IndexError: return + if button in ('up', 'down'): + if self.volume_tick is None: + return + + self._change_volume(button=='up') + return + if self.status == 'play': if button == 'left': self._stop() @@ -90,6 +99,13 @@ class Py3status: if player_name == 'audacious': self._run(['/usr/bin/audacious', '-u']) + def _change_volume(self, increase): + """Change volume using amixer + """ + sign = '+' if increase else '-' + delta = "%d%%%s" % (self.volume_tick, sign) + self._run(('/usr/bin/amixer', '-q', 'sset', 'Master', delta)) + def _detect_running_player(self): """Detect running player process, if any """ |
