aboutsummaryrefslogtreecommitdiffstats
path: root/deckit/modules/music.py
diff options
context:
space:
mode:
Diffstat (limited to 'deckit/modules/music.py')
-rw-r--r--deckit/modules/music.py9
1 files changed, 7 insertions, 2 deletions
diff --git a/deckit/modules/music.py b/deckit/modules/music.py
index aa30798..ef19cd0 100644
--- a/deckit/modules/music.py
+++ b/deckit/modules/music.py
@@ -23,9 +23,7 @@ from ..module import Module, ModuleError
SEP = "\x1f"
BASE_ACTIONS = {
- "voldown": ["wpctl", "set-volume", "@DEFAULT_AUDIO_SINK@", "5%-"],
"mute": ["wpctl", "set-mute", "@DEFAULT_AUDIO_SINK@", "toggle"],
- "volup": ["wpctl", "set-volume", "-l", "1.0", "@DEFAULT_AUDIO_SINK@", "5%+"],
"prev": ["playerctl", "previous"],
"play": ["playerctl", "play-pause"],
"next": ["playerctl", "next"],
@@ -73,6 +71,13 @@ def make(cfg: dict) -> Module:
raise ModuleError("position must be a number")
popen(["playerctl", "position", str(round(float(pos), 1))])
+ def volume(body):
+ level = body.get("level")
+ if isinstance(level, bool) or not isinstance(level, (int, float)) or not 0 <= level <= 100:
+ raise ModuleError("level must be 0-100")
+ popen(["wpctl", "set-volume", "@DEFAULT_AUDIO_SINK@", f"{level / 100:.2f}"])
+
actions = {name: (lambda cmd: (lambda body: popen(cmd)))(cmd) for name, cmd in BASE_ACTIONS.items()}
actions["seek"] = seek
+ actions["volume"] = volume
return Module(name="music", title="Music", state=state, actions=actions)