-
Notifications
You must be signed in to change notification settings - Fork 9
/
mantablockscreen.in
executable file
·166 lines (150 loc) · 5.54 KB
/
mantablockscreen.in
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
#!/bin/env bash
wallpaper=$2
cachepath=$HOME/.cache/mantablockscreen
cropuser=$cachepath/$USER-pic-crop.png
fullname=`getent passwd $USER | cut -d ":" -f 5 | cut -d "," -f 1`
full_alias="${fullname} (${USER})"
if [[ -n $fullname ]]; then
full_alias="${fullname} (${USER})"
else
full_alias=$USER
fi
width=$(xrandr --query | grep ' connected' | grep -o '[0-9][0-9]*x[0-9][0-9]*[^ ]*' | sed -r 's/^[^0-9]*([0-9]+x[0-9]+).*$/\1/' |cut -d "x" -f 1 |head -n1)
height=$(xrandr --query | grep ' connected' | grep -o '[0-9][0-9]*x[0-9][0-9]*[^ ]*' | sed -r 's/^[^0-9]*([0-9]+x[0-9]+).*$/\1/' |cut -d "x" -f 2 |head -n1)
half_width=$((width/2))
half_height=$((height/2))
fg_color=fefefeff
wrong_color=f82a11aa
highlight_color=39393999
verif_color=fefefe66
cropuser() {
ava_home=$HOME/.face
ava_var=/var/lib/AccountsService/icons/$USER
userpic=@pkgdatadir@/userpic.png
if [[ -e $ava_home ]]; then
userpic=$ava_home
elif [[ -e $ava_var ]]; then
userpic=$ava_var
fi
convert $userpic -resize 100x100 -gravity Center \( \
-size 100x100 xc:Black \
-fill White \
-draw "circle 50 50 50 1" \
-alpha Copy\
\) -compose CopyOpacity -composite -trim $cropuser
}
cropbg() {
convert "$wallpaper" -resize ${width}x -gravity center -crop ${width}x${height}+0+0 +repage \( \
-size 120x140 xc:none \
\) -gravity south -compose over -composite $cachepath/resize.png
}
blurbg() {
convert "$cachepath/resize.png" \
-filter Gaussian \
-blur 0x8 \
"$cachepath/resize-blur.png"
}
genbg() {
echo "Caching image ..."
if [[ ! -d $HOME/.cache/mantablockscreen ]]; then
mkdir $HOME/.cache/mantablockscreen
fi
cropuser
cropbg
blurbg
composite -geometry "+$((half_width-50))+$((half_height-130))" $cropuser $cachepath/resize-blur.png $cachepath/resize-pic-blur.png
composite -geometry "+$((half_width-50))+$((half_height+10))" $cropuser $cachepath/resize-blur.png $cachepath/resize-pic-sc-blur.png
echo "Finished caching image"
}
slowfade () {
dis=$(echo -n "$DISPLAY" | tr -c '[:alnum:]' _)
ifc='com.github.chjj.compton'
obj='/com/github/chjj/compton'
if [[ "$1" == "start" ]]; then
dbus-send --print-reply --dest=$ifc.$dis \
$obj $ifc.opts_set string:fade_in_step double:0.02
dbus-send --print-reply --dest=$ifc.$dis \
$obj $ifc.opts_set string:fade_out_step double:0.02
else
dbus-send --print-reply --dest=$ifc.$dis \
$obj $ifc.opts_set string:fade_in_step double:0.1
dbus-send --print-reply --dest=$ifc.$dis \
$obj $ifc.opts_set string:fade_out_step double:0.1
fi
}
lock() {
slowfade start
i3lock -n --force-clock -i $cachepath/resize-pic-blur.png \
--ind-pos="w/2:h/2+60" --time-pos="w-100:h-70" --date-pos="w-115:h-40" --greeter-pos="w/2:h/2" \
--insidever-color=$fg_color --insidewrong-color=$wrong_color --inside-color=fefefe00 \
--ringver-color=$verif_color --ringwrong-color=$wrong_color --ring-color=$fg_color \
--keyhl-color=$highlight_color --bshl-color=$highlight_color --separator-color=00000000 \
--date-color=$fg_color --time-color=$fg_color --greeter-color=$fg_color \
--time-str="%H:%M" --time-size=50 \
--date-str="%a, %b %d" --date-size=30 \
--greeter-text="$full_alias" --greeter-size=25\
--line-uses-ring \
--radius 38 --ring-width 3 --indicator \
--verif-text="" --wrong-text="" --noinput-text="" \
--clock --date-font="SF Pro Display" --time-font="SF Pro Display"
sleep 1
slowfade end
}
stackclock() {
slowfade start
date_now=$(date +'%b, %d')
i3lock -n --force-clock -i $cachepath/resize-pic-sc-blur.png \
--ind-pos="w/2:h/2+60" --time-pos="w/2:h/2-100" --date-pos="w/2:h/2-30" --greeter-pos="w/2:h/2" \
--insidever-color=$verif_color --insidewrong-color=$wrong_color --inside-color=fefefe00 \
--ringver-color=$verif_color --ringwrong-color=$wrong_color --ring-color=$fg_color \
--keyhl-color=$highlight_color --bshl-color=$highlight_color --separator-color=00000000 \
--date-color=$fg_color --time-color=$fg_color --greeter-color=$fg_color \
--time-str="%H" --time-size=70 \
--date-str="%M" --date-size=70 \
--greeter-text="$date_now" --greeter-size=25\
--line-uses-inside --radius 50 --ring-width 2 --indicator \
--verif-text="" --wrong-text="" --noinput-text="" \
--clock --date-font="Abel" --time-font="Abel"
sleep 1
slowfade end
}
circleclock() {
slowfade start
i3lock -n --force-clock -i $cachepath/resize-blur.png \
--ind-pos="w/2:h/2" --time-pos="w/2:h/2-5" --date-pos="w/2:h/2+35" --greeter-pos="w/2:h/2" \
--insidever-color=5f5f5f66 --insidewrong-color=$wrong_color --inside-color=5f5f5f66 \
--ringver-color=$verif_color --ringwrong-color=$wrong_color --ring-color=$fg_color \
--keyhl-color=$highlight_color --bshl-color=$highlight_color --separator-color=00000000 \
--date-color=$fg_color --time-color=$fg_color --greeter-color=$fg_color \
--time-str="%H | %M" --time-size=40 \
--date-str="%a, %d %b" --date-size=25 \
--greeter-text="$date_now" --greeter-size=25 \
--line-uses-inside --radius 75 --ring-width 2 --indicator \
--verif-text="" --wrong-text="" --noinput-text="" \
--clock --date-font="Abel" --time-font="Abel"
sleep 1
slowfade end
}
show_help(){
cat <<-EOF
Usage :
mantablockscreen [OPTION]
Avaible options:
-i, --image Generate cache image
-sc, --stackclock Show lockscreen with stacked digital clock
-cc, --circleclock Show lockscreen with clock inside circle
-h, --help Show this help
EOF
}
case $1 in
-i|--image)
genbg $2 ;;
-h|--help)
show_help ;;
-sc|--stackclock)
stackclock ;;
-cc|--circleclock)
circleclock ;;
*)
lock ;;
esac