blob: 8efe3059b6564f1b0884f300b6c1d12741e4aed5 (
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
|
import QtQuick
import QtQuick.Layouts
import Quickshell
import Quickshell.Services.Pipewire
import Quickshell.Wayland
// Volume OSD that appears on volume change, styled to match the system menus.
Scope {
id: root
readonly property PwNode sink: Pipewire.defaultAudioSink
property bool visible: false
PwObjectTracker {
objects: root.sink ? [root.sink] : []
}
Connections {
target: root.sink && root.sink.audio ? root.sink.audio : null
ignoreUnknownSignals: true
function onVolumeChanged() {
root.visible = true
hideTimer.restart()
}
function onMutedChanged() {
root.visible = true
hideTimer.restart()
}
}
Timer {
id: hideTimer
interval: 2000
onTriggered: root.visible = false
}
PanelWindow {
visible: root.visible
// Compositor centers horizontally if only bottom anchor is set
anchors.bottom: true
margins.bottom: 100
exclusiveZone: 0
implicitWidth: 240
implicitHeight: 64
WlrLayershell.layer: WlrLayer.Overlay
exclusionMode: ExclusionMode.Ignore
color: Theme.transparent
mask: Region {} // Pass-through clicks
Squircle {
id: card
anchors.fill: parent
fillColor: Theme.bg
strokeColor: Theme.border
strokeWidth: 1
cornerRadius: 16
RowLayout {
anchors {
fill: parent
margins: 16
}
spacing: 12
IconCircle {
size: 32
source: {
if (root.sink?.audio?.muted) return "audio-volume-muted"
const vol = root.sink?.audio?.volume ?? 0
if (vol <= 0) return "audio-volume-low"
if (vol <= 0.33) return "audio-volume-low"
if (vol <= 0.66) return "audio-volume-medium"
return "audio-volume-high"
}
active: !(root.sink?.audio?.muted ?? true)
}
PillSlider {
Layout.fillWidth: true
value: root.sink?.audio?.volume ?? 0
enabled: false // OSD is for display only
}
}
}
}
}
|