Skip to content

Instantly share code, notes, and snippets.

@xentec
Created October 21, 2021 17:12
Show Gist options
  • Save xentec/74df30bdb38e290eef317d72019496c7 to your computer and use it in GitHub Desktop.
Save xentec/74df30bdb38e290eef317d72019496c7 to your computer and use it in GitHub Desktop.
Screen locking script for swaylock.
#!/usr/bin/env fish
# You need sway, swaylock, grim, imagemagick, jq and parallel.
set SCREEN (swaymsg -t get_outputs | jq -r .[].name)
for s in $SCREEN;
set -l img /tmp/lock-$s.jpg
set -a IMG $img
set -a PARAMS "-i $s:$img"
end
parallel "grim -o {1} -t ppm -s 0.3 - | convert - -filter Gaussian -define filter:sigma=3.5 -resize 200% {2}" \
::: $SCREEN :::+ $IMG
swaylock -lF -s fill -c 000000 (echo $PARAMS | string split " ")
rm -- $IMG
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment