Skip to content

About

Omarchy battery/power bar plugin: per-source profiles, battery protection, clamshell, keyboard backlight, live watts

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

PowerCore (gdeyoung.powercore)

A battery and power bar widget for Omarchy that replaces the stock omarchy.power widget: per-source power strategy, battery protection, clamshell lid control, per-source keyboard backlight, and live power draw in watts — one icon, one panel.

preview

The panel — hero, live draw, protection and clamshell toggles, one strategy section per power source:

panel

The bar widget — icon + 100% + live watts, far right; right-click bar widget — icon, percentage, live watts

Per power source (plugged in / on battery), independently:
  power profile    power-saver · balanced · performance (powerprofilesctl)
  screensaver      seconds, or never
  lock             seconds, or never
  sleep            seconds after the lock fired, or never
  keyboard backlight  off/low/… per source, re-applied on plug events

Plus, always:
  battery protection   UPower EnableChargeThreshold toggle (polkit, no root)
  clamshell            keep running with the lid closed on an external screen
  lid close behavior   Smart (sleep, then hibernate after a delay on battery),
                       sleep, hibernate, lock, nothing, or system default —
                       plus a log of what each closed lid cost in battery
  live power draw      watts on the bar, from the battery gauge (true
                       whole-system draw on battery) or the GPU sensor on AC
  suspend scheduling   through the user systemd manager — a Quickshell
                       restart between click and sleep cannot cancel it;
                       profile switches, battery protection and suspend
                       confirm with the Omarchy OSD
  bar-wide gauge       optional battery fill painted across the whole bar

Why

Four community plugins each do one slice of this well. PowerCore is the union, built for a laptop whose hardware has no ambient light sensor and a 4-step keyboard LED — so the keyboard backlight is per-power-source instead of ALS-driven, and power draw leads with the battery gauge because that is the only true whole-system measurement a laptop has.

Credits and sources, all MIT:

Install

omarchy plugin add https://github.com/gdeyoung/omarchy-powercore.git --enable
omarchy bar put gdeyoung.powercore --section right
omarchy bar remove omarchy.power   # optional: drop the stock widget

Root-free by default: everything above runs inside the shell process with user privileges — profiles via omarchy-powerprofiles-set, charge limit via UPower D-Bus (polkit allows the active session), keyboard backlight via brightnessctl (logind fallback), lid via a logind inhibitor held by a child process that dies with the shell.

The lid-close modes are the one exception, and only when you apply one: applying writes systemd drop-ins under /etc/systemd/logind.conf.d/ and /etc/systemd/sleep.conf.d/ plus a battery-drain logging hook under /usr/lib/systemd/system-sleep/. That needs root, so PowerCore opens a floating terminal and asks for the sudo password there — nothing runs as root silently. lidsleep.sh (shipped in the plugin dir) is the whole mechanism: json/status read state without root; set/delay/remove write the drop-ins via the elevated terminal; system mode deletes the drop-ins and restores platform defaults. Test hibernate runs systemctl hibernate — logind allows it for the active session, no password. The plugin runs nothing else as root and installs no daemon, unit, or udev rule.

Removal: omarchy plugin disable gdeyoung.powercore && omarchy plugin remove gdeyoung.powercore, then re-enable the stock widget with omarchy plugin enable omarchy.power. Before removing, set every "never" idle timing back to a real interval — the idle settings live in Omarchy's shell config and stay where the plugin left them.

Bar interactions

  • Left click — open the panel
  • Right click — cycle the extra label: nothing → percentage → watts → both
  • Middle click — cycle the keyboard backlight through its steps
  • Tooltip names the current power source

Panel

