diff options
| author | Federico Ceratto <federico.ceratto@gmail.com> | 2015-03-27 12:30:23 +0000 |
|---|---|---|
| committer | Federico Ceratto <federico.ceratto@gmail.com> | 2015-03-27 12:30:23 +0000 |
| commit | 023479fab451657cbac68b87830dd48926b4e390 (patch) | |
| tree | e6215c09f44492a206e5356387f081e618bd99ef /py3status/modules/player_control.py | |
| parent | d6140718a9d1ec71b0495a028972baebccbd4fb3 (diff) | |
Add volume control
Diffstat (limited to 'py3status/modules/player_control.py')
| -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 """ |
