me like nix
1pragma Singleton
2
3import QtQuick
4import Quickshell
5import Quickshell.Io
6
7QtObject {
8 readonly property int volume: _volume
9 readonly property bool muted: _muted
10
11 property int _volume: 0
12 property bool _muted: false
13
14 property var _proc: Process {
15 command: ["sh", "-c", "wpctl get-volume @DEFAULT_AUDIO_SINK@"]
16 stdout: SplitParser {
17 onRead: data => {
18 if (!data) return
19 _muted = data.indexOf("[MUTED]") !== -1
20 var match = data.match(/Volume:\s+([\d.]+)/)
21 if (match) _volume = Math.round(parseFloat(match[1]) * 100)
22 }
23 }
24 Component.onCompleted: running = true
25 }
26
27 property var _timer: Timer {
28 interval: 2000
29 running: true
30 repeat: true
31 onTriggered: _proc.running = true
32 }
33}