-
Notifications
You must be signed in to change notification settings - Fork 6
/
i3lock-simple
executable file
·49 lines (44 loc) · 1.58 KB
/
i3lock-simple
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
#!/bin/bash
# i3lock-simle
# This script will:
# 1. take screenshot of the screen
# 2. pixelize the image, by scaling down and them scale up the image
# 3. if an overlay image exist, merge the screenshot with the overlay
# 4. lock the screen with the image
# Author: Bruno de Lima <github.com/brunodles>
tmp=/tmp/screen.png
cfg_pixelize_scale='10'
scale_down=$(( 100/cfg_pixelize_scale ))
scale_up=$(( 100*cfg_pixelize_scale ))
scrot -e "convert \$f -scale "$scale_down"% -scale "$scale_up"% ${tmp}" "${tmp}"
if [[ -f $1 ]] ; then
img=$1
else
img=~/.config/i3/lock.png
fi
if [[ -f $img ]]
then
# placement x/y
PX=0
PY=0
# lockscreen image info
R=$(file $img | grep -o '[0-9]* x [0-9]*')
RX=$(echo $R | cut -d' ' -f 1)
RY=$(echo $R | cut -d' ' -f 3)
SR=$(xrandr --query | grep ' connected' | sed 's/primary //' | cut -f3 -d' ')
for RES in $SR
do
# monitor position/offset
SRX=$(echo $RES | cut -d'x' -f 1) # x pos
SRY=$(echo $RES | cut -d'x' -f 2 | cut -d'+' -f 1) # y pos
SROX=$(echo $RES | cut -d'x' -f 2 | cut -d'+' -f 2) # x offset
SROY=$(echo $RES | cut -d'x' -f 2 | cut -d'+' -f 3) # y offset
PX=$(($SROX + $SRX / 2 - $RX / 2))
PY=$(($SROY + $SRY / 2 - $RY / 2))
convert /tmp/screen.png $img -geometry +$PX+$PY -composite -matte /tmp/screen.png
#echo "done"
done
fi
# dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Stop
# i3lock -I 10 -d -e -u -n -i /tmp/screen.png
i3lock -e -u -n -i /tmp/screen.png