Created
December 21, 2024 18:55
-
-
Save BenHerbst/ddb4e4e52803dde44e686e67926338a0 to your computer and use it in GitHub Desktop.
This Shell Script turns off a laptop 10 seconds after the AC Power is lost
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| while true | |
| do | |
| if ! on_ac_power; then | |
| notify-send "Lost Power. System shutdowns in 10 Seconds!" | |
| echo "Lost AC-Power. Shutting down in 10 Seconds ..." | |
| sleep 10 | |
| echo "You are on AC-Power" | |
| echo "password" | sudo -kS shutdown -h now | |
| fi | |
| sleep 10 | |
| done | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment