Files
linux-provisioning/config/scripts/idle-battery-suspend.sh
Julian Prester 180c5838ea Initial commit: linux-provision repo
Distribution-agnostic provisioning script that sets up a new Linux machine
(Detected via lib/distro.sh - supports Debian/Ubuntu/Pop and Fedora families).

13 stages covering:
- System packages, external repos, toolchains (nvm, uv, Python)
- Shell config (zsh, oh-my-zsh, p10k), git, SSH
- Custom uv tools from ~40 git repos
- Desktop config (keybindings, hotkeys, ghostty, fonts)
- Docker, system tweaks, browser/app installs
- Custom systemd user services (porridge, swayidle, mempi-sync, etc.)
- API keys loaded from Bitwarden at shell startup
2026-06-05 21:22:44 +10:00

12 lines
542 B
Bash

#!/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