From 0d9ab6ae499cdc7b6c2f7cd8df4ccfbb6be14999 Mon Sep 17 00:00:00 2001 From: 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> Date: Sat, 23 Aug 2025 21:34:31 +1000 Subject: config: player aliases + config default player Closes #441 --- README.md | 4 ++++ config/ServiceConfig.qml | 6 ++++++ modules/dashboard/Media.qml | 4 ++-- services/Players.qml | 10 ++++++++-- 4 files changed, 20 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index d5e4025..731c1f1 100644 --- a/README.md +++ b/README.md @@ -315,6 +315,10 @@ All configuration options are in `~/.config/caelestia/shell.json`. }, "services": { "audioIncrement": 0.1, + "defaultPlayer": "Spotify", + "playerAliases": [{ + "com.github.th_ch.youtube_music": "YT Music" + }], "weatherLocation": "10,10", "useFahrenheit": false, "useTwelveHourClock": false, diff --git a/config/ServiceConfig.qml b/config/ServiceConfig.qml index 0411b1a..4124147 100644 --- a/config/ServiceConfig.qml +++ b/config/ServiceConfig.qml @@ -7,4 +7,10 @@ JsonObject { property bool useTwelveHourClock: Qt.locale().timeFormat(Locale.ShortFormat).toLowerCase().includes("a") property real audioIncrement: 0.1 property bool smartScheme: true + property string defaultPlayer: "Spotify" + property list playerAliases: [ + { + "com.github.th_ch.youtube_music": "YT Music" + } + ] } diff --git a/modules/dashboard/Media.qml b/modules/dashboard/Media.qml index db43252..d0946e7 100644 --- a/modules/dashboard/Media.qml +++ b/modules/dashboard/Media.qml @@ -372,7 +372,7 @@ Item { StyledText { Layout.fillWidth: true Layout.maximumWidth: playerSelector.implicitWidth - implicitHeight - parent.spacing - Appearance.padding.normal * 2 - text: Players.active?.identity ?? "No players" + text: Players.active ? Players.getIdentity(Players.active) : qsTr("No players") color: Players.active ? Colours.palette.m3onSurface : Colours.palette.m3onSurfaceVariant elide: Text.ElideRight } @@ -444,7 +444,7 @@ Item { } StyledText { - text: player.modelData.identity + text: Players.getIdentity(player.modelData) color: Colours.palette.m3onSecondaryContainer } } diff --git a/services/Players.qml b/services/Players.qml index 9c197f1..27249af 100644 --- a/services/Players.qml +++ b/services/Players.qml @@ -1,6 +1,7 @@ pragma Singleton import qs.components.misc +import qs.config import Quickshell import Quickshell.Io import Quickshell.Services.Mpris @@ -9,9 +10,14 @@ Singleton { id: root readonly property list list: Mpris.players.values - readonly property MprisPlayer active: manualActive ?? list.find(p => p.identity === "Spotify") ?? list[0] ?? null + readonly property MprisPlayer active: manualActive ?? list.find(p => getIdentity(p) === Config.services.defaultPlayer) ?? list[0] ?? null property MprisPlayer manualActive + function getIdentity(player: MprisPlayer): string { + const alias = Config.services.playerAliases.find(a => a.from === player.identity); + return alias?.to ?? player.identity; + } + CustomShortcut { name: "mediaToggle" description: "Toggle media playback" @@ -57,7 +63,7 @@ Singleton { } function list(): string { - return root.list.map(p => p.identity).join("\n"); + return root.list.map(p => root.getIdentity(p)).join("\n"); } function play(): void { -- cgit v1.2.3-freya