diff --git a/i3lock.sh b/i3lock.sh index 72fe3e8..bfcd462 100755 --- a/i3lock.sh +++ b/i3lock.sh @@ -1,6 +1,34 @@ #!/bin/bash +cd ~/projects/scripts xset -b #disable scrot beep -scrot /tmp/screen.png -mogrify -scale 10% -scale 1000% /tmp/screen.png -[[ -f /home/user/images/icons/lock-icon.png ]] && convert /tmp/screen.png /home/user/images/icons/lock-icon-1.png -gravity center -composite -matte /tmp/screen.png -i3lock -e -u -i /tmp/screen.png \ No newline at end of file +#!/bin/bash + +# Dependencies: imagemagick, i3lock-color-git, scrot + +IMAGE=$(mktemp).png +TEXT="Type password to unlock" + +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/ + }'`; +# pixelate: -scale 10% -scale 1000% +if [ "$COLOR" -gt "$VALUE" ]; then #white background image and black text + convert $IMAGE -level 0%,100%,0.6 -filter Gaussian -resize 20% -define filter:sigma=1.5 -resize 500% -font Liberation-Sans -pointsize 26 -fill black -gravity center -annotate +0+160 "$TEXT" - | composite -gravity center lockdark.png - $IMAGE + PARAM='--textcolor=00000000 --insidecolor=0000001c --ringcolor=0000003e --linecolor=00000000 --keyhlcolor=ffffff80 --ringvercolor=ffffff00 --insidevercolor=ffffff1c --ringwrongcolor=ffffff55 --insidewrongcolor=ffffff1c' +else #black + convert $IMAGE -level 0%,100%,0.6 -filter Gaussian -resize 20% -define filter:sigma=1.5 -resize 500% -font Liberation-Sans -pointsize 26 -fill white -gravity center -annotate +0+160 "$TEXT" - | composite -gravity center lock.png - $IMAGE + PARAM='--textcolor=ffffff00 --insidecolor=ffffff1c --ringcolor=ffffff3e --linecolor=ffffff00 --keyhlcolor=00000080 --ringvercolor=00000000 --insidevercolor=0000001c --ringwrongcolor=00000055 --insidewrongcolor=0000001c' +fi + +# try to use a forked version of i3lock with prepared parameters +i3lock $PARAM -i $IMAGE > /dev/null 2>&1 + +if [ $? -ne 0 ]; then + # We have failed, lets get back to stock one + i3lock -i $IMAGE +fi + +rm $IMAGE \ No newline at end of file diff --git a/lock-icon.png b/lock-icon.png new file mode 100644 index 0000000..71c0db7 Binary files /dev/null and b/lock-icon.png differ diff --git a/lock.png b/lock.png new file mode 100644 index 0000000..e268624 Binary files /dev/null and b/lock.png differ diff --git a/lockdark.png b/lockdark.png new file mode 100644 index 0000000..baf22d1 Binary files /dev/null and b/lockdark.png differ