From 1ec031108643799d0c63d5ac2845a4e6bdfe32d8 Mon Sep 17 00:00:00 2001 From: purian23 Date: Sat, 9 May 2026 23:49:25 -0400 Subject: [PATCH] feat(IPC): Add dbar toggleReveal logic for autohide modes --- docs/IPC.md | 5 ++++ quickshell/Common/KeybindActions.js | 1 + quickshell/Common/SettingsData.qml | 31 ++++++++++++++++++++ quickshell/DMSShellIPC.qml | 20 +++++++++++++ quickshell/Modules/DankBar/DankBarWindow.qml | 8 +++-- 5 files changed, 62 insertions(+), 3 deletions(-) diff --git a/docs/IPC.md b/docs/IPC.md index 77e1e574..c1652d86 100644 --- a/docs/IPC.md +++ b/docs/IPC.md @@ -396,6 +396,10 @@ Top bar visibility control. - Toggle top bar visibility - Returns: Success confirmation with current state +**`toggleReveal`** +- Toggle the runtime reveal/tuck state for an autohidden bar +- Returns: Success confirmation with current reveal state + **`status`** - Get current top bar visibility status - Returns: "visible" or "hidden" @@ -403,6 +407,7 @@ Top bar visibility control. ### Examples ```bash dms ipc call bar toggle +dms ipc call bar toggleReveal index 0 dms ipc call bar hide dms ipc call bar status ``` diff --git a/quickshell/Common/KeybindActions.js b/quickshell/Common/KeybindActions.js index f996c8e1..6dc984d8 100644 --- a/quickshell/Common/KeybindActions.js +++ b/quickshell/Common/KeybindActions.js @@ -83,6 +83,7 @@ const DMS_ACTIONS = [ { id: "spawn dms ipc call bar toggle index 0", label: "Bar: Toggle (Primary)" }, { id: "spawn dms ipc call bar reveal index 0", label: "Bar: Reveal (Primary)" }, { id: "spawn dms ipc call bar hide index 0", label: "Bar: Hide (Primary)" }, + { id: "spawn dms ipc call bar toggleReveal index 0", label: "Bar: Toggle Autohide Reveal (Primary)" }, { id: "spawn dms ipc call bar toggleAutoHide index 0", label: "Bar: Toggle Auto-Hide (Primary)" }, { id: "spawn dms ipc call bar autoHide index 0", label: "Bar: Enable Auto-Hide (Primary)" }, { id: "spawn dms ipc call bar manualHide index 0", label: "Bar: Disable Auto-Hide (Primary)" }, diff --git a/quickshell/Common/SettingsData.qml b/quickshell/Common/SettingsData.qml index 271bc12d..bd389cbb 100644 --- a/quickshell/Common/SettingsData.qml +++ b/quickshell/Common/SettingsData.qml @@ -721,6 +721,7 @@ Singleton { property bool displayProfileAutoSelect: false property bool displayShowDisconnected: false property bool displaySnapToEdge: true + property var barIpcRevealStates: ({}) property var barConfigs: [ { @@ -2002,6 +2003,33 @@ Singleton { return barConfigs.find(cfg => cfg.id === barId) || null; } + function isBarIpcRevealed(barId) { + if (!barId) + return false; + return !!barIpcRevealStates[barId]; + } + + function setBarIpcReveal(barId, revealed) { + if (!barId) + return; + const nextRevealed = !!revealed; + if (!!barIpcRevealStates[barId] === nextRevealed) + return; + const states = Object.assign({}, barIpcRevealStates); + if (nextRevealed) { + states[barId] = true; + } else { + delete states[barId]; + } + barIpcRevealStates = states; + } + + function toggleBarIpcReveal(barId) { + const revealed = !isBarIpcRevealed(barId); + setBarIpcReveal(barId, revealed); + return revealed; + } + function addBarConfig(config) { const configs = JSON.parse(JSON.stringify(barConfigs)); configs.push(config); @@ -2017,6 +2045,8 @@ Singleton { if (index === -1) return; const positionChanged = updates.position !== undefined && configs[index].position !== updates.position; + if (updates.autoHide === false || updates.visible === false) + setBarIpcReveal(barId, false); Object.assign(configs[index], updates); barConfigs = _sanitizeBarConfigsForConnectedFrame(configs).configs; @@ -2078,6 +2108,7 @@ Singleton { delete nextBackups[barId]; connectedFrameBarStyleBackups = nextBackups; } + setBarIpcReveal(barId, false); updateBarConfigs(); } diff --git a/quickshell/DMSShellIPC.qml b/quickshell/DMSShellIPC.qml index de5e180f..101a4855 100644 --- a/quickshell/DMSShellIPC.qml +++ b/quickshell/DMSShellIPC.qml @@ -699,6 +699,26 @@ Item { return barConfig.autoHide ? "BAR_MANUAL_HIDE_SUCCESS" : "BAR_AUTO_HIDE_SUCCESS"; } + function toggleReveal(selector: string, value: string): string { + const { + barConfig, + error + } = getBarConfig(selector, value); + if (error) + return error; + if (!barConfig.autoHide) + return "BAR_AUTO_HIDE_DISABLED"; + if (!(barConfig.visible ?? true)) { + SettingsData.updateBarConfig(barConfig.id, { + visible: true + }); + SettingsData.setBarIpcReveal(barConfig.id, true); + return "BAR_REVEAL_SUCCESS"; + } + const revealed = SettingsData.toggleBarIpcReveal(barConfig.id); + return revealed ? "BAR_REVEAL_SUCCESS" : "BAR_TUCK_SUCCESS"; + } + function getPosition(selector: string, value: string): string { const { barConfig, diff --git a/quickshell/Modules/DankBar/DankBarWindow.qml b/quickshell/Modules/DankBar/DankBarWindow.qml index eabb56bb..8f5664a0 100644 --- a/quickshell/Modules/DankBar/DankBarWindow.qml +++ b/quickshell/Modules/DankBar/DankBarWindow.qml @@ -810,6 +810,7 @@ PanelWindow { property bool autoHide: barConfig?.autoHide ?? false property bool revealSticky: false + readonly property bool ipcReveal: !!SettingsData.barIpcRevealStates[barConfig?.id ?? ""] Timer { id: revealHold @@ -832,14 +833,14 @@ PanelWindow { const showOnWindowsSetting = barConfig?.showOnWindowsOpen ?? false; if (showOnWindowsSetting && autoHide && (CompositorService.isNiri || CompositorService.isHyprland)) { if (barWindow.shouldHideForWindows) - return topBarMouseArea.containsMouse || revealSticky; + return topBarMouseArea.containsMouse || revealSticky || ipcReveal; return true; } if (CompositorService.isNiri && NiriService.inOverview) - return topBarMouseArea.containsMouse || revealSticky; + return topBarMouseArea.containsMouse || revealSticky || ipcReveal; - return (barConfig?.visible ?? true) && (!autoHide || topBarMouseArea.containsMouse || revealSticky); + return (barConfig?.visible ?? true) && (!autoHide || topBarMouseArea.containsMouse || revealSticky || ipcReveal); } Connections { @@ -855,6 +856,7 @@ PanelWindow { return; if (topBarMouseArea.containsMouse) { + SettingsData.setBarIpcReveal(barConfig?.id ?? "", false); revealSticky = true; revealHold.stop(); return;