diff options
author | Mattias Andrée <maandree@operamail.com> | 2015-03-28 18:35:20 +0100 |
---|---|---|
committer | Mattias Andrée <maandree@operamail.com> | 2015-03-28 18:35:20 +0100 |
commit | af8e3067e8c64ef3317dd4e108af56d5b7ad2f3e (patch) | |
tree | b66de1d12088302b89e930964a00e26130a668c2 /src/plugins/alsa.py | |
parent | update dist (diff) | |
download | xpybar-af8e3067e8c64ef3317dd4e108af56d5b7ad2f3e.tar.gz xpybar-af8e3067e8c64ef3317dd4e108af56d5b7ad2f3e.tar.bz2 xpybar-af8e3067e8c64ef3317dd4e108af56d5b7ad2f3e.tar.xz |
alsa: add get_mute and set_mute
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to '')
-rw-r--r-- | src/plugins/alsa.py | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/src/plugins/alsa.py b/src/plugins/alsa.py index b955130..e9f144f 100644 --- a/src/plugins/alsa.py +++ b/src/plugins/alsa.py @@ -67,7 +67,7 @@ class ALSA: def set_volume(self, volume, channel = -1): ''' - set the volume for a channel on the mixer + Set the volume for a channel on the mixer @param volume:int? The [0, 100] volume for the channel, `None` to mute the channel @param channel:int The index of the channel, `ALSA.ALL_CHANNELS` (-1) for all channels @@ -82,6 +82,29 @@ class ALSA: pass # some mixers do not have mute switch + def get_mute(self): + ''' + Get the mute status for each channel on the mixer + + @return :list<bool> Whether mixer is muted for each channel + ''' + self.mixer = alsaaudio.Mixer(self.mixername, 0, self.cardindex) + try: + return [m == 1 for m in self.mixer.getmute()] + except: + return [False] * len(self.mixer.getvolume()) + + + def set_mute(self, mute, channel = -1): + ''' + Set the mute status on the mixer + + @param mute:bool Whether the mixer should be muted on the channel + @param channel:int The index of the channel, `ALSA.ALL_CHANNELS` (-1) for all channels + ''' + self.mixer.setmute(mute, channel) + + @staticmethod def get_cards(): ''' |