forked from hkc/sfxd
1
0
Fork 0

Remade typewriter w/ a shellscript

src: https://git.gay/Micro/typewriter
This commit is contained in:
Casey 2024-04-21 21:45:57 +03:00
parent e9a2c969c0
commit b68a4b7ccb
Signed by: hkc
GPG Key ID: F0F6CFE11CDB0960
1 changed files with 38 additions and 0 deletions

38
contrib/typewriter.sh Normal file
View File

@ -0,0 +1,38 @@
#!/bin/bash
# XXX: CHANGEME
KEYBOARD_ID="AT Translated Set 2 keyboard"
b_isColon=false
KEY_ENTER=36
KEY_SEMICOLON=47
KEY_BACKSPACE=22
KEY_3=12
xinput test "$KEYBOARD_ID" | while read -r line; do
if [[ "$line" =~ "key press" ]]; then
keycode="$(echo "$line" | awk '{print$3}')"
case "$keycode" in
"$KEY_ENTER")
b_isColon=false;
sfxc play typewriter/pc_on;;
"$KEY_BACKSPACE")
b_isColon=false;
sfxc play typewriter/bwomp;;
"$KEY_SEMICOLON")
b_isColon=true;
sfxc play typewriter/text;;
"$KEY_3")
if [ "$b_isColon" = "true" ]; then
sfxc play typewriter/meow;
else
sfxc play typewriter/text;
fi;
;;
*)
b_isColon=false;
sfxc play typewriter/text;;
esac;
fi;
done