blob: 944c5e8673cf324d9b88a3b63dbe1ca7408a5f15 (
plain)
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
|
# Automatisiere Lieblingstexte
## Requeriments
You need first install
sudo apt install git xsel xclip xdotool dash l3afpad yad wmctrl
Close session, try to login with the setting xorg, and reboot
You now are in xorg mode, how are you now for example run
sleep 1s && xdotool mousemove 500 600 click 1
^ that was change your cursor position? so, you are ready
Nota echo -n 1 debe comenzar en 1 el archivo $HOME/.contador.automatisiere-lieblingstexte.log
## How to install
cd && git clone http://saravia.org/automatisiere-lieblingstexte.git
## How to run
bash "$HOME/automatisiere-lieblingstexte/run.sh" start
```
1 Empieza reproducir:
Comando ^1 ^echo -n 1 > "$HOME/.contador.automatisiere-lieblingstexte.log"
1 Termina reproducir.
```
```
1 Empieza reproducir:
Comando ^1 ^touch "$HOME/.automatisiere-lieblingstexte.pause.switch" && while [ -f "$HOME/.automatisiere-lieblingstexte.pause.switch" ]; do sleep 0.1; done
1 Termina reproducir.
```
```
0 Empieza reproducir:
Comando ^1 ^dash "$HOME/automatisiere-lieblingstexte/COPY-NEXT-LINE.sh"
Comando ^1 ^setxkbmap us
Comando ^1 ^PORTAPAPELES=$(xsel -b -o) && xdotool mousemove 500 600 click 1 && xdotool type "Traduce la siguiente frase al alemán de Alemania, nivel A1, como si lo dijera un niño. Solo quiero la traducción en una línea, sin usar palabras en español, sin explicaciones. No reutilices palabras del español. Máximo 280 caracteres. Frase: $PORTAPAPELES"
Comando ^1 ^setxkbmap latam
Comando ^1 ^sleep 0.7
Keyboard ^1 ^Return
Comando ^1 ^touch "$HOME/.automatisiere-lieblingstexte.pause.switch" && while [ -f "$HOME/.automatisiere-lieblingstexte.pause.switch" ]; do sleep 0.1; done
0 Termina reproducir.
```
# Parte que se auto ejecuta
```
#!/bin/dash
mytext='/tmp/automatisiere-lieblingstexte-der-texte.txt'
if [ ! -f $mytext ]; then
exit 0
fi
SLEEP='sleep 0.2'
echo "Empieza a las $(date +'%Y%m%d%H%M%S')" >> $HOME/.automatisiere-lieblingstexte.log
label=$(date +'%Y%m%d%H%M%S')
archivo="$HOME/automatisiere-lieblingstexte/README.md"
Mouse() {
$SLEEP
case "$1" in
*w*) xdotool mousemove_relative -- 0 -11 ;;
*a*) xdotool mousemove_relative -- -11 0 ;;
*c*) xdotool mousemove_relative -- 11 11 ;;
*d*) xdotool mousemove_relative -- 11 0 ;;
*f*) xdotool click 1 ;;
*z*) xdotool mousemove_relative -- -8 8 ;;
*m*) xdotool click --repeat 3 5 ;;
*q*) xdotool mousemove_relative -- -11 -11 ;;
*x*) xdotool mousemove_relative -- 0 11 ;;
esac
}
Keyboard() {
$SLEEP
echo "xdotool key $1"
xdotool key "$1"
}
Comando() {
$SLEEP
echo $1
eval $1
}
porcion() {
local input="$1"
local first_value=$(echo "$input" | awk '{print $1}')
local param1=$(echo "$input" | awk -F'^' '{print $2}' | tr -d '[:space:]')
local param2=$(echo "$input" | awk -F'^' '{print $3}' | tr -d '^')
if [ -n "$param1" ] && [ -n "$param2" ]; then
echo "$param1" | grep -Eq '^[0-9]+$' || {
echo "ERROR: param1 debe ser un número entero positivo."
return 1
}
param1=$((param1))
case "$first_value" in
"Mouse")
i=0
while [ $i -lt $param1 ]; do
Mouse "$param2"
i=$((i + 1))
done
;;
"Keyboard")
i=0
while [ $i -lt $param1 ]; do
Keyboard "$param2"
i=$((i + 1))
done
;;
"Comando")
i=0
while [ $i -lt $param1 ]; do
Comando "$param2"
i=$((i + 1))
done
;;
*)
echo "ERROR: Comando no reconocido: $first_value"
;;
esac
fi
}
while IFS= read -r linea; do
echo 'DEBUG: '$linea
if echo "$linea" | grep -Eq "^[0-9]+\ Empieza\ reproducir\:"; then
N=$(echo "$linea" | awk '{ print $1 }')
bloque=""
while IFS= read -r sub_linea; do
echo "$sub_linea" | grep -Eq "^${N}\ Termina\ reproducir\." && break
bloque="${bloque}${sub_linea}\n"
done
if [ "$N" -eq 0 ]; then
if [ -f $mytext ]; then
line_count=$(wc -l < $mytext | tr -d '[:space:]')
echo "$line_count" | grep -Eq '^[0-9]+$' && N=$((line_count + 1)) || N=1
else
N=1
fi
else
N=1
fi
i=0
while [ $i -lt $N ]; do
echo "$bloque" | while IFS= read -r linea_bloque; do
[ -n "$linea_bloque" ] && porcion "$linea_bloque"
done
i=$((i + 1))
done
fi
done < "$archivo"
echo "Termina a las $(date +'%Y%m%d%H%M%S')" >> "$HOME/.automatisiere-lieblingstexte.log"
```
|