diff options
Diffstat (limited to 'accounts/gkleen@sif/shell/quickshell/VolumeOSD.qml')
-rw-r--r-- | accounts/gkleen@sif/shell/quickshell/VolumeOSD.qml | 129 |
1 files changed, 129 insertions, 0 deletions
diff --git a/accounts/gkleen@sif/shell/quickshell/VolumeOSD.qml b/accounts/gkleen@sif/shell/quickshell/VolumeOSD.qml new file mode 100644 index 00000000..3a78d91b --- /dev/null +++ b/accounts/gkleen@sif/shell/quickshell/VolumeOSD.qml | |||
@@ -0,0 +1,129 @@ | |||
1 | import QtQuick | ||
2 | import QtQuick.Layouts | ||
3 | import Quickshell | ||
4 | import Quickshell.Services.Pipewire | ||
5 | import Quickshell.Widgets | ||
6 | |||
7 | Scope { | ||
8 | id: root | ||
9 | |||
10 | property bool show: false | ||
11 | property bool inhibited: true | ||
12 | |||
13 | PwObjectTracker { | ||
14 | objects: [ Pipewire.defaultAudioSink ] | ||
15 | } | ||
16 | |||
17 | Connections { | ||
18 | target: Pipewire.defaultAudioSink?.audio | ||
19 | |||
20 | function onVolumeChanged() { | ||
21 | root.show = true; | ||
22 | hideTimer.reset(); | ||
23 | } | ||
24 | function onMutedChanged() { | ||
25 | root.show = true; | ||
26 | hideTimer.reset(); | ||
27 | } | ||
28 | } | ||
29 | |||
30 | onShowChanged: { | ||
31 | if (show) | ||
32 | hideTimer.restart(); | ||
33 | } | ||
34 | |||
35 | Timer { | ||
36 | id: hideTimer | ||
37 | interval: 2000 | ||
38 | onTriggered: root.show = false | ||
39 | } | ||
40 | |||
41 | Timer { | ||
42 | id: startInhibit | ||
43 | interval: 100 | ||
44 | running: true | ||
45 | onTriggered: root.inhibited = false; | ||
46 | } | ||
47 | |||
48 | LazyLoader { | ||
49 | active: root.show && !root.inhibited | ||
50 | |||
51 | Variants { | ||
52 | model: Quickshell.screens | ||
53 | |||
54 | delegate: Scope { | ||
55 | id: screenScope | ||
56 | |||
57 | required property var modelData | ||
58 | |||
59 | PanelWindow { | ||
60 | id: window | ||
61 | |||
62 | screen: screenScope.modelData | ||
63 | |||
64 | anchors.top: true | ||
65 | margins.top: (screen.height - window.height) / 2 | ||
66 | exclusiveZone: 0 | ||
67 | |||
68 | implicitWidth: 400 | ||
69 | implicitHeight: 50 | ||
70 | |||
71 | mask: Region {} | ||
72 | |||
73 | color: "transparent" | ||
74 | |||
75 | Rectangle { | ||
76 | anchors.fill: parent | ||
77 | color: Qt.rgba(0, 0, 0, 0.75) | ||
78 | } | ||
79 | |||
80 | RowLayout { | ||
81 | id: layout | ||
82 | |||
83 | anchors.centerIn: parent | ||
84 | |||
85 | height: 50 - 8*2 | ||
86 | width: 400 - 8*2 | ||
87 | |||
88 | MaterialDesignIcon { | ||
89 | id: volumeIcon | ||
90 | |||
91 | implicitWidth: parent.height | ||
92 | implicitHeight: parent.height | ||
93 | |||
94 | icon: { | ||
95 | if (!Pipewire.defaultAudioSink || Pipewire.defaultAudioSink.audio.muted) | ||
96 | return "volume-off"; | ||
97 | if (Pipewire.defaultAudioSink.audio.volume <= 0.33) | ||
98 | return "volume-low"; | ||
99 | if (Pipewire.defaultAudioSink.audio.volume <= 0.67) | ||
100 | return "volume-medium"; | ||
101 | return "volume-high"; | ||
102 | } | ||
103 | } | ||
104 | |||
105 | Rectangle { | ||
106 | Layout.fillWidth: true | ||
107 | |||
108 | implicitHeight: 10 | ||
109 | |||
110 | color: "#50ffffff" | ||
111 | |||
112 | Rectangle { | ||
113 | anchors { | ||
114 | left: parent.left | ||
115 | top: parent.top | ||
116 | bottom: parent.bottom | ||
117 | } | ||
118 | |||
119 | color: Pipewire.defaultAudioSink?.audio.muted ? "#70ffffff" : "white" | ||
120 | |||
121 | implicitWidth: parent.width * (Pipewire.defaultAudioSink?.audio.volume ?? 0) | ||
122 | } | ||
123 | } | ||
124 | } | ||
125 | } | ||
126 | } | ||
127 | } | ||
128 | } | ||
129 | } | ||