Skip to content

Instantly share code, notes, and snippets.

@m-wynn
Created February 16, 2016 21:36
Show Gist options
  • Save m-wynn/cb7140f0deeb68e150f2 to your computer and use it in GitHub Desktop.
Save m-wynn/cb7140f0deeb68e150f2 to your computer and use it in GitHub Desktop.
so pretty
#!/bin/bash
#scrot /tmp/screen.png
#convert /tmp/screen.png -scale 10% -scale 1000% /tmp/screen.png
#[[ -f $HOME/.config/awesome/lock.png ]] && convert /tmp/screen.png $HOME/.config/awesome/lock.png -gravity center -composite -matte /tmp/screen.png
#i3lock -t -i /tmp/screen.png
# Dependencies: imagemagick, i3lock-color-git, scrot
IMAGE=/tmp/i3lock.png
VALUE="60" #brightness value to compare to
scrot $IMAGE
COLOR=`convert $IMAGE -colorspace hsb -resize 1x1 txt:- | sed -E '/.*$/ {
N
s/.*\n.*([0-9]{1,2}[^\.])\.[0-9]+%\)$/\1/
}'`;
COLOR=0;
if [ "$COLOR" -gt "$VALUE" ]; then #white background image and black text
convert $IMAGE -level 0%,100%,0.6 -filter Gaussian -resize 50% -define filter:sigma=4.5 -resize 200% -font Liberation-Sans -pointsize 26 -fill black -gravity center -annotate +0+160 'Type password to unlock' - | composite -gravity center ~/bin/lockdark.png - $IMAGE
i3lock --textcolor=00000000 --insidecolor=0000001c --ringcolor=0000003e --linecolor=00000000 --keyhlcolor=ffffff80 --ringvercolor=ffffff00 --insidevercolor=ffffff1c --ringwrongcolor=ffffff55 --insidewrongcolor=ffffff1c -i $IMAGE
else #black
convert $IMAGE -level 0%,100%,0.6 -filter Gaussian -resize 50% -define filter:sigma=4.5 -resize 200% -font Liberation-Sans -pointsize 26 -fill white -gravity center -annotate +0+160 'Type password to unlock' - | composite -gravity center ~/bin/lock.png - $IMAGE
i3lock --textcolor=ffffff00 --insidecolor=ffffff1c --ringcolor=ffffff3e --linecolor=ffffff00 --keyhlcolor=00000080 --ringvercolor=00000000 --insidevercolor=0000001c --ringwrongcolor=00000055 --insidewrongcolor=0000001c -i $IMAGE
fi
rm $IMAGE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment