From e2c3ff00fbf05c33909f60bf6c148e2f156fdbc2 Mon Sep 17 00:00:00 2001 From: ArijanJ <56356662+ArijanJ@users.noreply.github.com> Date: Tue, 10 Feb 2026 21:44:56 +0100 Subject: [PATCH] feat(ipc): add player-specific mpris volume control (#1645) * feat: add mpris volume control through ipc * feat: add mpris volume action and default binds --- core/internal/config/embedded/hypr-binds.conf | 2 ++ core/internal/config/embedded/niri-binds.kdl | 6 ++++ quickshell/Common/KeybindActions.js | 10 +++++++ quickshell/DMSShellIPC.qml | 30 +++++++++++++++++++ 4 files changed, 48 insertions(+) diff --git a/core/internal/config/embedded/hypr-binds.conf b/core/internal/config/embedded/hypr-binds.conf index 058dfd20..af8e2154 100644 --- a/core/internal/config/embedded/hypr-binds.conf +++ b/core/internal/config/embedded/hypr-binds.conf @@ -27,6 +27,8 @@ bindl = , XF86AudioPause, exec, dms ipc call mpris playPause bindl = , XF86AudioPlay, exec, dms ipc call mpris playPause bindl = , XF86AudioPrev, exec, dms ipc call mpris previous bindl = , XF86AudioNext, exec, dms ipc call mpris next +bindel = CTRL, XF86AudioRaiseVolume, exec, dms ipc call mpris increment 3 +bindel = CTRL, XF86AudioLowerVolume, exec, dms ipc call mpris decrement 3 # === Brightness Controls === bindel = , XF86MonBrightnessUp, exec, dms ipc call brightness increment 5 "" diff --git a/core/internal/config/embedded/niri-binds.kdl b/core/internal/config/embedded/niri-binds.kdl index 7fe7ea4a..27cb860e 100644 --- a/core/internal/config/embedded/niri-binds.kdl +++ b/core/internal/config/embedded/niri-binds.kdl @@ -60,6 +60,12 @@ binds { XF86AudioNext allow-when-locked=true { spawn "dms" "ipc" "call" "mpris" "next"; } + Ctrl+XF86AudioRaiseVolume allow-when-locked=true { + spawn "dms" "ipc" "call" "mpris" "increment" "3"; + } + Ctrl+XF86AudioLowerVolume allow-when-locked=true { + spawn "dms" "ipc" "call" "mpris" "decrement" "3"; + } // === Brightness Controls === XF86MonBrightnessUp allow-when-locked=true { diff --git a/quickshell/Common/KeybindActions.js b/quickshell/Common/KeybindActions.js index 55fa2f42..25b1ed07 100644 --- a/quickshell/Common/KeybindActions.js +++ b/quickshell/Common/KeybindActions.js @@ -57,6 +57,8 @@ const DMS_ACTIONS = [ { id: "spawn dms ipc call audio decrement 1", label: "Volume Down (1%)" }, { id: "spawn dms ipc call audio decrement 5", label: "Volume Down (5%)" }, { id: "spawn dms ipc call audio decrement 10", label: "Volume Down (10%)" }, + { id: "spawn dms ipc call mpris increment 5", label: "Player Volume Up (5%)" }, + { id: "spawn dms ipc call mpris decrement 5", label: "Player Volume Down (5%)" }, { id: "spawn dms ipc call audio mute", label: "Volume Mute Toggle" }, { id: "spawn dms ipc call audio micmute", label: "Microphone Mute Toggle" }, { id: "spawn dms ipc call audio cycleoutput", label: "Audio Output: Cycle" }, @@ -719,6 +721,14 @@ const DMS_ACTION_ARGS = { base: "spawn dms ipc call audio decrement", args: [{ name: "amount", type: "number", label: "Amount %", placeholder: "5", default: "5" }] }, + "player increment": { + base: "spawn dms ipc call mpris increment", + args: [{ name: "amount", type: "number", label: "Amount %", placeholder: "5", default: "5" }] + }, + "player decrement": { + base: "spawn dms ipc call mpris decrement", + args: [{ name: "amount", type: "number", label: "Amount %", placeholder: "5", default: "5" }] + }, "brightness increment": { base: "spawn dms ipc call brightness increment", args: [ diff --git a/quickshell/DMSShellIPC.qml b/quickshell/DMSShellIPC.qml index d4f28717..39879516 100644 --- a/quickshell/DMSShellIPC.qml +++ b/quickshell/DMSShellIPC.qml @@ -339,6 +339,36 @@ Item { } } + function increment(step: string): string { + if (MprisController.activePlayer && MprisController.activePlayer.volumeSupported) { + const currentVolume = Math.round(MprisController.activePlayer.volume * 100); + const stepValue = parseInt(step || "5"); + const newVolume = Math.max(0, Math.min(100, currentVolume + stepValue)); + + MprisController.activePlayer.volume = newVolume / 100; + return `Player volume increased to ${newVolume}%`; + } + } + + function decrement(step: string): string { + if (MprisController.activePlayer && MprisController.activePlayer.volumeSupported) { + const currentVolume = Math.round(MprisController.activePlayer.volume * 100); + const stepValue = parseInt(step || "5"); + const newVolume = Math.max(0, Math.min(100, currentVolume - stepValue)); + + MprisController.activePlayer.volume = newVolume / 100; + return `Player volume decreased to ${newVolume}%`; + } + } + + function setvolume(percentage: string): string { + if (MprisController.activePlayer && MprisController.activePlayer.volumeSupported) { + const clampedVolume = Math.max(0, Math.min(100, percentage)); + MprisController.activePlayer.volume = clampedVolume / 100; + return `Player volume set to ${clampedVolume}%`; + } + } + target: "mpris" }