commit dcd87d509a91599a1a834924a15ad6a23817882b Author: bad Date: Sat Sep 11 17:41:58 2021 +0200 Initial commit diff --git a/antisub.sh b/antisub.sh new file mode 100755 index 0000000..f0e5ae8 --- /dev/null +++ b/antisub.sh @@ -0,0 +1,43 @@ +#!/usr/bin/env bash +max_speed=20 +function handleKeys() { + input_time=$(($(date +%s%N)/1000)) + while true; do + + end=$(($input_time + 1000000)) + inputs=0 + + while [[ "$input_time" -lt "$end" ]]; do + time_sec=$(od -An -t u8 -N 8) + time_ms=$(od -An -t u8 -N 8) + + # Time of the input in usec + input_time=$(($time_ms+$time_sec*1000000)) + + key_type=$(od -An -t u2 -N 2) + code=$(od -An -t u2 -N 2) + value=$(od -An -t u4 -N 4) + + if [[ $key_type -eq 1 ]]; then + if [[ $value -eq 1 ]]; then + inputs=$(($inputs+1)) + fi + fi + done + echo "--------------------------------" + echo $inputs over the last second + if [[ $inputs -gt $max_speed ]]; then + if [ -z "$var" ]; then + swaylock -c 000000 -i "./whatthefuckispleadingface.jpg" -s fit + else + # Haven'y actually tested outside of sway but it should work + output=$(mktemp XXXXXXXX.jpg) + convert -resize $(xdpyinfo | grep dimensions | cut -d\ -f7 | cut -dx -f1) "./whatthefuckispleadingface.jpg" "$output" + i3lock -c 000000 -i "$output" + fi + + fi +done; +} + +sudo cat /dev/input/event0 | handleKeys diff --git a/whatthefuckispleadingface.jpg b/whatthefuckispleadingface.jpg new file mode 100644 index 0000000..6db7889 Binary files /dev/null and b/whatthefuckispleadingface.jpg differ