summaryrefslogtreecommitdiffstats
path: root/layouts/community/ergodox/algernon/tools/hid-commands
blob: 54ca7556ab9aa2e86c2b4289aebdc24b3ac137a7 (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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#!/bin/bash
set -e

LAST_APPSEL_START=0

cmd_wm () {
    WIN="$(xdotool getactivewindow)"
    wmctrl -i -r ${WIN} -b remove,maximized_vert,maximized_horz
    xdotool windowsize ${WIN} 100% 100%
    wmctrl -i -r ${WIN} -b add,maximized_vert,maximized_horz
}

_cmd_appsel () {
    wmctrl -x -a $1 || true
    xdotool key Escape
}

cmd_appsel_music () {
    wmctrl -x -a rhythmbox || wmctrl -x -a spotify || \
        wmctrl -x -a banshee || wmctrl -x -a kodi || true
    xdotool key Escape
}

cmd_appsel_slack () {
    _cmd_appsel slack
}

cmd_appsel_emacs () {
    _cmd_appsel emacs
}

cmd_appsel_term () {
    _cmd_appsel gnome-terminal
}

cmd_appsel_chrome () {
    _cmd_appsel chrom
}

cmd_appsel_start () {
    if [ ! -z "${DISABLE_APPSEL_START}" ]; then
        return
    fi

    APPSEL_START=$(date +%s)
    if [ $APPSEL_START -lt $(expr $LAST_APPSEL_START + 10) ]; then
        return
    fi
    LAST_APPSEL_START=$APPSEL_START
    notify-send -t 1000 "Please select an application!" -c device -u low \
                -i /usr/share/icons/Adwaita/24x24/devices/video-display.png
}

cmd_reflash () {
    teensy_loader_cli -v -w ~/src/ext/qmk_firmware/algernon.hex --mcu atmega32u4 || true
}

cmd_help () {
    cat <<EOF
Use the source, Luke!
EOF
}

while read l; do
    case "$l" in
        "CMD:"*)
            ;;
        *)
            continue
            ;;
    esac

    cmd="$(echo $l | cut -d: -f2-)"

    echo "Got command: ${cmd}"

    if type cmd_${cmd} >/dev/null 2>&1; then
        cmd_${cmd}
    fi
done