aboutsummaryrefslogtreecommitdiff
path: root/robot/robot.sh
blob: e013308351a4e63678ad2938b251b32b7dbc4696 (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
#!/bin/bash

## call find_bot to init this
window_id=

## This is the small sleep between key presses. Change for debugging
## when you are not sure what is happening
small_sleep=0.25
big_sleep=1

function sleep_small {
    sleep $small_sleep
}

function sleep_big {
    sleep $big_sleep
}

function send_answer {
    retn
    sleep_small
    key 5
    sleep_small
}

function launch_emacs {
    echo Launching $EMACS -Q -l $1 &
    $EMACS -Q -l $1 &
}

function kill_emacs {
    key alt+x
    command kill-emacs
    retn
}

function key {
    xdotool key --window $window_id $1
}

function command {
    xdotool type --window $window_id $1
}

function retn {
    xdotool key --window $window_id Return
}

function find_bot {
    window_id=`xdotool search --name "emacs-bot"`
    if [ -z "$window_id" ]
    then
        echo "Could not find window ID for Emacs-bot"
        exit 1
    fi
}