2020-12-18 15:33:47 +01:00
|
|
|
#!/bin/bash
|
2021-01-04 18:46:33 +01:00
|
|
|
source $HOME/.config/sway/bin/sway_helpers
|
2022-06-27 10:29:52 +02:00
|
|
|
IMAGE=$HOME/.lockscreen.png
|
2021-01-06 19:12:31 +01:00
|
|
|
LOCK_IMAGE=$HOME/.config/sway/bin/lock.png
|
2022-06-27 10:29:52 +02:00
|
|
|
OUTPUT=$(swaymsg -t get_outputs -p | grep focused | cut -d " " -f 2)
|
2022-04-20 20:42:25 +02:00
|
|
|
MEDIA_APP=playerctl
|
2020-12-22 13:19:58 +01:00
|
|
|
SCROT_APP=grim
|
2022-06-27 10:29:52 +02:00
|
|
|
SCROT_ARGS=" -o $OUTPUT -t png"
|
2020-12-22 13:19:58 +01:00
|
|
|
LOCK_APP=swaylock
|
2022-07-02 15:29:48 +02:00
|
|
|
LOCK_ARGS=" -f -F -e -s fill -c 000000 --indicator-radius 100 --indicator-thickness 20 -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
|
2022-07-02 15:29:48 +02:00
|
|
|
$MEDIA_APP pause
|
2022-05-06 11:22:58 +02:00
|
|
|
_check_running $LOCK_APP
|
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
|
2021-01-06 19:12:31 +01:00
|
|
|
convert -composite -gravity center $IMAGE $LOCK_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-06 19:12:31 +01:00
|
|
|
i*)
|
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
|
2022-06-27 10:29:52 +02:00
|
|
|
_clean
|
2020-12-22 13:19:58 +01:00
|
|
|
;;
|
|
|
|
lockonly)
|
|
|
|
_lock
|
2022-06-27 10:29:52 +02:00
|
|
|
_clean
|
2020-12-22 13:19:58 +01:00
|
|
|
;;
|
|
|
|
off)
|
|
|
|
_screenshot
|
|
|
|
_off
|
|
|
|
;;
|
|
|
|
on)
|
|
|
|
_on
|
2022-06-27 10:29:52 +02: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
|
|
|
|
|
|
|
|
|