Lock Script erweitert
This commit is contained in:
parent
14fb1ef220
commit
4788470c0d
1 changed files with 73 additions and 10 deletions
|
@ -1,17 +1,80 @@
|
|||
#!/bin/sh -e
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if [[ -n "$1" ]]; then
|
||||
case "$1" in
|
||||
--lock | -l)
|
||||
lock
|
||||
;;
|
||||
--reboot | -r)
|
||||
reboot
|
||||
;;
|
||||
--shutdown | -s)
|
||||
shutdown
|
||||
;;
|
||||
--suspend | -sd)
|
||||
suspend
|
||||
;;
|
||||
--hibernate | -hb)
|
||||
hibernate
|
||||
;;
|
||||
--help | -h)
|
||||
exit 0
|
||||
;;
|
||||
*)
|
||||
echo -e "\e[31mUnbekannter Paremeter!"
|
||||
exit 1
|
||||
esac
|
||||
fi
|
||||
|
||||
|
||||
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 {
|
||||
lock
|
||||
sudo systemctl reboot
|
||||
}
|
||||
function shutdown {
|
||||
lock
|
||||
sudo systemctl shutdown
|
||||
}
|
||||
function suspend {
|
||||
lock
|
||||
sudo systemctl suspend
|
||||
}
|
||||
function hibernate {
|
||||
lock
|
||||
sudo systemctl reboot
|
||||
}
|
||||
function help {
|
||||
echo "
|
||||
Usage:
|
||||
./build.sh [-l|-r|-s|-sd|-hb]
|
||||
|
||||
# Turn the screen off after a delay.
|
||||
sleep 60; pgrep i3lock && xset dpms force off
|
||||
|
||||
Arguments:
|
||||
-l, --lock Lock display.
|
||||
-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
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue