sfxd/contrib/typewriter.sh

40 lines
1.3 KiB
Bash

#!/bin/bash
# XXX: CHANGEME
KEYBOARD_ID="AT Translated Set 2 keyboard"
b_isColon=false
xinput test "$KEYBOARD_ID" | while read -r line; do
if [[ "$line" =~ "key press" ]]; then
keycode="$(echo "$line" | awk '{print$3}')"
case "$keycode" in
36) # enter
b_isColon=false;
echo play typewriter/pc_on;; # OneShot:SE/pc_on.wav
22) # backspace
b_isColon=false;
echo play typewriter/bwomp;;
111 | 113 | 114 |116) # arrows
b_isColon=false;
echo play typewriter/arrow;; # OneShot:SE/menu_cursor.wav
112 | 117) # page up / page down
b_isColon=false;
echo play typewriter/page;; # OneShot:SE/page.wav
47) # ":"
b_isColon=true;
echo play typewriter/text;; # OneShot:SE/text.wav
12) # "3"
if [ "$b_isColon" = "true" ]; then
echo play typewriter/meow; # Minecraft:entity.cat.meow
else
echo play typewriter/text; # OneShot:SE/text.wav
fi;
;;
*)
b_isColon=false;
echo play typewriter/text;; # OneShot:SE/text.wav
esac;
fi;
done | sfxc