All shell scripts and config files should be executable (755) for direct invocation. No content changes.
12 lines
542 B
Bash
Executable File
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
|