80 lines
1.4 KiB
Bash
Executable file
80 lines
1.4 KiB
Bash
Executable file
#!/bin/bash
|
|
|
|
function lock {
|
|
# Take a screenshot
|
|
scrot /tmp/screen_locked.png
|
|
# Pixellate it 10x
|
|
mogrify -scale 10% -scale 1000% /tmp/screen_locked.png
|
|
# Lock screen displaying this image.
|
|
i3lock -i /tmp/screen_locked.png
|
|
# delete Image
|
|
rm -f /tmp/screen_locked.png
|
|
}
|
|
function reboot {
|
|
sudo systemctl reboot
|
|
}
|
|
function shutdown {
|
|
sudo systemctl poweroff
|
|
}
|
|
function suspend {
|
|
lock
|
|
sudo systemctl suspend
|
|
}
|
|
function hibernate {
|
|
lock
|
|
sudo systemctl hibernate
|
|
}
|
|
function help {
|
|
echo "
|
|
Usage:
|
|
./pwr.sh [-r|-s|-sd|-hb]
|
|
|
|
Arguments:
|
|
-r, --reboot Reboot this system.
|
|
-s, --shutdown Shutdown this system.
|
|
-sd, --suspend Suspends this system.
|
|
-hb, --hibernate Hibernates this system.
|
|
-h, --help Displays this help.
|
|
"
|
|
}
|
|
function display_off {
|
|
# Turn the screen off
|
|
xset dpms force off
|
|
}
|
|
|
|
|
|
if [[ -n "$1" ]]; then
|
|
case "$1" in
|
|
--reboot | -r)
|
|
dunstify -u critical "reboot"
|
|
sleep 3
|
|
reboot
|
|
;;
|
|
--shutdown | -s)
|
|
dunstify -u critical "shutdown"
|
|
sleep 3
|
|
shutdown
|
|
;;
|
|
--suspend | -sd)
|
|
dunstify -u critical "suspend"
|
|
sleep 3
|
|
suspend
|
|
;;
|
|
--hibernate | -hb)
|
|
dunstify -u critical "hibernate"
|
|
sleep 3
|
|
hibernate
|
|
;;
|
|
--help | -h)
|
|
help
|
|
exit 0
|
|
;;
|
|
*)
|
|
echo -e "\e[31mUnbekannter Parameter!"
|
|
exit 1
|
|
esac
|
|
else
|
|
lock
|
|
sleep 60
|
|
display_off
|
|
fi
|