Skip to content

Instantly share code, notes, and snippets.

@xentec
Last active December 24, 2025 16:03
Show Gist options
  • Select an option

  • Save xentec/74df30bdb38e290eef317d72019496c7 to your computer and use it in GitHub Desktop.

Select an option

Save xentec/74df30bdb38e290eef317d72019496c7 to your computer and use it in GitHub Desktop.
Screen locking script for swaylock.
#!/usr/bin/env fish
# You need wlr-randr, grim, imagemagick, jq and parallel.
set SCREENS (wlr-randr --json | jq -r .[].name)
for scr in $SCREENS
set -l img /tmp/lock-$scr.jpg
set -a IMGS $img
set -a PARAMS "-i $scr:$img"
end
#echo "Params: $PARAMS"
#echo "Images: $IMGS"
parallel "grim -o {1} -t ppm -s 0.3 - | magick - -filter Gaussian -define filter:sigma=3.5 -resize 200% {2}" \
::: $SCREENS :::+ $IMGS
echo "Locking..."
swaylock \
--daemonize \
--indicator-caps-lock \
--show-failed-attempts \
--scaling fill --color 000000 \
(echo $PARAMS | string split " ")
rm -- $IMGS
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment