feat: update osd for volume
This commit is contained in:
1 parent
cfe81c15f5
commit
8aa254bb87
4 files changed
+153
-75
No files matched your search
@@ -197,13 +197,13 @@ hl.bind(mainMod .. " + W", hl.dsp.exec_cmd("qs ipc call wallpaperSwitcher open")
|
||||
hl.bind(mainMod .. " + SHIFT + W", hl.dsp.exec_cmd("qs ipc call wallpaperSwitcher random"))
|
||||
|
||||
-- Brightness
|
||||
hl.bind("XF86MonBrightnessUp", hl.dsp.exec_cmd("brightnessctl set 10%-"), { locked = true })
|
||||
hl.bind("XF86MonBrightnessDown", hl.dsp.exec_cmd("brightnessctl set 10%-"), { locked = true })
|
||||
hl.bind("XF86MonBrightnessUp", hl.dsp.exec_cmd("brightnessctl set 10%+ && quickshell ipc call osd showBrightness"), { locked = true })
|
||||
hl.bind("XF86MonBrightnessDown", hl.dsp.exec_cmd("brightnessctl set 10%- && quickshell ipc call osd showBrightness"), { locked = true })
|
||||
|
||||
-- Media
|
||||
hl.bind("XF86AudioRaiseVolume", hl.dsp.exec_cmd("wpctl set-volume -l 1 @DEFAULT_AUDIO_SINK@ 5%+ && quickshell ipc call commandPalette openOsd"), { locked = true })
|
||||
hl.bind("XF86AudioLowerVolume", hl.dsp.exec_cmd("wpctl set-volume -l 1 @DEFAULT_AUDIO_SINK@ 5%- && quickshell ipc call commandPalette openOsd"), { locked = true })
|
||||
hl.bind("XF86AudioMute", hl.dsp.exec_cmd("wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle"), { locked = true })
|
||||
hl.bind("XF86AudioRaiseVolume", hl.dsp.exec_cmd("wpctl set-volume -l 1 @DEFAULT_AUDIO_SINK@ 5%+ && quickshell ipc call osd showVolume"), { locked = true })
|
||||
hl.bind("XF86AudioLowerVolume", hl.dsp.exec_cmd("wpctl set-volume -l 1 @DEFAULT_AUDIO_SINK@ 5%- && quickshell ipc call osd showVolume"), { locked = true })
|
||||
hl.bind("XF86AudioMute", hl.dsp.exec_cmd("wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle && quickshell ipc call osd showVolume"), { locked = true })
|
||||
hl.bind("XF86AudioMicMute", hl.dsp.exec_cmd("wpctl set-mute @DEFAULT_AUDIO_SOURCE@ toggle"), { locked = true })
|
||||
hl.bind("XF86AudioPlay", hl.dsp.exec_cmd("playerctl play-pause"), { locked = true })
|
||||
hl.bind("XF86AudioPause", hl.dsp.exec_cmd("playerctl play-pause"), { locked = true })
|
||||
|
||||
@@ -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 }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,7 @@ import Quickshell.Io
|
||||
|
||||
import "components/Bar"
|
||||
import "components/CommandPalette"
|
||||
import "components/OSD"
|
||||
import "components/Shared"
|
||||
|
||||
ShellRoot {
|
||||
@@ -11,45 +12,24 @@ ShellRoot {
|
||||
|
||||
// --- Global State ---
|
||||
property bool commandPaletteOpen: false
|
||||
property bool commandPaletteOsdMode: false
|
||||
|
||||
IpcHandler {
|
||||
target: "commandPalette"
|
||||
function toggle() {
|
||||
root.toggleCommandPalette();
|
||||
}
|
||||
function openOsd() {
|
||||
root.showOsd();
|
||||
commandPaletteOpen = !commandPaletteOpen;
|
||||
}
|
||||
}
|
||||
|
||||
function toggleCommandPalette() {
|
||||
if (commandPaletteOpen && !commandPaletteOsdMode) {
|
||||
commandPaletteOpen = false;
|
||||
} else {
|
||||
commandPaletteOsdMode = false;
|
||||
commandPaletteOpen = true;
|
||||
IpcHandler {
|
||||
target: "osd"
|
||||
function showVolume() {
|
||||
osd.show("volume");
|
||||
}
|
||||
function showBrightness() {
|
||||
osd.show("brightness");
|
||||
}
|
||||
}
|
||||
|
||||
function showOsd() {
|
||||
commandPaletteOsdMode = true;
|
||||
commandPaletteOpen = true;
|
||||
osdHideTimer.restart();
|
||||
}
|
||||
|
||||
Timer {
|
||||
id: osdHideTimer
|
||||
interval: 2000
|
||||
onTriggered: {
|
||||
if (root.commandPaletteOsdMode) {
|
||||
root.commandPaletteOpen = false;
|
||||
root.commandPaletteOsdMode = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
// --------------------
|
||||
|
||||
Bar {
|
||||
id: bar
|
||||
rootState: root
|
||||
@@ -59,4 +39,8 @@ ShellRoot {
|
||||
id: commandPalette
|
||||
rootState: root
|
||||
}
|
||||
|
||||
OSD {
|
||||
id: osd
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user