Skip to content

About

Idle power saving for Omarchy in four stages: screensaver, monitor standby, lock and suspend, each with its own switch and timeout.

Resources

Stars

3 stars

Watchers

0 watching

Forks

Repository files navigation

Omarchy Power Saving

Idle power saving for Omarchy in five stages:

Group Stage What it does
Display Screensaver Starts the Omarchy terminal screensaver
Display Standby Turns the monitors off (DPMS)
System Lock Locks the session
System Suspend Suspends the machine
Hibernation Hibernate Hibernates the machine

Each stage has its own switch and its own idle timeout. Both are set from a panel in the bar.

The stock Omarchy idle service only has screensaver and lock. It cannot switch either of them off, it never turns the monitors off and it never suspends. This plugin replaces it.

Preview

Power Saving panel: the idle schedule above the display and system stages

Install

omarchy plugin add https://github.com/selfcrypto/omarchy-power-saving.git --enable

The plugin is declared as a clone of the stock omarchy.idle service, so Omarchy switches the stock service off when this plugin is enabled and back on when it is removed. Running both would lock and start the screensaver twice.

The idle.screensaver and idle.lock values you already have in shell.json are used as the starting timeouts.

If you enable omarchy.idle again by hand, Omarchy takes this plugin out of the bar, as it does with any other clone.

Check that it is running:

omarchy plugin list
omarchy-shell idle status

Update:

omarchy plugin update io.github.selfcrypto.power-saving
omarchy restart shell

Remove:

omarchy plugin remove io.github.selfcrypto.power-saving

The stock service comes back by itself. If the plugin was installed before 1.3.0, also run omarchy plugin enable omarchy.idle.

Who it is for

  • Desktop PCs. A desktop has no lid, and stock Omarchy has no idle standby and no idle suspend, so the monitors stay on and the machine never suspends.
  • Laptops left open. Closing the lid suspends (logind does that, this plugin is not involved), but an open laptop never turns its screen off or suspends on idle in stock Omarchy.
  • Anyone who wants to switch single stages off, for example screensaver without lock at home.

There is one set of timeouts. Separate timeouts for battery and mains are not supported yet.

Usage

Bar icon:

  • Left click opens the panel.
  • Right click toggles stay awake, which pauses all the stages. It is the same flag as omarchy toggle idle and the coffee cup indicator.

Panel:

  • The schedule at the top shows the stages in the order they fire, by timeout, and the line above it says what fires next ("Next: Screensaver after 2 min idle") or why nothing will (paused, all off). A stage that is on is a filled dot, one that is off is a ring with its time struck through. Stages that are on and the line between them use the theme accent. Clicking a dot switches that stage on or off.
  • Each stage row has a minutes stepper and a switch. Click the stepper and type the minutes; Enter applies them, the −/+ buttons and Up/Down step. Hovering a stepper shows its allowed range and, when another stage limits it, which one.
  • Clicking the icon or the name of a stage runs that stage immediately. The key beside the name does the same.
  • The switch at the top toggles stay awake.

Order within a group:

  • While both are on, the screensaver cannot come after standby, and lock cannot come after suspend or hibernate. Equal times are allowed. Lock and standby are in different groups and can be in either order.
  • The steppers stop at the other stage's time.
  • Switching a stage on moves its time to the nearest one that keeps the order, and the panel says so ("Standby moved to 5 min").

Keys in the panel:

Key Action
t Toggle stay awake
1 to 5 Switch a stage on or off
r Screensaver now
o Standby now
k Lock now
s Suspend now
h Hibernate now

Keys in a minutes stepper, once it has been clicked:

Key Action
0 to 9 Type the minutes (1 to 1440)
Backspace Delete the last digit typed
Enter Apply what was typed
Escape Drop what was typed; with nothing typed, close the panel
Up, Down Step by one minute

Letters still act as panel keys while the field has focus.

Running a stage by hand works even when its switch is off.

Behaviour

Screensaver:

  • A mouse move or a key press ends it. The stock screensaver only reacts to keys. Movement in the first 1.5 seconds after it appears is ignored, so a hand still on the mouse does not end it at once. After that any movement ends it immediately, including movement that never stopped.
  • Ending the screensaver counts as activity, so a pending lock is cancelled and the idle count starts again.
  • The switch is Omarchy's own screensaver-off toggle, so the Omarchy menu and the panel always show the same state.
  • It is not started while the monitors are off.

