OPINIONATED OMARCHY
TROUBLESHOOTING CORPUS
790
RECORDS
790
AUDITED
0
UNCHECKED
2388
SOURCES
LIVE
power-suspend high occasional DISPUTE

Get a low-battery warning when a dock or weak charger is connected but the battery still drains

omarchylaptopupowerusb-cdock
CORRECTED An auditor found the fix wrong or incomplete and rewrote it. · checked against Omarchy omarchy 4.0.4-1 on 2026-10-05
AUDIT NOTE

Read issue #10939 (open). It supports the isDischarging onBattery guard and the docked-but-draining symptom. Confirmed on this workstation that BatteryModel.js is byte-identical to quattro and Service.qml hard-codes batteryThreshold 10. Quattro's Service.qml differs only by an added power-profile poll. Read UPower 1.91.3 source (installed upower 1.91.3-1): up-daemon.c sets OnBattery to display-device-discharging AND no line power online, which confirms the mechanism. The cause and danger were wrong about the critical action. up-backend.c maps CriticalPowerAction=Auto to logind's Sleep() call, not a HybridSleep, Hibernate, PowerOff chain. logind's Sleep picks from SleepOperation=, default suspend-then-hibernate suspend hibernate (logind.conf(5), systemd 256+), so on a stock machine the action is a suspend on a nearly empty battery, which is exactly what the issue's journal shows (suspend requested from client ... upowerd). The danger said it powers off or hibernates. The record's Hibernate fallback statement is correct: an explicit Hibernate falls to PowerOff when CanHibernate is false. The UPower drop-in path and 70-critical.conf name match the regex in /etc/UPower/UPower.conf.d/README.md shipped by upower. The fix's timer also fires on a normal battery discharge, where the shell already warns, so a laptop on battery would get two warnings. The corrected script only covers the OnBattery=false case. omarchy-powerprofiles-set ac balanced, omarchy hibernation setup and /usr/bin/omarchy-battery-low exist on 4.0.4-1. The manual says the AC default is performance, which supports step 2. The timer was not exercised.

The cause above was rewritten on 2026-10-05 to match this note; the fix was corrected by the audit itself.
RISK

UPower's critical action runs without asking. With the stock CriticalPowerAction=Auto it suspends through logind, and the session is lost when the battery then dies, so unsaved work is lost when no warning came first. CriticalPowerAction=Hibernate without working hibernation falls back to power-off.

Symptom

The laptop was on a dock or a low-wattage USB-C charger, the battery drained to about 2% and the machine shut down, hibernated or suspended with no "Time to recharge!" warning at any point. upower -i /org/freedesktop/UPower/devices/DisplayDevice shows state: discharging while cat /sys/class/power_supply/AC/online prints 1, and busctl get-property org.freedesktop.UPower /org/freedesktop/UPower org.freedesktop.UPower OnBattery prints b false. The journal shows upowerd requesting the sleep or power-off.

Cause

Omarchy's warning comes from the shell's battery service. isDischarging() in shell/plugins/services/battery/BatteryModel.js requires both UPower.onBattery and a Discharging battery state. UPower sets OnBattery only when the battery is discharging and no line-power supply is online, so a supply that delivers less than the machine draws produces a draining battery with the warning suppressed for the whole discharge. Omarchy's default AC power profile is performance, which makes this more likely on a weak dock. The threshold is hard-coded to 10% in Service.qml and has no setting. UPower then takes its own critical action at PercentageAction (2% in the stock /etc/UPower/UPower.conf). With the stock CriticalPowerAction=Auto, UPower calls logind's Sleep(), which uses the first supported entry of logind's SleepOperation= (default suspend-then-hibernate suspend hibernate), so on a machine without hibernation the action is a suspend on a nearly empty battery. BatteryModel.js is byte-identical on 4.0.4-1 and quattro. Issue #10939 is open.

Fix

**1. Confirm the mismatch:**


upower -i /org/freedesktop/UPower/devices/DisplayDevice | grep -E 'state|percentage'
busctl get-property org.freedesktop.UPower /org/freedesktop/UPower org.freedesktop.UPower OnBattery
grep . /sys/class/power_supply/*/online

**2. Stop the drain.** Use a charger rated for the laptop, or a lighter power profile while docked. Omarchy 4 remembers the AC profile separately, and its default is performance:


omarchy-powerprofiles-set ac balanced

**3. Add a warning for the docked case.** A user timer that calls Omarchy's own warning script only when the battery drains while UPower says a charger is online. The shell already warns when OnBattery is true, so this does not duplicate it:


mkdir -p ~/.local/bin ~/.config/systemd/user
cat > ~/.local/bin/battery-drain-warn <<'EOF'
#!/bin/bash
# Warn at or below 10% while discharging with a charger online.
info=$(upower -i /org/freedesktop/UPower/devices/DisplayDevice)
state=$(awk '/^ *state:/ {print $2}' <<<"$info")
pct=$(awk '/^ *percentage:/ {gsub("%", "", $2); print int($2)}' <<<"$info")
on_battery=$(busctl get-property org.freedesktop.UPower /org/freedesktop/UPower org.freedesktop.UPower OnBattery)
flag="${XDG_RUNTIME_DIR:-/tmp}/battery-drain-warned"
if [[ $state == discharging && $on_battery == "b false" ]] && (( pct <= 10 )); then
  [[ -e $flag ]] || { /usr/bin/omarchy-battery-low "$pct" && touch "$flag"; }
elif (( pct > 10 )); then
  rm -f "$flag"
fi
EOF
chmod +x ~/.local/bin/battery-drain-warn

cat > ~/.config/systemd/user/battery-drain-warn.service <<'EOF'
[Service]
Type=oneshot
Environment=OMARCHY_PATH=/usr/share/omarchy
ExecStart=%h/.local/bin/battery-drain-warn
EOF

cat > ~/.config/systemd/user/battery-drain-warn.timer <<'EOF'
[Timer]
OnBootSec=2min
OnUnitActiveSec=1min

[Install]
WantedBy=timers.target
EOF

systemctl --user daemon-reload
systemctl --user enable --now battery-drain-warn.timer

**4. Optional: make the last-resort action safer.** The stock CriticalPowerAction=Auto suspends, and a suspended laptop on an empty battery loses its session when the battery dies. If hibernation is set up (omarchy hibernation setup), prefer it and act a little earlier, through a UPower drop-in:


sudo install -Dm644 /dev/stdin /etc/UPower/UPower.conf.d/70-critical.conf <<'EOF'
[UPower]
PercentageAction=4.0
CriticalPowerAction=Hibernate
EOF
sudo systemctl restart upower

Without working hibernation, use CriticalPowerAction=PowerOff instead, which at least shuts down cleanly.

Verify

systemctl --user list-timers battery-drain-warn.timer shows the next run. Running ~/.local/bin/battery-drain-warn by hand at or below 10% while docked and discharging shows the "Time to recharge!" notification once. upower --dump | grep -iE 'critical|action' reflects the UPower drop-in if you added it.

Sources

omarchy-low-battery-warning-silent-while-docked-draining