forked from meskarune/i3lock-fancy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlock
executable file
·56 lines (48 loc) · 2.08 KB
/
lock
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/bin/bash
# Dependencies: imagemagick, i3lock-color-git, scrot
IMAGE=$(mktemp).png
TEXT="Type password to unlock"
# get path where the script is located
# its used for the lock icon
pushd `dirname $0` > /dev/null
SCRIPTPATH=`pwd`
popd > /dev/null
# l10n support
case $LANG in
fr_* ) TEXT="Entrez votre mot de passe" ;; # Français
es_* ) TEXT="Ingrese su contraseña" ;; # Española
pl_* ) TEXT="Podaj hasło" ;; # Polish
esac
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.5% \
-font Liberation-Sans -pointsize 26 -fill black -gravity center \
-annotate +0+160 "$TEXT" \
$SCRIPTPATH/lockdark.png -gravity center -composite $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.5% \
-font Liberation-Sans -pointsize 26 -fill white -gravity center \
-annotate +0+160 "$TEXT" \
$SCRIPTPATH/lock.png -gravity center -composite $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