From b68a4b7ccbe36b435c6e1e5f810a41fcf4094fad Mon Sep 17 00:00:00 2001 From: hkc Date: Sun, 21 Apr 2024 21:45:57 +0300 Subject: [PATCH] Remade typewriter w/ a shellscript src: https://git.gay/Micro/typewriter --- contrib/typewriter.sh | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 contrib/typewriter.sh diff --git a/contrib/typewriter.sh b/contrib/typewriter.sh new file mode 100644 index 0000000..ea7041b --- /dev/null +++ b/contrib/typewriter.sh @@ -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