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
|
### network
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
from alsaaudio import Mixer
|
from alsaaudio import Mixer, ALSAAudioError
|
||||||
|
|
||||||
from i3pystatus import IntervalModule
|
from i3pystatus import IntervalModule
|
||||||
|
|
||||||
@ -9,6 +9,8 @@ class ALSA(IntervalModule):
|
|||||||
Requires pyalsaaudio
|
Requires pyalsaaudio
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
interval = 1
|
||||||
|
|
||||||
settings = (
|
settings = (
|
||||||
("format", "{volume} is the current volume, {muted} is one of `muted` or `unmuted`. {card} is the sound card used; {mixer} the mixer."),
|
("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"),
|
("mixer", "ALSA mixer"),
|
||||||
@ -30,9 +32,15 @@ class ALSA(IntervalModule):
|
|||||||
channel = 0
|
channel = 0
|
||||||
|
|
||||||
alsamixer = None
|
alsamixer = None
|
||||||
|
has_mute = True
|
||||||
|
|
||||||
def init(self):
|
def init(self):
|
||||||
self.create_mixer()
|
self.create_mixer()
|
||||||
|
try:
|
||||||
|
self.alsamixer.getmute()
|
||||||
|
except ALSAAudioError:
|
||||||
|
self.has_mute = False
|
||||||
|
|
||||||
self.fdict = {
|
self.fdict = {
|
||||||
"card": self.alsamixer.cardname(),
|
"card": self.alsamixer.cardname(),
|
||||||
"mixer": self.mixer,
|
"mixer": self.mixer,
|
||||||
@ -44,7 +52,9 @@ class ALSA(IntervalModule):
|
|||||||
def run(self):
|
def run(self):
|
||||||
self.create_mixer()
|
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["volume"] = self.alsamixer.getvolume()[self.channel]
|
||||||
self.fdict["muted"] = self.muted if muted else self.muted
|
self.fdict["muted"] = self.muted if muted else self.muted
|
||||||
|
|
||||||
|
2
setup.py
2
setup.py
@ -3,7 +3,7 @@
|
|||||||
from setuptools import setup
|
from setuptools import setup
|
||||||
|
|
||||||
setup(name="i3pystatus",
|
setup(name="i3pystatus",
|
||||||
version="3.12",
|
version="3.13",
|
||||||
description="Like i3status, this generates status line for i3bar / i3wm",
|
description="Like i3status, this generates status line for i3bar / i3wm",
|
||||||
url="http://github.com/enkore/i3pystatus",
|
url="http://github.com/enkore/i3pystatus",
|
||||||
license="MIT",
|
license="MIT",
|
||||||
|
Loading…
Reference in New Issue
Block a user