summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobin Seger <pixelkhaos@live.com>2025-09-23 10:04:21 +0200
committerGitHub <noreply@github.com>2025-09-23 18:04:21 +1000
commitbef5359702c6300fda097f56681e5d2820d62613 (patch)
tree4f08afdb94ae92c044f9c830d8fc878cedc613a8
parentplugin: fix clazy warnings (diff)
downloadcaelestia-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>
-rw-r--r--README.md6
-rw-r--r--config/UtilitiesConfig.qml6
-rw-r--r--services/Audio.qml34
3 files changed, 45 insertions, 1 deletions
diff --git a/README.md b/README.md
index 71aedbf..f72ecdc 100644
--- a/README.md
+++ b/README.md
@@ -567,7 +567,11 @@ default, you must create it manually.
},
"utilities": {
"enabled": true,
- "maxToasts": 4
+ "maxToasts": 4,
+ "toasts": {
+ "audioOutputChanged": true,
+ "audioInputChanged": true
+ }
}
}
```
diff --git a/config/UtilitiesConfig.qml b/config/UtilitiesConfig.qml
index d9d4ed5..c1bad2a 100644
--- a/config/UtilitiesConfig.qml
+++ b/config/UtilitiesConfig.qml
@@ -5,8 +5,14 @@ JsonObject {
property int maxToasts: 4
property Sizes sizes: Sizes {}
+ property Toasts toasts: Toasts {}
component Sizes: JsonObject {
property int width: 430
}
+
+ component Toasts: JsonObject {
+ property bool audioOutputChanged: true
+ property bool audioInputChanged: true
+ }
}
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]
}