config_sway/bin/sway_lock

73 lines
1.2 KiB
Bash
Executable file

#!/bin/bash
source $HOME/.config/sway/bin/sway_helpers
IMAGE=$HOME/.lockscreen.jpg
LOCK_IMAGE=$HOME/.config/sway/bin/lock.png
MEDIA_APP=playerctl
SCROT_APP=grim
SCROT_ARGS=" -t jpeg"
LOCK_APP=swaylock
LOCK_ARGS=" -f -F -e -c 000000 --indicator-radius 100 --indicator-thickness 20 -i $IMAGE"
INHIBIT_FILE=$HOME/.inhibit_lock
function _clean() {
rm -vf $IMAGE
}
function _lock() {
_check_inhibit $INHIBIT_FILE
$MEDIA_APP stop
_check_running $LOCK_APP
$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
convert -composite -gravity center $IMAGE $LOCK_IMAGE $IMAGE
}
## main
_log LOCK INFO args: $*
_check_app $LOCK_APP
_check_app $SCROT_APP
case "$1" in
i*)
_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