3.13: MPD module, ALSA fix

This commit is contained in:
enkore 2013-07-01 20:41:03 +02:00
parent 5371ab4276
commit dccbc63826
3 changed files with 36 additions and 3 deletions

View File

@ -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

View File

@ -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

View File

@ -3,7 +3,7 @@
from setuptools import setup
setup(name="i3pystatus",
version="3.12",
version="3.13",
description="Like i3status, this generates status line for i3bar / i3wm",
url="http://github.com/enkore/i3pystatus",
license="MIT",