bin/sway_lock: take screenshot for each output, use for lockscreen

also reduce processing time
This commit is contained in:
Konstantin Koslowski 2022-08-14 12:55:55 +02:00
parent a099e583c7
commit c3d0af22cd

View file

@ -1,23 +1,30 @@
#!/bin/bash
source $HOME/.config/sway/bin/sway_helpers
IMAGE=$HOME/.lockscreen.png
LOCK_IMAGE=$HOME/.config/sway/bin/lock.png
OUTPUT=$(swaymsg -t get_outputs -p | grep focused | cut -d " " -f 2)
MEDIA_APP=playerctl
SCROT_APP=grim
SCROT_ARGS=" -o $OUTPUT -t png"
SCROT_APP_ARGS=" -t jpeg"
SCROT_FILE_BASE=$HOME/.lockscreen
SCROT_FILE_EXT=jpg
LOCK_APP=swaylock
LOCK_ARGS=" -f -F -e -s fill -c 000000 --indicator-radius 100 --indicator-thickness 20 -i $IMAGE"
LOCK_ARGS=" -f -F -e -s fill -c 000000 --indicator-radius 100 --indicator-thickness 20"
INHIBIT_FILE=$HOME/.inhibit_lock
function _clean() {
rm -vf $IMAGE
for output in $(_outputs); do
SCROT_FILE=${SCROT_FILE_BASE}_${output}.${SCROT_FILE_EXT}
rm -vf $SCROT_FILE
done
}
function _lock() {
_check_inhibit $INHIBIT_FILE
$MEDIA_APP pause
_check_running $LOCK_APP
for output in $(_outputs); do
SCROT_FILE=${SCROT_FILE_BASE}_${output}.${SCROT_FILE_EXT}
LOCK_ARGS+=" -i ${output}:$SCROT_FILE"
done
$LOCK_APP $LOCK_ARGS
}
@ -29,10 +36,22 @@ function _on() {
swaymsg "output * dpms on"
}
function _outputs() {
swaymsg -t get_outputs | jq '.[] |select(.active == true) | .name' | while read line; do
echo ${line//\"/}
done
}
function _screenshot() {
$SCROT_APP $SCROT_ARGS $IMAGE
convert -blur 4x4 $IMAGE $IMAGE
convert -composite -gravity center $IMAGE $LOCK_IMAGE $IMAGE
for output in $(_outputs); do
SCROT_FILE=${SCROT_FILE_BASE}_${output}.${SCROT_FILE_EXT}
echo $SCROT_FILE
$SCROT_APP $SCROT_APP_ARGS -o $output $SCROT_FILE
# convert -blur 0x5 $SCROT_FILE $SCROT_FILE
# convert -motion-blur 15x15 $SCROT_FILE $SCROT_FILE
convert -scale 20% -blur 0x2.5 -resize 500% $SCROT_FILE $SCROT_FILE
convert -composite -gravity center $SCROT_FILE $LOCK_IMAGE $SCROT_FILE
done
}
## main