From ce70addd5b17da95a6e05c1fb1e94cb03944d99d Mon Sep 17 00:00:00 2001 From: "Danilo M." Date: Tue, 10 Nov 2026 18:28:20 +0100 Subject: feat(music): a volume slider with a mute toggle, icon buttons The Vol-, Mute and Vol+ buttons give way to a mute toggle (its icon shows the state) and a 0-100 slider that sets the default sink with wpctl as it moves. Previous, play/pause and next are Nerd Font glyphs instead of the tablet's Unicode symbols. Co-Authored-By: Claude Opus 5.5 --- deckit/modules/music.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'deckit') 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) -- cgit v1.2.3