summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xCOPY-NEXT-LINE.sh24
-rw-r--r--README.md147
-rw-r--r--automatisier-lieblingstexte.sh25
-rw-r--r--yad-panel.sh60
4 files changed, 256 insertions, 0 deletions
diff --git a/COPY-NEXT-LINE.sh b/COPY-NEXT-LINE.sh
new file mode 100755
index 0000000..f424be3
--- /dev/null
+++ b/COPY-NEXT-LINE.sh
@@ -0,0 +1,24 @@
+#!/bin/dash
+LOG_FILE="$HOME/.contador.automatisiere-lieblingstexte.log"
+ARCHIVO_TXT=$(cat "$HOME/automatisiere-lieblingstexte/README.md" | grep 'mytext=' | awk -F"=" '{print $2}' | tr -d "'")
+
+if [ ! -f "$LOG_FILE" ]; then
+ echo 1 > "$LOG_FILE"
+fi
+
+CONTADOR=$(echo -n $(cat "$LOG_FILE"))
+
+# Asegúrate de que el contador sea mayor que 0
+if [ "$CONTADOR" -gt 0 ]; then
+ LINEA=$(sed "${CONTADOR}q;d" "$ARCHIVO_TXT")
+ if [ -n "$LINEA" ]; then
+ echo "$LINEA" | xclip -selection clipboard
+ echo -n "$LINEA" > "$HOME/.automatisiere-lieblingstexte.linea.actual.txt"
+ CONTADOR=$(expr "$CONTADOR" + 1)
+ echo "$CONTADOR" > "$LOG_FILE"
+ else
+ echo "No hay más líneas en $ARCHIVO_TXT"
+ fi
+else
+ echo "Contador no válido."
+fi
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
diff --git a/automatisier-lieblingstexte.sh b/automatisier-lieblingstexte.sh
new file mode 100644
index 0000000..15261b5
--- /dev/null
+++ b/automatisier-lieblingstexte.sh
@@ -0,0 +1,25 @@
+#!/bin/dash
+
+archivo=$(cat "$HOME/automatisiere-lieblingstexte/README.md" | grep 'mytext=' | awk -F"=" '{print $2}' | tr -d "'")
+
+if echo -n $1 | grep -q start; then
+ if [ -f "$archivo" ]; then
+ OLD=$(echo -n $(mktemp -u | cut -d. -f2))
+ mv "$archivo" "${archivo}.${OLD}.txt"
+ fi
+
+ # Abre una ventana de xterm que ejecuta "dash run"
+ if wmctrl -l | grep -qv 'Yad Icon panel'; then
+ sleep 1 && ( xdotool windowmove "$(xdotool search --name 'bash yad' | head -n 1)" 1247 536 && xdotool windowsize "$(xdotool search --name 'bash yad' | head -n 1)" 28 160 ) &
+ xterm -hold -e "bash $HOME/automatisiere-lieblingstexte/yad-panel.sh" &
+ fi
+fi
+
+if echo -n $1 | grep -q 'Z9SWsMuc89'; then
+ if [ -f $archivo ]; then
+ texto=$(echo -n "$archivo")
+ if [ -n "$texto" ]; then
+ xterm -hold -e "cd && sed -n '/^#!\/bin\/dash/,/```/p' \"$HOME/automatisiere-lieblingstexte/README.md\" | sed '/^```/d' | sed '/^$/d' > /tmp/automatisiere-lieblingstexte.tmp.sh && dash /tmp/automatisiere-lieblingstexte.tmp.sh" &
+ fi
+ fi
+fi \ No newline at end of file
diff --git a/yad-panel.sh b/yad-panel.sh
new file mode 100644
index 0000000..dee551d
--- /dev/null
+++ b/yad-panel.sh
@@ -0,0 +1,60 @@
+#!/bin/bash
+
+buttons() {
+ while wmctrl -l | grep -qv 'Yad Icon panel'; do
+ if [ -f "$HOME/.automatisiere-lieblingstexte.pause.switch" ]; then
+ yad --title="Yad Icon panel" \
+ --button="👍":0 --button="🔊":1 --button="🔁":2 \
+ --form \
+ --columns=1 \
+ --text "$(echo -n \"$(cat \\"$HOME/.automatisiere-lieblingstexte.linea.actual.txt\\")\")" \
+ --width=400 --posx=$(($(( $(xrandr --query | grep '*' | awk '{print $1}' | cut -d'x' -f1) )) - 400 - 20)) --posy=20
+ case $? in
+ 0)
+ [ -f "$HOME/.automatisiere-lieblingstexte.pause.switch" ] && rm "$HOME/.automatisiere-lieblingstexte.pause.switch" || touch "$HOME/.automatisiere-lieblingstexte.pause.switch"
+ ;;
+ 1)
+ sleep 0.2 && xdotool key Shift+Tab && sleep 0.1 && xdotool key space && sleep 0.7 && xdotool key e && sleep 0.5 && xdotool key space && sleep 0.4 && xdotool key Tab
+ ;;
+ 2)
+ sleep 0.2 && xdotool key control+r
+ ;;
+ esac
+ fi
+ done
+}
+
+# Primer YAD inicial
+texto=$(yad --center --width=500 --height=490 --title="Yad Icon panel" \
+ --button="👍":0 \
+ --text="Pega el texto que quieres estudiar o escribe editar para editar:" \
+ --editable --entry)
+
+case $? in
+ 0)
+ if [ -n "$texto" ]; then
+ archivo=$(cat "$HOME/automatisiere-lieblingstexte/README.md" | grep 'mytext=' | awk -F"=" '{print $2}' | tr -d "'")
+ if [ ! -f "$archivo" ] || ! diff -q <(echo "$texto") "$archivo" > /dev/null; then
+ echo "$texto" > "$archivo"
+ echo "Ok"
+ # Empieza el bucle, pasándole el texto inicial
+ l3afpad $archivo &
+ yad --width=500 --height=490 \
+ --center --title="Listo para empezar" \
+ --button="👍":0 \
+ --text="Puedes modificar el texto ...o si ya está todo listo empezemos!"
+
+ case $? in
+ 0)
+ bash "$HOME/automatisiere-lieblingstexte/yad-panel.sh" 'Z9SWsMuc89'
+ ;;
+ esac
+ buttons
+ else
+ echo "No upd"
+ fi
+ else
+ echo "Nada"
+ fi
+ ;;
+esac