diff options
| author | 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> | 2025-05-11 18:42:45 +1000 |
|---|---|---|
| committer | 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> | 2025-05-11 18:42:45 +1000 |
| commit | dbe4852ed6901cc7020497054e839cde6af094c4 (patch) | |
| tree | 47d411955c30cfb26f2a952e76e1007c7894acdc | |
| parent | notif: allow markdown in body (diff) | |
| download | caelestia-shell-dbe4852ed6901cc7020497054e839cde6af094c4.tar.gz caelestia-shell-dbe4852ed6901cc7020497054e839cde6af094c4.tar.bz2 caelestia-shell-dbe4852ed6901cc7020497054e839cde6af094c4.zip | |
feat: mpris shortcuts + ipc
| -rw-r--r-- | services/Players.qml | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/services/Players.qml b/services/Players.qml new file mode 100644 index 0000000..aaf1f9b --- /dev/null +++ b/services/Players.qml @@ -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"; + } + } +} |