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