toasts: add toast for media track change (#790)

This commit is contained in:
dish 2025-10-14 23:03:14 -04:00 committed by GitHub
parent fe4ebb79b6
commit 4cb1048fdd
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 17 additions and 0 deletions

View file

@ -591,6 +591,7 @@ default, you must create it manually.
"kbLayoutChanged": true, "kbLayoutChanged": true,
"numLockChanged": true, "numLockChanged": true,
"vpnChanged": true, "vpnChanged": true,
"nowPlaying": false
}, },
"vpn": { "vpn": {
"enabled": false, "enabled": false,

View file

@ -24,6 +24,7 @@ JsonObject {
property bool numLockChanged: true property bool numLockChanged: true
property bool kbLayoutChanged: true property bool kbLayoutChanged: true
property bool vpnChanged: true property bool vpnChanged: true
property bool nowPlaying: false
} }
component Vpn: JsonObject { component Vpn: JsonObject {

View file

@ -5,6 +5,8 @@ import qs.config
import Quickshell import Quickshell
import Quickshell.Io import Quickshell.Io
import Quickshell.Services.Mpris import Quickshell.Services.Mpris
import QtQml
import Caelestia
Singleton { Singleton {
id: root id: root
@ -18,6 +20,19 @@ Singleton {
return alias?.to ?? player.identity; return alias?.to ?? player.identity;
} }
Connections {
target: active
function onPostTrackChanged() {
if (!Config.utilities.toasts.nowPlaying) {
return;
}
if (active.trackArtist != "" && active.trackTitle != "") {
Toaster.toast(qsTr("Now Playing"), qsTr("%1 - %2").arg(active.trackArtist).arg(active.trackTitle), "music_note");
}
}
}
PersistentProperties { PersistentProperties {
id: props id: props