blob: 16fb5dea6e7d1f0b505e2f1d56df7f6eac3314c6 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
|
import QtQuick
import QtQuick.Layouts
import Quickshell
import Quickshell.Services.Pipewire
import Quickshell.Widgets
Scope {
id: root
property string show: ""
property bool inhibited: true
PwObjectTracker {
objects: [ Pipewire.defaultAudioSink, Pipewire.defaultAudioSource ]
}
Connections {
enabled: Pipewire.defaultAudioSink
target: Pipewire.defaultAudioSink?.audio
function onVolumeChanged() {
root.show = "sink";
hideTimer.restart();
}
function onMutedChanged() {
root.show = "sink";
hideTimer.restart();
}
}
Connections {
enabled: Pipewire.defaultAudioSource
target: Pipewire.defaultAudioSource?.audio
function onVolumeChanged() {
root.show = "source";
hideTimer.restart();
}
function onMutedChanged() {
root.show = "source";
hideTimer.restart();
}
}
onShowChanged: {
if (show)
hideTimer.restart();
}
Timer {
id: hideTimer
interval: 1000
onTriggered: root.show = ""
}
Timer {
id: startInhibit
interval: 100
running: true
onTriggered: {
root.show = "";
root.inhibited = false;
}
}
LazyLoader {
active: root.show && !root.inhibited
Variants {
model: Quickshell.screens
delegate: Scope {
id: screenScope
required property var modelData
PanelWindow {
id: window
screen: screenScope.modelData
anchors.top: true
margins.top: screen.height / 2 - 50 + 3.5
exclusiveZone: 0
exclusionMode: ExclusionMode.Ignore
implicitWidth: 400
implicitHeight: 50
mask: Region {}
color: "transparent"
Rectangle {
anchors.fill: parent
color: Qt.rgba(0, 0, 0, 0.75)
}
RowLayout {
id: layout
anchors.centerIn: parent
height: 50 - 8*2
width: 400 - 8*2
MaterialDesignIcon {
id: volumeIcon
implicitWidth: parent.height
implicitHeight: parent.height
icon: {
if (root.show == "sink") {
if (!Pipewire.defaultAudioSink || Pipewire.defaultAudioSink.audio.muted)
return "volume-off";
if (Pipewire.defaultAudioSink.audio.volume <= 0.33)
return "volume-low";
if (Pipewire.defaultAudioSink.audio.volume <= 0.67)
return "volume-medium";
return "volume-high";
} else if (root.show == "source") {
if (!Pipewire.defaultAudioSource || Pipewire.defaultAudioSource.audio.muted)
return "microphone-off";
return "microphone";
}
return "volume-high";
}
}
Rectangle {
Layout.fillWidth: true
implicitHeight: 10
color: "#50ffffff"
Rectangle {
anchors {
left: parent.left
top: parent.top
bottom: parent.bottom
}
color: Pipewire.defaultAudioSink?.audio.muted ? "#70ffffff" : "white"
implicitWidth: {
if (root.show == "sink")
return parent.width * (Pipewire.defaultAudioSink?.audio.volume ?? 0);
else if (root.show == "source")
return parent.width * (Pipewire.defaultAudioSource?.audio.volume ?? 0);
return 0;
}
}
}
}
}
}
}
}
}
|