import QtQuick import Quickshell import Quickshell.Wayland import Quickshell.Services.Pipewire import Quickshell.Io import "../Shared" PanelWindow { id: osdWindow // API function show(newMode) { mode = newMode; if (mode === "brightness") { brightnessProcess.restart(); } visibleTimer.restart(); } property string mode: "volume" // "volume" or "brightness" property real brightnessLevel: 0.5 // Pipewire Audio Binding property QtObject sink: Pipewire.defaultAudioSink // Ensure sink and audio are valid before trying to read volume property bool sinkReady: sink !== null && sink.ready && sink.audio !== null property real volumeLevel: sinkReady ? sink.audio.volume : 0.0 property bool isMuted: sinkReady ? sink.audio.muted : false PwObjectTracker { objects: sink !== null ? [sink] : [] } anchors { bottom: true left: true right: true } margins { bottom: visibleTimer.running ? Theme.geometry.padding * 4 : -implicitHeight - 50 } Behavior on margins.bottom { NumberAnimation { duration: Theme.animation.durationNormal easing.type: Easing.OutBack } } exclusiveZone: 0 color: "transparent" implicitHeight: 60 WlrLayershell.layer: WlrLayer.Overlay WlrLayershell.namespace: "quickshell-osd" Timer { id: visibleTimer interval: 2000 } Process { id: brightnessProcess // brightnessctl -m outputs: intel_backlight,backlight,12000,100%,12000 command: ["bash", "-c", "brightnessctl -m 2>/dev/null | awk -F, '{print $4}' | tr -d '%'"] running: false function restart() { running = false; running = true; } stdout: StdioCollector { onStreamFinished: { let val = parseInt(this.text); if (!isNaN(val)) { brightnessLevel = val / 100.0; } } } } Rectangle { width: 300 height: parent.implicitHeight anchors.centerIn: parent color: Theme.colors.background radius: Theme.geometry.pillRadius border.color: Theme.colors.border border.width: 1 Item { anchors.fill: parent anchors.margins: Theme.geometry.padding Text { id: iconText anchors.left: parent.left anchors.verticalCenter: parent.verticalCenter text: { if (mode === "volume") { if (isMuted) return "🔇"; if (volumeLevel < 0.33) return "🔈"; if (volumeLevel < 0.66) return "🔉"; return "🔊"; } else { return "☀️"; } } color: Theme.colors.text font.pixelSize: 18 } Rectangle { anchors.left: iconText.right anchors.leftMargin: Theme.geometry.spacing anchors.right: parent.right anchors.verticalCenter: parent.verticalCenter height: 8 color: Theme.colors.surfaceHover radius: 4 clip: true Rectangle { width: parent.width * (mode === "volume" ? volumeLevel : brightnessLevel) height: parent.height color: (mode === "volume" && isMuted) ? Theme.colors.textMuted : Theme.colors.primary radius: 4 Behavior on width { NumberAnimation { duration: Theme.animation.durationFast } } } } } } }