diff options
| author | 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> | 2025-05-13 17:43:04 +1000 |
|---|---|---|
| committer | 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> | 2025-05-13 17:43:04 +1000 |
| commit | 9c3e2fffbd31c3864ef7edc6212c1c601357f031 (patch) | |
| tree | 78f45af391db6b7096da61342beceb3904e7819e | |
| parent | osd: show on hover (diff) | |
| download | caelestia-shell-9c3e2fffbd31c3864ef7edc6212c1c601357f031.tar.gz caelestia-shell-9c3e2fffbd31c3864ef7edc6212c1c601357f031.tar.bz2 caelestia-shell-9c3e2fffbd31c3864ef7edc6212c1c601357f031.zip | |
osd: fix show on hover + show on audio/brightness change
| -rw-r--r-- | modules/drawers/Drawers.qml | 1 | ||||
| -rw-r--r-- | modules/drawers/Interactions.qml | 32 | ||||
| -rw-r--r-- | modules/osd/Interactions.qml | 48 | ||||
| -rw-r--r-- | services/Brightness.qml | 1 | ||||
| -rw-r--r-- | services/Hyprland.qml | 14 |
5 files changed, 91 insertions, 5 deletions
diff --git a/modules/drawers/Drawers.qml b/modules/drawers/Drawers.qml index 937409a..35129ce 100644 --- a/modules/drawers/Drawers.qml +++ b/modules/drawers/Drawers.qml @@ -80,6 +80,7 @@ Variants { } Interactions { + screen: scope.modelData visibilities: visibilities Panels { diff --git a/modules/drawers/Interactions.qml b/modules/drawers/Interactions.qml index aab23aa..bd76944 100644 --- a/modules/drawers/Interactions.qml +++ b/modules/drawers/Interactions.qml @@ -1,22 +1,44 @@ import "root:/services" import "root:/config" +import "root:/modules/osd" as Osd import Quickshell import QtQuick MouseArea { + id: root + + required property ShellScreen screen required property PersistentProperties visibilities + property bool osdHovered property point dragStart + function inOsd(x: real, y: real): bool { + const osd = panels.osd; + return x > width - BorderConfig.thickness - osd.width && y >= osd.y && y <= osd.y + osd.height; + } + anchors.fill: parent hoverEnabled: true onPressed: event => dragStart = Qt.point(event.x, event.y) - onExited: visibilities.osd = false - onPositionChanged: ({x, y}) => { - // Show osd on hover - const osd = panels.osd; - visibilities.osd = (x > width - BorderConfig.thickness - osd.width && y >= osd.y && y <= osd.y + osd.height); + Connections { + target: Hyprland + + function onCursorPosChanged(): void { + const {x, y} = Hyprland.cursorPos; + + // Show osd on hover + const showOsd = root.inOsd(x, y); + root.visibilities.osd = showOsd; + root.osdHovered = showOsd; + } + } + + Osd.Interactions { + screen: root.screen + visibilities: root.visibilities + hovered: root.osdHovered } } diff --git a/modules/osd/Interactions.qml b/modules/osd/Interactions.qml new file mode 100644 index 0000000..eecf0b6 --- /dev/null +++ b/modules/osd/Interactions.qml @@ -0,0 +1,48 @@ +import "root:/services" +import "root:/config" +import Quickshell +import QtQuick + +Scope { + id: root + + required property ShellScreen screen + required property PersistentProperties visibilities + required property bool hovered + readonly property Brightness.Monitor monitor: Brightness.getMonitorForScreen(screen) + + function show(): void { + root.visibilities.osd = true; + timer.restart(); + } + + Connections { + target: Audio + + function onMutedChanged(): void { + root.show(); + } + + function onVolumeChanged(): void { + root.show(); + } + } + + Connections { + target: root.monitor + + function onBrightnessChanged(): void { + root.show(); + } + } + + Timer { + id: timer + + interval: OsdConfig.hideDelay + onTriggered: { + if (!root.hovered) + root.visibilities.osd = false; + } + } +} diff --git a/services/Brightness.qml b/services/Brightness.qml index ef90511..2de51a0 100644 --- a/services/Brightness.qml +++ b/services/Brightness.qml @@ -95,6 +95,7 @@ Singleton { if (Math.round(brightness * 100) === rounded) return; brightness = value; + console.log(brightness) setProc.command = isDdc ? ["ddcutil", "-b", busNum, "setvcp", "10", rounded] : ["brightnessctl", "s", `${rounded}%`]; setProc.startDetached(); } diff --git a/services/Hyprland.qml b/services/Hyprland.qml index a1f5cbb..515441e 100644 --- a/services/Hyprland.qml +++ b/services/Hyprland.qml @@ -15,6 +15,7 @@ Singleton { readonly property HyprlandWorkspace activeWorkspace: focusedMonitor?.activeWorkspace ?? null readonly property HyprlandMonitor focusedMonitor: Hyprland.focusedMonitor readonly property int activeWsId: activeWorkspace?.id ?? 1 + property point cursorPos function reload() { Hyprland.refreshWorkspaces(); @@ -38,6 +39,19 @@ Singleton { } } + FrameAnimation { + running: true + onTriggered: getCursorPos.running = true + } + + Process { + id: getCursorPos + command: ["hyprctl", "cursorpos"] + stdout: SplitParser { + onRead: data => root.cursorPos = data + } + } + Process { id: getClients command: ["sh", "-c", "hyprctl -j clients | jq -c"] |