aboutsummaryrefslogtreecommitdiffhomepage
path: root/examples/data/scripts/follow.sh
blob: 4edab36d1e1e38e6447bb1d7482efaed88f8307b (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
#!/bin/sh

# This script is just a wrapper around follow.js that lets us change uzbl's mode
# after a link is selected.

. "$UZBL_UTIL_DIR/uzbl-util.sh"

keys="$1"
shift

# if socat is installed then we can change Uzbl's input mode once a link is
# selected; otherwise we just select a link.
if ! which socat >/dev/null 2>&1; then
    print "script @scripts_dir/follow.js \"@{follow_hint_keys} $keys\"\n" > "$UZBL_FIFO"
    exit 0
fi

result="$( print "script @scripts_dir/follow.js \"@{follow_hint_keys} $keys\"\n" | socat - "unix-connect:$UZBL_SOCKET" )"
case $result in
    *XXXEMIT_FORM_ACTIVEXXX*)
        # a form element was selected
        print "event FORM_ACTIVE\n" > "$UZBL_FIFO"
        ;;
    *XXXRESET_MODEXXX*)
        # a link was selected, reset uzbl's input mode
        print "set mode=\n" > "$UZBL_FIFO"
        ;;
esac