Standby:

  • The monitors are turned off through Hyprland's DPMS dispatcher. The lock screen "blank" in stock Omarchy only lowers the brightness of one monitor.
  • A key press or a mouse move turns them back on.
  • A running screensaver is closed first. This does not count as activity, so the lock still fires on time.
  • Idle inhibitors are respected. A playing video keeps the monitors on.

Lock:

  • Uses omarchy-system-lock, the same as the stock service.

Suspend:

  • Locks the session first, so the machine wakes to the lock screen.
  • Turns the monitors back on before suspending, so a resume does not show a black screen.
  • Goes through logind and needs no privileges.
  • Idle inhibitors are respected.

Hibernate:

  • Shown only when logind can hibernate, which needs hibernation set up (on Omarchy: omarchy-hibernation-setup).
  • Locks the session first and turns the monitors back on, as suspend does.
  • Goes through logind's Hibernate call and needs no privileges.
  • Idle inhibitors are respected.
  • Suspend and hibernate cannot both be on: switching one on switches the other off, and the panel says so. Both keep their times. If both are on in shell.json, hibernate wins.
  • Lock comes no later than hibernate while both are on, as with suspend.

Then hibernate:

  • A switch under the suspend row. Suspend goes through logind's SuspendThenHibernate: the machine suspends, then wakes and hibernates when systemd decides. Useful on a laptop left on battery.

  • When it hibernates is set by systemd, not by the plugin. The row, marked ↳ under suspend, shows the value in a greyed box: "2 h" (the default without a battery), "45 min", "Low battery" or "45 min / battery" on a laptop. Hovering the box says where it comes from and how to change it. It is the time after suspending, not after going idle, and not a guaranteed deadline. Without a battery: after HibernateDelaySec=, 2 h when unset. With a battery: at low battery, or after HibernateDelaySec= if that comes first (HibernateOnACPower=no runs the delay only on battery). The schedule marks the suspend stop "then hibernate".

  • To change the delay, create /etc/systemd/sleep.conf.d/hibernate-delay.conf as root with:

    [Sleep]
    HibernateDelaySec=45min

    It applies from the next suspend. The panel reads it when it opens.

  • Shown where logind can do it, dimmed while suspend is off. Switching it on switches suspend on too; switching suspend off switches it off. If it has gone by the time the machine suspends, it just suspends. Applies to "suspend now" too.

All timeouts count from the moment you went idle. Starting the screensaver or locking does not push the later stages back. A switch or time changed while you are away keeps that count, so a stage turned on after its time has passed fires at once.

Troubleshooting

  • Nothing happens when idle. An app holding an idle inhibitor (a video player, a call) keeps standby, suspend and hibernate from firing. The panel cannot tell which app; systemd-inhibit --list and the app's own settings can.
  • No Hibernation section. logind does not offer hibernation on this system: no swap big enough, no resume= on the kernel command line, or Secure Boot lockdown. On Omarchy, omarchy-hibernation-setup sets it up.
  • A minutes field stops taking digits. The time would break the order within a group (lock no later than suspend or hibernate, screensaver no later than standby). Hover the field for the allowed range.
  • Suspend switched itself off. Hibernate was switched on; only one of the two can be on.

Configuration

The settings are stored on this plugin's entry in the bar layout of ~/.config/omarchy/shell.json. The panel writes them, and so does omarchy bar set:

omarchy bar set io.github.selfcrypto.power-saving suspend 1800
omarchy bar set io.github.selfcrypto.power-saving suspendEnabled true
{
  "id": "io.github.selfcrypto.power-saving",
  "screensaver": 300,
  "standby": 600,
  "lock": 1200,
  "suspend": 1800,
  "hibernate": 3600,
  "lockEnabled": false,
  "standbyEnabled": true,
  "suspendEnabled": true,
  "hibernateEnabled": false,
  "suspendThenHibernate": false
}
Key Meaning Default
screensaver Seconds of idle before the screensaver starts 150
standby Seconds of idle before the monitors turn off 600
lock Seconds of idle before the session locks 300
suspend Seconds of idle before the machine suspends 1800
hibernate Seconds of idle before the machine hibernates 3600
standbyEnabled Standby stage on or off false
lockEnabled Lock stage on or off true
suspendEnabled Suspend stage on or off false
hibernateEnabled Hibernate stage on or off false
suspendThenHibernate Suspend, then hibernate false