Hero (icon, status, percentage) → progress bar → battery stats and live draw (with an honest source label) → battery protection toggle → clamshell toggle → lid close behavior (applied-mode sentence, sleep-drain read-out, six exclusive modes, Smart's hibernate delay) → one section per power source: profile buttons, screensaver/lock/sleep dropdowns, keyboard backlight dropdown. Full keyboard navigation like the stock panel.

Lid close behavior

This laptop is s2idle-only — a closed lid light-sleeps and drains ~1% per hour. Smart mode does what Windows does: sleep for instant wake, then hibernate to disk after the delay (battery only; on AC it stays in light sleep). Changing the mode writes systemd drop-ins, which needs root — PowerCore opens a floating terminal for the password, applies, and re-reads the real state (lidsleep.sh json); the panel always shows the applied truth, and a pending badge while desired ≠ applied. Hibernation must be set up first (omarchy hibernation setup); the panel gates Smart and Hibernate until it is. A system-sleep hook logs battery % around every sleep, so the panel can show what a closed lid actually cost — average %/hour for light sleep vs hibernate.

The panel probes lidsleep.sh directly rather than going through a service facade: replacement bars (like ultrawide-bar) deliberately serve third-party widgets a service-less shell facade, so the lid section — and the settings write, via the bar entry API — is fully panel-autonomous and works under any bar.

Power draw, honestly

On battery the draw is the battery gauge's V×I — everything the machine draws flows through it, so it is the whole system, charger excluded. On AC the battery gauge reads ~0, so the widget falls back to the amdgpu package power sensor, which covers only the SoC: the bar shows the number and the panel says "GPU sensor (SoC only, on AC)". RAPL is root-gated on this machine (CVE-2020-8694) and deliberately not pried open for a widget.

Battery protection on ASUS

The firmware fixes the threshold window (75–80% here); UPower exposes only EnableChargeThreshold — there is no writable numeric threshold API — so the control is a toggle and the panel shows the window the firmware will apply. ThinkPad/Framework machines with sysfs charge_control_end_threshold get the same toggle through UPower's threshold mode.

Roadmap (research-grounded)

v0.1.0 was scoped against what the community actually asks for, not guesswork. Ranked ask inventory from Omarchy GitHub issues/discussions, r/omarchy, and the reference plugins' lineages (Sep 2026):

Covered by v0.1.0 — the top four asks, which no single plugin served together:

  1. Charge limit / protection toggle — the single most-recurring ask since Aug 2025 (#627, #4474, #10431); patcastle.power forked the stock widget just to add it.
  2. Per-source strategy — profile + idle timings split by AC/battery (#933, 17 votes; auto profile switching shipped in Omarchy v3.4.0; idle split still open).
  3. Lid/clamshell control — the second-biggest complaint cluster (#1556, #3871, 45 votes).
  4. Live watts on the bar — the efficiency-literate ask; Waybar's {power} precedent (#2963).

v2 candidates, in demand order (community evidence in parentheses):

  • Charge-guidance notifications — plug at 10/30%, unplug at 80% (r/omarchy hand-rolled dotfiles; Waybar states/events is the feature floor).
  • Battery health readout — capacity/wear %, cycle count (batctl got a 97-upvote r/omarchy thread; omarchy-power-manager headlines it).
  • Low-battery warning hardening — stock bug #8813 (critical toast never expires / replays after reboot) has 4 conflicting PRs; the first-party battery service coexists, so a hardened re-implementation is safe.
  • Time-remaining smoothing — EMA over the gauge instead of UPower's raw jump (chronic distro-wide complaint, no Omarchy tool serves it).
  • Usage history / cost trends — macOS-style day/week/month (Omabat, 36 upvotes; energy-meter already proves the RAPL+amdgpu path).
  • Per-source lid actions — powerplan's full matrix (suspend/ignore/lock/ shutdown per source) instead of the single clamshell toggle.
  • Dual battery — BAT0+BAT1 display (#7067, a waybar→Quickshell regression).
  • Not planned: dGPU gating, TLP/tuned shims, RTC suspend-drain floor — real asks but wrong scope for a shell plugin (need root helpers; see powerplan's signed-package approach for the cost of that road).

Known ecosystem gaps we share: thresholds live in EC firmware and can revert without boot/resume hooks (batctl ships udev+systemd persistence for this — UPower's own service survives reboots, which is why PowerCore routes through it rather than sysfs); and no rootless numeric-threshold path exists anywhere in the ecosystem yet (#10431 is the open design).

Development

node --test tests/        # pure-logic tests (Model.js has no Qt imports)

Deploy a local checkout: copy the repo to ~/.config/omarchy/plugins/gdeyoung.powercore/ and omarchy restart shell. Check the log: grep -a powercore $(ls -td /run/user/$UID/quickshell/by-id/* | head -1)/log.qslog.

License

MIT

About

Omarchy battery/power bar plugin: per-source profiles, battery protection, clamshell, keyboard backlight, live watts

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages