diff options
-rw-r--r-- | TODO | 1 | ||||
-rw-r--r-- | src/plugins/alsa.py | 25 |
2 files changed, 25 insertions, 1 deletions
@@ -47,5 +47,6 @@ Demo plugins: vmstat weather hdparm + alsa :: get_mute, set_mute, set_volume Terminal mode 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(): ''' |