summaryrefslogtreecommitdiff
path: root/accounts/gkleen@sif/shell/quickshell/VolumeOSD.qml
diff options
context:
space:
mode:
Diffstat (limited to 'accounts/gkleen@sif/shell/quickshell/VolumeOSD.qml')
-rw-r--r--accounts/gkleen@sif/shell/quickshell/VolumeOSD.qml68
1 files changed, 50 insertions, 18 deletions
diff --git a/accounts/gkleen@sif/shell/quickshell/VolumeOSD.qml b/accounts/gkleen@sif/shell/quickshell/VolumeOSD.qml
index 3a78d91b..16fb5dea 100644
--- a/accounts/gkleen@sif/shell/quickshell/VolumeOSD.qml
+++ b/accounts/gkleen@sif/shell/quickshell/VolumeOSD.qml
@@ -7,23 +7,38 @@ import Quickshell.Widgets
7Scope { 7Scope {
8 id: root 8 id: root
9 9
10 property bool show: false 10 property string show: ""
11 property bool inhibited: true 11 property bool inhibited: true
12 12
13 PwObjectTracker { 13 PwObjectTracker {
14 objects: [ Pipewire.defaultAudioSink ] 14 objects: [ Pipewire.defaultAudioSink, Pipewire.defaultAudioSource ]
15 } 15 }
16 16
17 Connections { 17 Connections {
18 enabled: Pipewire.defaultAudioSink
18 target: Pipewire.defaultAudioSink?.audio 19 target: Pipewire.defaultAudioSink?.audio
19 20
20 function onVolumeChanged() { 21 function onVolumeChanged() {
21 root.show = true; 22 root.show = "sink";
22 hideTimer.reset(); 23 hideTimer.restart();
23 } 24 }
24 function onMutedChanged() { 25 function onMutedChanged() {
25 root.show = true; 26 root.show = "sink";
26 hideTimer.reset(); 27 hideTimer.restart();
28 }
29 }
30
31 Connections {
32 enabled: Pipewire.defaultAudioSource
33 target: Pipewire.defaultAudioSource?.audio
34
35 function onVolumeChanged() {
36 root.show = "source";
37 hideTimer.restart();
38 }
39 function onMutedChanged() {
40 root.show = "source";
41 hideTimer.restart();
27 } 42 }
28 } 43 }
29 44
@@ -34,15 +49,18 @@ Scope {
34 49
35 Timer { 50 Timer {
36 id: hideTimer 51 id: hideTimer
37 interval: 2000 52 interval: 1000
38 onTriggered: root.show = false 53 onTriggered: root.show = ""
39 } 54 }
40 55
41 Timer { 56 Timer {
42 id: startInhibit 57 id: startInhibit
43 interval: 100 58 interval: 100
44 running: true 59 running: true
45 onTriggered: root.inhibited = false; 60 onTriggered: {
61 root.show = "";
62 root.inhibited = false;
63 }
46 } 64 }
47 65
48 LazyLoader { 66 LazyLoader {
@@ -62,8 +80,9 @@ Scope {
62 screen: screenScope.modelData 80 screen: screenScope.modelData
63 81
64 anchors.top: true 82 anchors.top: true
65 margins.top: (screen.height - window.height) / 2 83 margins.top: screen.height / 2 - 50 + 3.5
66 exclusiveZone: 0 84 exclusiveZone: 0
85 exclusionMode: ExclusionMode.Ignore
67 86
68 implicitWidth: 400 87 implicitWidth: 400
69 implicitHeight: 50 88 implicitHeight: 50
@@ -92,13 +111,20 @@ Scope {
92 implicitHeight: parent.height 111 implicitHeight: parent.height
93 112
94 icon: { 113 icon: {
95 if (!Pipewire.defaultAudioSink || Pipewire.defaultAudioSink.audio.muted) 114 if (root.show == "sink") {
96 return "volume-off"; 115 if (!Pipewire.defaultAudioSink || Pipewire.defaultAudioSink.audio.muted)
97 if (Pipewire.defaultAudioSink.audio.volume <= 0.33) 116 return "volume-off";
98 return "volume-low"; 117 if (Pipewire.defaultAudioSink.audio.volume <= 0.33)
99 if (Pipewire.defaultAudioSink.audio.volume <= 0.67) 118 return "volume-low";
100 return "volume-medium"; 119 if (Pipewire.defaultAudioSink.audio.volume <= 0.67)
101 return "volume-high"; 120 return "volume-medium";
121 return "volume-high";
122 } else if (root.show == "source") {
123 if (!Pipewire.defaultAudioSource || Pipewire.defaultAudioSource.audio.muted)
124 return "microphone-off";
125 return "microphone";
126 }
127 return "volume-high";
102 } 128 }
103 } 129 }
104 130
@@ -118,7 +144,13 @@ Scope {
118 144
119 color: Pipewire.defaultAudioSink?.audio.muted ? "#70ffffff" : "white" 145 color: Pipewire.defaultAudioSink?.audio.muted ? "#70ffffff" : "white"
120 146
121 implicitWidth: parent.width * (Pipewire.defaultAudioSink?.audio.volume ?? 0) 147 implicitWidth: {
148 if (root.show == "sink")
149 return parent.width * (Pipewire.defaultAudioSink?.audio.volume ?? 0);
150 else if (root.show == "source")
151 return parent.width * (Pipewire.defaultAudioSource?.audio.volume ?? 0);
152 return 0;
153 }
122 } 154 }
123 } 155 }
124 } 156 }