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 <noreply@anthropic.com>
This commit is contained in:
David Heinemeier Hansson
2026-08-01 15:36:34 -05:00
co-authored by Claude Fable 5
parent 7020a6ea57
commit 0af39c5260
2 changed files with 16 additions and 0 deletions
+14
View File
@@ -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) {
+2
View File
@@ -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