Created
November 26, 2022 12:18
-
-
Save mnl/f4c34091e82e90944557e925bb8efe5e to your computer and use it in GitHub Desktop.
swaylock with blurred screenshot
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# shellcheck disable=SC2086,SC2064 | |
# vim: set ts=2 sw=2 tw=0 noet : | |
# Take screenshots, apply gaussian blur, lock screen | |
# grim -> blur -> swaylock | |
readonly GRIM=/usr/bin/grim | |
readonly BLUR="$HOME/bin/blur" | |
set -Eueo pipefail | |
# lock with safe config on error | |
trap "swaylock -feFKc 133337 -C /dev/null" ERR INT | |
scratch=$(mktemp -d /tmp/lockscreenshot.XXX) | |
trap "rm -rf ${scratch}" EXIT | |
# Build swaylock args | |
ARGS="--daemonize" | |
# Active monitors, not just .focused | |
for monitor in $(swaymsg -t get_outputs | jq -r '.[] | select(.active) | .name') | |
do | |
img="${scratch}/${monitor}.png" | |
{ | |
$GRIM -o "${monitor}" "${img}" && | |
$BLUR "${img}" "${img}" > /dev/null | |
} & | |
ARGS="$ARGS --image=${monitor}:${img}" | |
done | |
wait # for all screenhots to blur | |
exec swaylock $ARGS |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment