-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpwr
executable file
·34 lines (31 loc) · 1.05 KB
/
pwr
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/usr/bin/bash
# Power management tasks.
# Usage.
usage () {
echo -n "${0##*/} [--poweroff,-p] [--restart,-r] [--suspend,-s] "
echo "[--hibernate,-h] [--blank,-b]"
}; [ $# -ne 1 -o "$1" = --help ] && { usage; exit; }
# Root test; admin. program set.
if (( $EUID )); then
hash sudo 2>&- || { echo "Requires program: sudo."; exit 1; }
sudo=sudo
fi
case $1 in
--poweroff | -p )
echo "Shutting Down..."
$sudo systemctl poweroff ;;
--reboot | -r )
echo "Restarting System..."
$sudo systemctl reboot ;;
--suspend | -s )
echo "Suspending to RAM..."
$sudo systemctl suspend ;;
--hibernate | -h )
echo "Hibernating to Disk..."
$sudo systemctl hibernate ;;
--blank | -b )
echo "Sleeping Monitor..."
sleep 1 && xset s activate ;;
* )
usage ; exit 1
esac