mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-04-04 04:42:05 -04:00
feat(ipc): add player-specific mpris volume control (#1645)
* feat: add mpris volume control through ipc * feat: add mpris volume action and default binds
This commit is contained in:
@@ -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: [
|
||||
|
||||
@@ -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"
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user