Skip to content

Instantly share code, notes, and snippets.

@tilpner
Created February 14, 2019 19:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tilpner/bfe7ddce4fdbaaab2a9319ae0c023bec to your computer and use it in GitHub Desktop.
Save tilpner/bfe7ddce4fdbaaab2a9319ae0c023bec to your computer and use it in GitHub Desktop.
{ lib, writeShellScriptBin, coreutils, i3lock, scrot, imagemagick,
private ? true }:
let
path = lib.makeBinPath ([
coreutils
i3lock
] ++ (lib.optionals (!private) [
scrot
imagemagick
]));
in writeShellScriptBin "slock" ''
export PATH=${path}
${if private then ''
i3lock --show-failed-attempts -c 000000
'' else ''
screen=/run/user/$UID/screen.png
convert x:root -scale 5% -sample 2000% -quality 30 $screen
i3lock --show-failed-attempts -i $screen
''}
pid=$!
wait $pid
[ -f "$screen" ] && rm $screen
''
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment