summaryrefslogtreecommitdiff
path: root/scripts/glitchlock
blob: b9b51570d08757590ce42945fa957c4d3791263e (plain)
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
#!/bin/bash
# ┏━┓┳  o┏┓┓┏━┓┳ ┳┳  ┏━┓┏━┓┳┏ 
# ┃ ┳┃  ┃ ┃ ┃  ┃━┫┃  ┃ ┃┃  ┣┻┓
# ┇━┛┇━┛┇ ┇ ┗━┛┇ ┻┇━┛┛━┛┗━┛┇ ┛
#
# author: xero <x@xero.nu> http://xero.nu
# requires: i3lock-color, imagemagick, scrot

maim /tmp/lock.png
convert /tmp/lock.png /tmp/lock.jpg
file=/tmp/lock.jpg

function datamosh() {
	fileSize=$(wc -c < "$file")
	headerSize=1000
	skip=$(shuf -i "$headerSize"-"$fileSize" -n 1)
	count=$(shuf -i 1-10 -n 1)
	for i in $(seq 1 $count);do byteStr=$byteStr'\x'$(shuf -i 0-255 -n 1); done;   
	printf $byteStr | dd of="$file" bs=1 seek=$skip count=$count conv=notrunc >/dev/null 2>&1
}

steps=$(shuf -i 40-70 -n 1)
for i in $(seq 1 $steps);do datamosh "$file"; done

GLITCHICON=${GLITCHICON:=""}
PARAM=(--bar-indicator --bar-orientation horizontal --bar-direction 1 --redraw-thread -t "" \
	--bar-step 50 --bar-total-width 250 --bar-base-width 50 --bar-max-height 100 --bar-periodic-step 50 \
	--bar-color 00000077 --keyhl-color 00666666 --ringver-color cc87875f --wrong-color ffff0000 \
	--verif-text="" --wrong-text="" --noinput-text="" )

LOCK=()
while read LINE
do
	if [[ "$LINE" =~ ([0-9]+)x([0-9]+)\+([0-9]+)\+([0-9]+) ]]; then
		W=${BASH_REMATCH[1]}
		H=${BASH_REMATCH[2]}
		Xoff=${BASH_REMATCH[3]}
		Yoff=${BASH_REMATCH[4]}
		if [ ! -z "$GLITCHICON" ]; then
			IW=`identify -ping -format '%w' $GLITCHICON`
			IH=`identify -ping -format '%h' $GLITCHICON`
			MIDXi=$(($W / 2 + $Xoff - $IW / 2))
			MIDYi=$(($H / 2 + $Yoff - $IH / 2))
			LOCK+=($GLITCHICON -geometry +$MIDXi+$MIDYi -composite)
		fi
	fi
done <<<"$(xrandr)"

convert /tmp/lock.jpg /tmp/lock.png >/dev/null 2>&1
rm /tmp/lock.jpg
file=/tmp/lock.png

convert "$file" "${LOCK[@]}" "$file"

LC_ALL="fr_FR.UTF-8" i3lock -f --indicator -k --time-color="458588ff" --date-color="458588ff" --verif-text="Vérification..." --wrong-text="" --wrong-font="Cousine Nerd Font" --noinput-text="Vide" -i "$file" --date-str="%A %e %B" > /dev/null 2>&1