]> git.donarmstrong.com Git - qmk_firmware.git/blob - layouts/community/ergodox/algernon/tools/hid-commands
ergodox: Update algernon's layout to v1.11
[qmk_firmware.git] / layouts / community / ergodox / algernon / tools / hid-commands
1 #!/bin/bash
2 set -e
3
4 LAST_APPSEL_START=0
5
6 cmd_wm () {
7     WIN="$(xdotool getactivewindow)"
8     wmctrl -i -r ${WIN} -b remove,maximized_vert,maximized_horz
9     xdotool windowsize ${WIN} 100% 100%
10     wmctrl -i -r ${WIN} -b add,maximized_vert,maximized_horz
11 }
12
13 cmd_appsel_helper () {
14     rofi -show window
15 }
16
17 _cmd_appsel () {
18     wmctrl -x -a $1 || true
19     xdotool key Escape
20 }
21
22 cmd_appsel_music () {
23     wmctrl -x -a rhythmbox || wmctrl -x -a spotify || \
24         wmctrl -x -a banshee || wmctrl -x -a kodi || \
25         wmctrl -x -a plex || true
26     xdotool key Escape
27 }
28
29 cmd_appsel_slack () {
30     wmctrl -x -a slack || wmctrl -x -a Mstdn || true
31     xdotool key Escape
32 }
33
34 cmd_appsel_emacs () {
35     _cmd_appsel emacs
36 }
37
38 cmd_appsel_term () {
39     _cmd_appsel gnome-terminal
40 }
41
42 cmd_appsel_chrome () {
43     wmctrl -x -a chrom || wmctrl -x -a Chrome || true
44     xdotool key Escape
45 }
46
47 cmd_appsel_start () {
48     if [ ! -z "${DISABLE_APPSEL_START}" ]; then
49         return
50     fi
51
52     APPSEL_START=$(date +%s)
53     if [ $APPSEL_START -lt $(expr $LAST_APPSEL_START + 10) ]; then
54         return
55     fi
56     LAST_APPSEL_START=$APPSEL_START
57     notify-send -t 1000 "Please select an application!" -c device -u low \
58                 -i /usr/share/icons/Adwaita/24x24/devices/video-display.png
59 }
60
61 cmd_appsel_social () {
62     # Save the current window
63     a=$(xdotool getactivewindow)
64     # Raise & Focus Mstdn & Tweetdeck
65     wmctrl -x -a trunk.mad-scientist.club.Google-chrome || true; wmctrl -x -a tweetdeck || true
66     # Focus the previously active window
67     xdotool windowfocus $a || true; xdotool windowactivate $a || true
68
69     xdotool key Escape
70 }
71
72 cmd_appsel_social2 () {
73     # Save the current window
74     a=$(xdotool getactivewindow)
75     # Raise & Focus Viber & Signal
76     wmctrl -x -a Viber || true; wmctrl -a Signal || true
77     # Focus the previously active window
78     xdotool windowfocus $a || true; xdotool windowactivate $a || true
79
80     xdotool key Escape
81 }
82
83 cmd_appsel_pwmgr () {
84     _cmd_appsel keepass
85 }
86
87 cmd_reflash () {
88     teensy_loader_cli -v -w ~/src/ext/qmk_firmware/algernon.hex --mcu atmega32u4 || true
89 }
90
91 cmd_help () {
92     cat <<EOF
93 Use the source, Luke!
94 EOF
95 }
96
97 while read l; do
98     case "$l" in
99         "CMD:"*)
100             ;;
101         *)
102             continue
103             ;;
104     esac
105
106     cmd="$(echo $l | cut -d: -f2-)"
107
108     echo "Got command: ${cmd}"
109
110     if type cmd_${cmd} >/dev/null 2>&1; then
111         cmd_${cmd}
112     fi
113 done