From c3d0af22cdc329d774a1a479685303f0d08d44a5 Mon Sep 17 00:00:00 2001 From: Konstantin Koslowski Date: Sun, 14 Aug 2022 12:55:55 +0200 Subject: [PATCH] bin/sway_lock: take screenshot for each output, use for lockscreen also reduce processing time --- bin/sway_lock | 35 +++++++++++++++++++++++++++-------- 1 file changed, 27 insertions(+), 8 deletions(-) diff --git a/bin/sway_lock b/bin/sway_lock index 537a83f..24f1f9c 100755 --- a/bin/sway_lock +++ b/bin/sway_lock @@ -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