summaryrefslogtreecommitdiff
path: root/README.md
diff options
context:
space:
mode:
authorsrv <enmanuel.saravia.externo@pandero.com.pe>2025-05-06 01:40:23 -0500
committersrv <enmanuel.saravia.externo@pandero.com.pe>2025-05-06 01:40:23 -0500
commit300b5c13668f24a3a50ddd98ece18fce856f5269 (patch)
tree77f62212c75544a6575e88288c0f53b6d0268068 /README.md
First commit, ready for the first test in a virtual machine
Diffstat (limited to 'README.md')
-rw-r--r--README.md147
1 files changed, 147 insertions, 0 deletions
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..3445e07
--- /dev/null
+++ b/README.md
@@ -0,0 +1,147 @@
+# Requeriments
+
+xsel, xclip, herbe, xdotool, dash, l3afpad, yad
+
+cd && sed -n '/^#!\/bin\/dash/,/```/p' automatisiere-lieblingstexte/README.md | sed '/^```/d' | sed '/^$/d' > /tmp/automatisiere-lieblingstexte.tmp.sh && dash /tmp/automatisiere-lieblingstexte.tmp.sh
+
+Nota echo -n 1 debe comentar en uno para el contador.tt.log
+
+```
+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-NEXLINE.sh"
+Comando ^1 ^setxkbmap us
+Comando ^1 ^PORTAPAPELES=$(xsel -b -o) && 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.
+```
+
+```
+1 Empieza reproducir:
+Comando ^1 ^pgrep herbe > /dev/null && ( pgrep herbe | xargs doas kill )
+Comando ^1 ^herbe 'Automatisiere Lieblingstexte fertig'
+1 Termina reproducir.
+```
+
+# Parte que se auto ejecuta
+
+```
+#!/bin/dash
+mytext='$HOME/automatisiere-lieblingstexte-der-texte.txt'
+if [ ! -f $mytext ]; then
+ exit 0
+fi
+SLEEP='sleep 0.2'
+pgrep herbe > /dev/null && ( pgrep herbe | xargs doas kill )
+sleep 1 && ( pgrep herbe > /dev/null && ( pgrep herbe | xargs doas kill ) )
+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"
+``` \ No newline at end of file