diff options
| author | Robin Seger <pixelkhaos@live.com> | 2025-09-23 10:04:21 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-09-23 18:04:21 +1000 |
| commit | bef5359702c6300fda097f56681e5d2820d62613 (patch) | |
| tree | 4f08afdb94ae92c044f9c830d8fc878cedc613a8 /services/Audio.qml | |
| parent | plugin: fix clazy warnings (diff) | |
| download | caelestia-shell-bef5359702c6300fda097f56681e5d2820d62613.tar.gz caelestia-shell-bef5359702c6300fda097f56681e5d2820d62613.tar.bz2 caelestia-shell-bef5359702c6300fda097f56681e5d2820d62613.zip | |
audio: audio device changed toasts (#684)
* Added toast notifications for audio device changes
* rename to toasts
* moved into audio service
* fixes
---------
Co-authored-by: 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com>
Diffstat (limited to 'services/Audio.qml')
| -rw-r--r-- | services/Audio.qml | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/services/Audio.qml b/services/Audio.qml index 95990c5..bc87d46 100644 --- a/services/Audio.qml +++ b/services/Audio.qml @@ -2,12 +2,17 @@ pragma Singleton import qs.config import Caelestia.Services +import Caelestia import Quickshell import Quickshell.Services.Pipewire +import QtQuick Singleton { id: root + property string previousSinkName: "" + property string previousSourceName: "" + readonly property var nodes: Pipewire.nodes.values.reduce((acc, node) => { if (!node.isStream) { if (node.isSink) @@ -74,6 +79,35 @@ Singleton { Pipewire.preferredDefaultAudioSource = newSource; } + onSinkChanged: { + if (!sink?.ready) + return; + + const newSinkName = sink.description || sink.name || qsTr("Unknown Device"); + + if (previousSinkName && previousSinkName !== newSinkName && Config.utilities.toasts.audioOutputChanged) + Toaster.toast(qsTr("Audio output changed"), qsTr("Now using: %1").arg(newSinkName), "volume_up"); + + previousSinkName = newSinkName; + } + + onSourceChanged: { + if (!source?.ready) + return; + + const newSourceName = source.description || source.name || qsTr("Unknown Device"); + + if (previousSourceName && previousSourceName !== newSourceName && Config.utilities.toasts.audioInputChanged) + Toaster.toast(qsTr("Audio input changed"), qsTr("Now using: %1").arg(newSourceName), "mic"); + + previousSourceName = newSourceName; + } + + Component.onCompleted: { + previousSinkName = sink?.description || sink?.name || qsTr("Unknown Device"); + previousSourceName = source?.description || source?.name || qsTr("Unknown Device"); + } + PwObjectTracker { objects: [...root.sinks, ...root.sources] } |