71 lines
994 B
Bash
Executable file
71 lines
994 B
Bash
Executable file
#!/bin/bash
|
|
IMAGE=$HOME/.lockscreen.jpg
|
|
SCROT_APP=grim
|
|
SCROT_ARGS=" -t jpeg"
|
|
LOCK_APP=swaylock
|
|
LOCK_ARGS=" -f -c 000000 -i $IMAGE"
|
|
|
|
|
|
function _app_exists() {
|
|
which $1 &> /dev/null
|
|
if [ $? -ne 0 ]; then
|
|
echo "ERROR: missing app \"$1\""
|
|
exit 1
|
|
fi
|
|
}
|
|
|
|
function _clean() {
|
|
rm -vf $IMAGE
|
|
}
|
|
|
|
function _lock() {
|
|
_app_exists $LOCK_APP
|
|
$LOCK_APP $LOCK_ARGS
|
|
}
|
|
|
|
function _off() {
|
|
swaymsg "output * dpms off"
|
|
}
|
|
|
|
function _on() {
|
|
swaymsg "output * dpms on"
|
|
}
|
|
|
|
function _screenshot() {
|
|
_app_exists $SCROT_APP
|
|
$SCROT_APP $SCROT_ARGS $IMAGE
|
|
convert -blur 4x4 $IMAGE $IMAGE
|
|
}
|
|
|
|
mkdir -p $HOME/log
|
|
echo "lock: $(date) args: $*" >> $HOME/log/lock.log
|
|
|
|
case "$1" in
|
|
lock)
|
|
_on
|
|
_screenshot
|
|
_lock
|
|
_clean
|
|
;;
|
|
lockonly)
|
|
_lock
|
|
_clean
|
|
;;
|
|
off)
|
|
_screenshot
|
|
_off
|
|
;;
|
|
on)
|
|
_on
|
|
_clean
|
|
;;
|
|
screenshot)
|
|
_on
|
|
_screenshot
|
|
;;
|
|
*)
|
|
echo "invalid argument \"$1\"."
|
|
echo "arguments: [lock|lockonly|off|on|screenshot]"
|
|
esac
|
|
|
|
|