Ubuntu Pastebin

Paste from jordan at Fri, 13 Feb 2015 04:05:11 +0000

Download as text
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
#!/bin/bash

# This script is intended to automatically shutdown the computer $wait_time
# minutes after transitioning from being plugged in to running on battery
# power. This was added manually, by the advice of Jordan_U in #ubuntu
# on irc.freenode.net .

wait_time=5

if [[ "$1" == "true" ]]; then
  # We're transitioning to battery power, trigger delayed shutdown.
  shutdown -h "$wait_time" "Shutdown triggered by /etc/pm/power.d/99_auto_shutdown because AC power was lost." & disown
else
  # Power came back, cancel shutdown.
  # Note, this may cancel a shutdown that was trigged by means other than
  # this script. Use at your own risk.
  shutdown -c "Shutdown canceled by /etc/pm/power.d/99_auto_shutdown as laptop AC power was restored."
fi

exit 0
Download as text