Skip to content

Instantly share code, notes, and snippets.

@kaihendry
Last active May 4, 2025 14:02
Show Gist options
  • Save kaihendry/fda6fca28d9273b68ed7bae7bd10b810 to your computer and use it in GitHub Desktop.
Save kaihendry/fda6fca28d9273b68ed7bae7bd10b810 to your computer and use it in GitHub Desktop.
#!/bin/bash
# Check if running on battery (optional, but good practice)
on_ac=$(acpi -a | grep -c "on-line")
if [ "$on_ac" -eq 0 ]; then
logger "Power loss detected (ACPI event), initiating suspend."
systemctl suspend
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment