forked from RealOrangeOne/pranklock
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pranklock
executable file
·41 lines (33 loc) · 1.35 KB
/
pranklock
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
#!/usr/bin/env bash
# Forked pranklock by vhash and zeub13
# See https://github.com/RealOrangeOne/pranklock
# Prank your firend by showing a meme when touching computer while locked
# and capture and save both photo and video at this time.
# Escape key used to exit lockscreen whitout been pranked
ESCAPE_KEY=9
TEMP_FILE_PHOTO=$(mktemp -t "XXXXXXXXXX.png")
TEMP_FILE_VIDEO=$(mktemp -t "XXXXXXXXXX.mkv")
VIDEO_DEV=${1:-/dev/video0}
MEME_FILE="/opt/pranklock/you_got_pranked_yoda.png"
# Take picture and video of the pranked guy, saving it on local filesystem
capture_pranked_guy () {
ffmpeg -f video4linux2 -video_size hd720 -i "$VIDEO_DEV" -y -vf "scale=$screensize" -frames 1 "$TEMP_FILE_PHOTO"
ffmpeg -f v4l2 -framerate 60 -video_size 1920x1080 -t 00:00:05 -i "$VIDEO_DEV" -y -vf "scale=$screensize" "$TEMP_FILE_VIDEO"
}
screensize=$(xdpyinfo | grep -i dimensions: | sed 's/[^0-9]*pixels.*(.*).*//' | sed 's/[^0-9x]*//')
ffmpeg -y -f x11grab -s "$screensize" -i "$DISPLAY" -vframes 1 "$TEMP_FILE_PHOTO"
i3lock -i "$TEMP_FILE_PHOTO" -p default &
key=0
while read -r line
do
if [[ "$line" =~ "detail:" ]]; then
key=${line//detail: /}
break
fi
done < <(xinput test-xi2 --root)
# When input is recieved but is not the escape key
if [[ "$key" -ne "$ESCAPE_KEY" ]]; then
killall i3lock
i3lock -i "$MEME_FILE"
capture_pranked_guy
fi