feat: update osd for volume

This commit is contained in:
johannes committed 2026-09-21 16:15:00 +02:00
1 parent cfe81c15f5
commit 8aa254bb87
4 files changed
+153 -75

No files matched your search

@@ -39,7 +39,7 @@ PanelWindow {
id: container
// Sized appropriately for a 2560x1440 screen
width: 800
height: rootState.commandPaletteOsdMode ? 100 : Math.min(600, (appList.count > 0 ? appList.contentHeight : 0) + 50 + Theme.geometry.padding * 2 + Theme.geometry.spacing)
height: Math.min(600, (appList.count > 0 ? appList.contentHeight : 0) + 50 + Theme.geometry.padding * 2 + Theme.geometry.spacing)
anchors.centerIn: parent
radius: Theme.geometry.radius
color: Theme.colors.background
@@ -56,12 +56,11 @@ PanelWindow {
anchors.fill: parent
}
// --- App Launcher Mode ---
// --- App Launcher ---
Column {
anchors.fill: parent
anchors.margins: Theme.geometry.padding
spacing: Theme.geometry.spacing
visible: !rootState.commandPaletteOsdMode
Rectangle {
width: parent.width
@@ -98,7 +97,6 @@ PanelWindow {
Keys.onEscapePressed: {
rootState.commandPaletteOpen = false;
rootState.commandPaletteOsdMode = false;
}
Keys.onUpPressed: {
@@ -317,43 +315,6 @@ PanelWindow {
running = true;
}
}
// --- OSD Mode ---
Item {
anchors.fill: parent
visible: rootState.commandPaletteOsdMode
// Mock OSD visual
Row {
anchors.centerIn: parent
spacing: Theme.geometry.spacing * 2
Text {
text: "Volume"
color: Theme.colors.text
font.family: Theme.font.family
font.pixelSize: 24
anchors.verticalCenter: parent.verticalCenter
}
Rectangle {
width: 400
height: 12
color: Theme.colors.surfaceHover
radius: 6
anchors.verticalCenter: parent.verticalCenter
clip: true
Rectangle {
// Mock width based on a dummy volume
width: parent.width * 0.7
height: parent.height
color: Theme.colors.primary
radius: 6
}
}
}
}
}
onVisibleChanged: {
@@ -0,0 +1,133 @@
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 }
}
}
}
}
}
}