Files
linux-provisioning/config/scripts/idle-battery-suspend.sh
Julian Prester 2ca9a2bdef Fix script file permissions (644 → 755 for executables)
All shell scripts and config files should be executable (755)
for direct invocation. No content changes.
2026-06-07 14:34:51 +10:00

12 lines
542 B
Bash
Executable File

#!/bin/bash
# ===========================================================================
# idle-battery-suspend.sh — Suspend laptop only when on battery
# Checks AC power status before suspending. If on AC power, does nothing.
# Used by swayidle.service (systemd user service).
# ===========================================================================
# Only suspend if on battery (AC online = 0)
AC_ONLINE=$(cat /sys/class/power_supply/AC/online 2>/dev/null)
if [ "$AC_ONLINE" = "0" ]; then
systemctl suspend-then-hibernate
fi