feat: mpris shortcuts + ipc
This commit is contained in:
parent
69c9eba3f5
commit
dbe4852ed6
1 changed files with 58 additions and 0 deletions
58
services/Players.qml
Normal file
58
services/Players.qml
Normal file
|
|
@ -0,0 +1,58 @@
|
||||||
|
pragma Singleton
|
||||||
|
|
||||||
|
import "root:/widgets"
|
||||||
|
import Quickshell
|
||||||
|
import Quickshell.Io
|
||||||
|
import Quickshell.Services.Mpris
|
||||||
|
|
||||||
|
Singleton {
|
||||||
|
id: root
|
||||||
|
|
||||||
|
readonly property list<MprisPlayer> list: Mpris.players.values
|
||||||
|
readonly property MprisPlayer active: list.find(p => p.identity === "Spotify") ?? list[0] ?? null
|
||||||
|
|
||||||
|
CustomShortcut {
|
||||||
|
name: "mediaToggle"
|
||||||
|
description: "Toggle media playback"
|
||||||
|
onPressed: {
|
||||||
|
const active = root.active;
|
||||||
|
if (active && active.canTogglePlaying)
|
||||||
|
active.togglePlaying();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
CustomShortcut {
|
||||||
|
name: "mediaPrev"
|
||||||
|
description: "Previous track"
|
||||||
|
onPressed: {
|
||||||
|
const active = root.active;
|
||||||
|
if (active && active.canGoPrevious)
|
||||||
|
active.previous();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
CustomShortcut {
|
||||||
|
name: "mediaNext"
|
||||||
|
description: "Next track"
|
||||||
|
onPressed: {
|
||||||
|
const active = root.active;
|
||||||
|
if (active && active.canGoNext)
|
||||||
|
active.next();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
CustomShortcut {
|
||||||
|
name: "mediaStop"
|
||||||
|
description: "Stop media playback"
|
||||||
|
onPressed: root.active?.stop()
|
||||||
|
}
|
||||||
|
|
||||||
|
IpcHandler {
|
||||||
|
target: "mpris"
|
||||||
|
|
||||||
|
function getActive(prop: string): string {
|
||||||
|
const active = root.active;
|
||||||
|
return active ? active[prop] ?? "Invalid property" : "No active player";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Add table
Reference in a new issue