alsa module, requires pyalsaaudio (from PyPI)

This commit is contained in:
enkore 2013-02-25 18:36:17 +01:00
parent 9ab3c751da
commit 446eda7218
3 changed files with 67 additions and 1 deletions

View File

@ -40,6 +40,26 @@ Many modules let you modify the output via a
[format string](http://docs.python.org/3/library/string.html#formatstrings). [format string](http://docs.python.org/3/library/string.html#formatstrings).
### alsa
Shows volume of ALSA mixer. You can also use this for inputs, btw.
Requires pyalsaaudio
* `format` — {volume} is the current volume, {muted} is one of `muted` or `unmuted`. {card} is the sound card used; {mixer} the mixer. (default: `♪: {volume}`)
* `mixer` — ALSA mixer (default: `Master`)
* `mixer_id` — ALSA mixer id (default: `0`)
* `card` — ALSA sound card (default: `0`)
* `muted` — (default: `M`)
* `unmuted` — (default: ``)
* `color_muted` — (default: `#AAAAAA`)
* `color` — (default: `#FFFFFF`)
* `channel` — (default: `0`)
### backlight ### backlight

47
i3pystatus/alsa.py Normal file
View File

@ -0,0 +1,47 @@
from alsaaudio import Mixer
from i3pystatus import IntervalModule
class ALSA(IntervalModule):
"""
Shows volume of ALSA mixer. You can also use this for inputs, btw.
Requires pyalsaaudio
"""
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"),
("mixer_id", "ALSA mixer id"),
("card", "ALSA sound card"),
"muted", "unmuted",
"color_muted", "color",
"channel"
)
muted = "M"
unmuted = ""
color_muted = "#AAAAAA"
color = "#FFFFFF"
format = "♪: {volume}"
mixer = "Master"
mixer_id = 0
card = 0
channel = 0
def init(self):
self.alsamixer = Mixer(control=self.mixer, id=self.mixer_id, cardindex=self.card)
self.fdict = {
"card": self.alsamixer.cardname(),
"mixer": self.mixer,
}
def run(self):
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
self.output = {
"full_text" : self.format.format(**self.fdict),
"color": self.color_muted if muted else self.color,
}

View File

@ -20,7 +20,6 @@ class Backlight(File):
backlight="acpi_video0" backlight="acpi_video0"
format="{brightness}/{max_brightness}" format="{brightness}/{max_brightness}"
interval=5
base_path = "/sys/class/backlight/{backlight}/" base_path = "/sys/class/backlight/{backlight}/"
components={ components={
"brightness": (int, "brightness"), "brightness": (int, "brightness"),