Skip to content

Instantly share code, notes, and snippets.

@nickrw
Last active March 20, 2019 09:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save nickrw/063b49e9997bc4d44e0b14fb0a2dda20 to your computer and use it in GitHub Desktop.
Save nickrw/063b49e9997bc4d44e0b14fb0a2dda20 to your computer and use it in GitHub Desktop.
i3 screen lock
#!/bin/bash
# depends: scrot imagemagick keychain rivalctl
# Take a screenshot
scrot /tmp/lockshot.png
# Apply pixellation effect
convert /tmp/lockshot.png -scale 5% -scale 2000% /tmp/lockshot-pixel.png
# Set mouse LED colour to red
rivalcfg -E 4 -e 4 -c red -C red
# Securely delete the unaltered screenshot
shred -u /tmp/lockshot.png &
(
# Lock the screen
i3lock -nei /tmp/lockshot-pixel.png
# Set mouse LEDs back to normal after i3lock exits
rivalcfg -c '#40ffff' -C '#6000ff' -e 1 -E 1
) &
# Put screens to sleep after 10 minutes if the lock is still active
(
sleep 600
pgrep i3lock && xset dpms force off && keychain -k all
) &
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment