3.13: MPD module, ALSA fix
This commit is contained in:
parent
5371ab4276
commit
dccbc63826
23
README.md
23
README.md
@ -271,6 +271,29 @@ __Settings:__
|
||||
|
||||
|
||||
|
||||
### mpd
|
||||
|
||||
|
||||
Displays various information from MPD (the music player daemon)
|
||||
|
||||
Available formatters:
|
||||
* title (the title of the current song)
|
||||
* album (the album of the current song, can be an empty string (e.g. for online streams))
|
||||
* artist (can be empty, too)
|
||||
* playtime_h (Playtime, hours)
|
||||
* playtime_m (Playtime, minutes)
|
||||
* playtime_s (Playtime, seconds)
|
||||
* pos (Position of current song in playlist, one-based)
|
||||
* len (Length of current playlist)
|
||||
|
||||
|
||||
__Settings:__
|
||||
|
||||
* `port` — MPD port (default: `6600`)
|
||||
* `format` — (default: `{title} [{playtime_h}:{playtime_m}:{playtime_s}]`)
|
||||
|
||||
|
||||
|
||||
### network
|
||||
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
from alsaaudio import Mixer
|
||||
from alsaaudio import Mixer, ALSAAudioError
|
||||
|
||||
from i3pystatus import IntervalModule
|
||||
|
||||
@ -9,6 +9,8 @@ class ALSA(IntervalModule):
|
||||
Requires pyalsaaudio
|
||||
"""
|
||||
|
||||
interval = 1
|
||||
|
||||
settings = (
|
||||
("format", "{volume} is the current volume, {muted} is one of `muted` or `unmuted`. {card} is the sound card used; {mixer} the mixer."),
|
||||
("mixer", "ALSA mixer"),
|
||||
@ -30,9 +32,15 @@ class ALSA(IntervalModule):
|
||||
channel = 0
|
||||
|
||||
alsamixer = None
|
||||
has_mute = True
|
||||
|
||||
def init(self):
|
||||
self.create_mixer()
|
||||
try:
|
||||
self.alsamixer.getmute()
|
||||
except ALSAAudioError:
|
||||
self.has_mute = False
|
||||
|
||||
self.fdict = {
|
||||
"card": self.alsamixer.cardname(),
|
||||
"mixer": self.mixer,
|
||||
@ -44,7 +52,9 @@ class ALSA(IntervalModule):
|
||||
def run(self):
|
||||
self.create_mixer()
|
||||
|
||||
muted = self.alsamixer.getmute()[self.channel] == 1
|
||||
muted = False
|
||||
if self.has_mute:
|
||||
muted = self.alsamixer.getmute()[self.channel] == 1
|
||||
self.fdict["volume"] = self.alsamixer.getvolume()[self.channel]
|
||||
self.fdict["muted"] = self.muted if muted else self.muted
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user