-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathp2000-xdo.sh
56 lines (52 loc) · 2.33 KB
/
p2000-xdo.sh
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
56
#https://gitlab.com/cunidev/gestures/-/wikis/xdotool-list-of-key-codes
#https://www.ascii-code.com/
echo sleep 5
#added so an enter is typed for the first line
oldnumber=yes
cat $1 |\
while read line
do
linenumber=$(echo "$line"|cut -d" " -f1)
[[ $linenumber =~ ^[0-9]+$ ]] && number=yes || number=no
[[ $oldnumber == yes ]] && [[ $number == yes ]] && echo xdotool keydown "Return" sleep 0.05 keyup "Return" sleep 0.05
[[ $oldnumber == no ]] && [[ $number == yes ]] && echo xdotool keydown "Return" sleep 0.05 keyup "Return" sleep 0.05
#[[ $oldnumber == no ]] && [[ $number == no ]] && echo "skip enter"
[[ -z $line ]] && echo xdotool sleep 0.05 keydown "Return" sleep 0.05 keyup "Return" sleep 0.05
#replace space with underscore
line="$(echo "$line"|sed 's/ /_/g')"
echo "$line"|while read -n 1 char
do
char=${char,,} #char to lowercase
[[ $char == '_' ]] && char=space #space (underscore is space)
[[ $char == '$' ]] && char="Shift + 4"
[[ $char == ',' ]] && char=comma
[[ $char == '.' ]] && char=period
[[ $char == '&' ]] && char="Shift + 6" # ampersand
[[ $char == '+' ]] && char="Shift + semicolon" # plus
[[ $char == "=" ]] && char="Shift + 0" # equals
[[ $char == '"' ]] && char="Shift + 2" # quotedbl
[[ $char == '>' ]] && char="Shift + Delete" # greater
[[ $char == '<' ]] && char=Delete # less
[[ $char == '(' ]] && char="Shift + 8" #asterisk # parenleft
[[ $char == ')' ]] && char="Shift + 9" #parenleft # parenright
[[ $char == ';' ]] && char=semicolon
[[ $char == ':' ]] && char=quoteright #colon
[[ $char == '-' ]] && char=minus #colon
[[ $char == '*' ]] && char="Shift + apostrophe" #asterisk
#[[ $char == '/' ]] && char=0x002f #slash
[[ $char == '/' ]] && char=slash
[[ $char == '?' ]] && char="Shift + slash" #question
[[ $char == '!' ]] && char="Shift + 1" #exclamdown
[[ $char == '`' ]] && char="Shift + 7"
[[ $char == '%' ]] && char="Shift + 5"
[[ $char == '#' ]] && char="Shift + backslash" #numbersign
#'~'
#'}'
output="$(echo "$char"|sed "s/Shift + //g")"
[[ -n $output ]] && echo xdotool sleep 0.05 $([[ $char == Shift* ]]&& echo keydown Shift sleep 0.05) keydown "$output" sleep 0.05 keyup "$output" sleep 0.05 $([[ $char == Shift* ]]&& echo keyup Shift sleep 0.05)
done
linenumber=$(echo "$line"|cut -d" " -f1)
[[ $linenumber =~ ^[0-9]+$ ]] && oldnumber=yes || oldnumber=no
#echo xdotool keydown "Return" sleep 0.05 keyup "Return" sleep 0.05
#sleep 2
done