Timeouts go from 10 seconds to 24 hours (86400 seconds). The panel and the IPC timeout call keep the order within a group described above; values written to shell.json by hand are used as they are, except that anything above 24 hours counts as 24 hours.

A key that is missing from the entry is read from the stock idle block of shell.json. The first edit from the panel copies all keys onto the entry. The idle block is only read, never written, because since Omarchy 4.0.3 a third-party plugin can only write its own bar entry.

The screensaver switch is not in shell.json. It is the flag file ~/.local/state/omarchy/toggles/screensaver-off, which omarchy toggle screensaver also writes.

IPC

The IPC target is idle, the same as the stock service, so existing calls keep working.

omarchy-shell idle status                       # JSON: stages, monitors, last event
omarchy-shell idle stage standby on             # on | off | toggle | status
omarchy-shell idle timeout standby 900          # set, in seconds
omarchy-shell idle timeout standby ""           # print the current value
omarchy-shell idle screensaver                  # screensaver now
omarchy-shell idle standby                      # monitors off now
omarchy-shell idle wake                         # monitors on now
omarchy-shell idle suspend                      # suspend now
omarchy-shell idle hibernate                    # hibernate now
omarchy-shell idle suspendThenHibernate on      # on | off | toggle | status
omarchy-shell idle enable | disable | toggle    # stay awake, as in the stock service

Stage names for stage and timeout are screensaver, standby, lock, suspend and hibernate.

Requirements

  • Omarchy 4.0.3 or later.
  • Hyprland 0.56 or later for the standby stage.
  • No extra packages, no external services and no privileges beyond the user session.

Technical notes

  • Idle monitors are created and destroyed, never reconfigured. Quickshell 0.3.1 breaks an IdleMonitor whose timeout changes at runtime.
  • Screensaver and lock share one idle monitor, as in the stock service. Standby and suspend have one each.
  • The idle monitors only tell the service when you went idle. From then on the stages run on timers counted from that moment. Hyprland resets every idle monitor when the screensaver opens or closes and when the lock screen comes up, so monitors alone would delay the later stages.
  • Activity reported while the service starts or closes the screensaver, locks or turns the monitors off, and for 1.5 seconds after, is taken to be that action and is ignored.
  • Every command the service runs has a time limit: 30 seconds for the screensaver launch, 20 for the lock, 10 for each monitor step, 120 for suspend and hibernate. A command still running then is killed with everything it started, so a hung one cannot keep your input ignored.
  • Your return is detected by its own idle monitor with a 0.1 second timeout that ignores idle inhibitors. It is armed while you are away and while a screensaver is up. This is also what ends the screensaver on a mouse move.
  • That monitor only reports the step from idle to active. For input that never paused, the service looks at it when the 1.5 seconds are over: if it is not idle then, there is input at that moment.
  • A stage that is already overdue when it is switched on (or its time shortened) during those 1.5 seconds waits for that check: it fires right after if you are still away, and not at all if you are back.
  • Standby calls hyprctl eval 'hl.dispatch(hl.dsp.dpms({action = "off"}))'. The older hyprctl dispatch dpms off no longer parses on Hyprland 0.56. The action has to be passed as {action = "off"}. With hl.dsp.dpms("off") the argument is ignored and the dispatch toggles.
  • hyprctl monitors reports dpmsStatus one dispatch late. The service reads /sys/class/drm/*/dpms instead.
  • The screensaver is kept off dark monitors because a DisplayPort monitor in DPMS off can drop its link. Hyprland then removes the monitor, and a screensaver window that survives this comes back drawn over the whole monitor while clicks go through to the desktop.
  • The screensaver is closed before the DPMS off. Its exit restores the cursor through a Hyprland config keyword, and that makes Hyprland turn the monitors back on.
  • Monitor off and on requests run one at a time, and the last one asked for wins. A wake that comes while the screensaver is still closing cancels the off.
  • Omarchy's omarchy-sleep-lock.service also locks on suspend, whatever the lock stage is set to.
  • The stock coffee cup indicator in omarchy.indicators follows this plugin, because Omarchy resolves the stock id to the enabled clone.
  • The service reads shell.json itself and does not use the barConfig snapshot the host passes to plugins. In 4.0.3 that snapshot is refreshed one config event late.

Working on the code

Start with CLAUDE.md: the map of the code, the current state and the release steps.

License

MIT. See LICENSE.

About

Idle power saving for Omarchy in four stages: screensaver, monitor standby, lock and suspend, each with its own switch and timeout.

Resources

Stars

3 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages