From dccbc638263a537cc490b4fd435e645e1f3dc56b Mon Sep 17 00:00:00 2001 From: enkore Date: Mon, 1 Jul 2013 20:41:03 +0200 Subject: [PATCH] 3.13: MPD module, ALSA fix --- README.md | 23 +++++++++++++++++++++++ i3pystatus/alsa.py | 14 ++++++++++++-- setup.py | 2 +- 3 files changed, 36 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 37107da..4d27b97 100644 --- a/README.md +++ b/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 diff --git a/i3pystatus/alsa.py b/i3pystatus/alsa.py index 6d63f76..71ec6fe 100644 --- a/i3pystatus/alsa.py +++ b/i3pystatus/alsa.py @@ -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 diff --git a/setup.py b/setup.py index 2f7d262..9139667 100755 --- a/setup.py +++ b/setup.py @@ -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",