config_sway/bin/lock

68 lines
995 B
Bash
Executable file

#!/bin/bash
source $HOME/.config/sway/bin/helpers
IMAGE=$HOME/.lockscreen.jpg
SCROT_APP=grim
SCROT_ARGS=" -t jpeg"
LOCK_APP=swaylock
LOCK_ARGS=" -f -c 000000 -i $IMAGE"
INHIBIT_FILE=$HOME/.inhibit_lock
function _clean() {
rm -vf $IMAGE
}
function _lock() {
_check_inhibit $INHIBIT_FILE
$LOCK_APP $LOCK_ARGS
}
function _off() {
swaymsg "output * dpms off"
}
function _on() {
swaymsg "output * dpms on"
}
function _screenshot() {
$SCROT_APP $SCROT_ARGS $IMAGE
convert -blur 4x4 $IMAGE $IMAGE
}
## main
_log LOCK INFO args: $*
_check_app $LOCK_APP
_check_app $SCROT_APP
case "$1" in
inhibit)
_set_inhibit $INHIBIT_FILE $2
;;
lock)
_on
_screenshot
_lock
# _clean
;;
lockonly)
_lock
# _clean
;;
off)
_screenshot
_off
;;
on)
_on
# _clean
;;
screenshot)
_on
_screenshot
;;
*)
echo "invalid argument \"$1\""
echo "arguments: [inhibit [on|off]|lock|lockonly|off|on|screenshot]"
esac