summaryrefslogtreecommitdiff
path: root/yad-panel.sh
blob: 095b0834dfc9f4b35123250715da111f63b14eed (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
#!/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/run.sh" 'Z9SWsMuc89'
			;;
		esac
		buttons
            else
                echo "No upd"
            fi
        else
            echo "Nada"
        fi
        ;;
esac