From 0af39c52608c4631c3021dc53d665530ba0622f1 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Sat, 1 Aug 2026 15:32:15 -0500 Subject: [PATCH] Expose the battery percentage toggle through omarchy.power IPC omarchy-shell omarchy.power togglePercentage now flips the same setting the widget's right-click does. Follows the monitor/tailscale pattern: manageIpc: false so the panel owns the target's single IpcHandler and can extend it past the inherited lifecycle methods. Co-Authored-By: Claude Fable 5 --- shell/plugins/panels/power/Panel.qml | 14 ++++++++++++++ test/shell.d/power-test.sh | 2 ++ 2 files changed, 16 insertions(+) diff --git a/shell/plugins/panels/power/Panel.qml b/shell/plugins/panels/power/Panel.qml index e03c31f6..871ee2f6 100644 --- a/shell/plugins/panels/power/Panel.qml +++ b/shell/plugins/panels/power/Panel.qml @@ -10,6 +10,9 @@ Panel { id: root moduleName: "omarchy.power" ipcTarget: "omarchy.power" + // manageIpc: false so this panel can own the single IpcHandler the target + // permits — needed for the togglePercentage method below. + manageIpc: false property var batteryInfo: ({}) property var systemInfo: ({}) property var profiles: [] @@ -171,6 +174,17 @@ Panel { if (root.bar && root.bar.shell) root.bar.shell.updateEntryInline(root.moduleName, root.settings) } + IpcHandler { + target: "omarchy.power" + + function open() { root.open() } + function close() { root.close() } + function show() { root.open() } + function hide() { root.close() } + function toggle() { root.toggle() } + function togglePercentage() { root.togglePercentage() } + } + onOpenedChanged: { if (opened) { if (!batteryPresent) { diff --git a/test/shell.d/power-test.sh b/test/shell.d/power-test.sh index 4d24f88f..c367e782 100644 --- a/test/shell.d/power-test.sh +++ b/test/shell.d/power-test.sh @@ -46,4 +46,6 @@ assert(/if \(b === Qt\.RightButton\) root\.togglePercentage\(\)/.test(panelSourc assert(/Object\.assign\([^\n]+showPercentage: !root\.showPercentage[^\n]+\)[\s\S]*updateEntryInline/.test(panelSource), 'power persists the bar percentage setting') assert(/Math\.round\(root\.batteryFraction \* 100\) \+ "% " \+ root\.batteryIcon\(\)/.test(panelSource), 'power places the percentage before the battery icon') assert(/openPanelIndicatorWidth:.*showPercentage.*button\.glyphPaintedWidth : 0/.test(panelSource), 'power spans the open-panel mark across the painted percentage block') +assert(/IpcHandler[\s\S]*?function togglePercentage\(\) \{ root\.togglePercentage\(\) \}/.test(panelSource), 'power exposes togglePercentage over IPC') +assert(/manageIpc: false/.test(panelSource), 'power owns its IPC handler so it can extend the target methods') JS