-
Notifications
You must be signed in to change notification settings - Fork 12
/
init_zmk.sh
executable file
·172 lines (148 loc) · 14.4 KB
/
init_zmk.sh
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
#!/bin/bash
KEYBOARD_HOME="$(pwd)"
ZMK_MODULE="modules/rafaelromao/zmk"
RGBWIDGET_MODULE="modules/caksoylar/zmk-rgbled-widget"
DONGLE_MODULE="modules/englmaxi/zmk-dongle-display"
AUTOLAYER_MODULE="modules/urob/zmk-auto-layer"
ANTECEDENT_MODULE="modules/ssbb/zmk-antecedent-morph"
export ZMK_HOME="$KEYBOARD_HOME/$ZMK_MODULE"
RGBWIDGET_HOME="$KEYBOARD_HOME/$RGBWIDGET_MODULE"
DONGLE_HOME="$KEYBOARD_HOME/$DONGLE_MODULE"
AUTOLAYER_HOME="$KEYBOARD_HOME/$AUTOLAYER_MODULE"
ANTECEDENT_HOME="$KEYBOARD_HOME/$ANTECEDENT_MODULE"
BEHAVIOR_MODULES=""
if [[ ! -d "$DONGLE_HOME" ]]
then
echo "Add git sub-modules..."
git submodule add -f https://github.com/englmaxi/zmk-dongle-display $DONGLE_MODULE
fi
if [[ ! -d "$RGBWIDGET_HOME" ]]
then
echo "Add git sub-modules..."
git submodule add -f https://github.com/caksoylar/zmk-rgbled-widget $RGBWIDGET_MODULE
fi
if [[ ! -d "$ANTECEDENT_HOME" ]]
then
echo "Add git sub-modules..."
git submodule add -f https://github.com/ssbb/zmk-antecedent-morph $ANTECEDENT_MODULE
fi
if [[ ! -d "$AUTOLAYER_HOME" ]]
then
echo "Add git sub-modules..."
git submodule add -f https://github.com/urob/zmk-auto-layer $AUTOLAYER_MODULE
fi
INIT=false
if [[ ! -d "$ZMK_HOME/.west" ]]
then
INIT=true
echo "Add git sub-modules..."
git submodule add -f https://github.com/rafaelromao/zmk $ZMK_MODULE
fi
echo "Update git sub-modules..."
git submodule sync --recursive
git submodule update --init --recursive --progress
clean_zmk="rm -rf $KEYBOARD_HOME/modules/rafaelromao/zmk/build"
checkout_main_zmk="echo 'Cleaning zmk...'; ${clean_zmk} ; echo 'Checking out main zmk...'; cd $ZMK_HOME; git fetch; git checkout -f 20240328/rafaelromao/main; git pull; cd $KEYBOARD_HOME"
checkout_wired_zmk="echo 'Cleaning zmk...'; ${clean_zmk} ; echo 'Checking out wired zmk...'; cd $ZMK_HOME; git fetch; git checkout -f 20240328/rafaelromao/wired-split; git pull; cd $KEYBOARD_HOME"
if [[ "${INIT}" == "true" ]]
then
echo "Initializing West..."
cd $ZMK_HOME
west init -l app/
west update
west zephyr-export
cd $KEYBOARD_HOME
fi
echo "Exporting Zephyr Toolchain..."
cd $ZMK_HOME
unset ZEPHYR_TOOLCHAIN_VARIANT
unset GNUARMEMB_TOOLCHAIN_PATH
export ZEPHYR_SDK_INSTALL_DIR=~/zephyr-sdk-0.16.3
cd $KEYBOARD_HOME
echo "Creating Testpad build alias..."
build_testpad_unibody="west build -s app -b seeeduino_xiao_ble --build-dir build/testpad -- -DSHIELD='testpad rgbled_adapter' -DZMK_CONFIG=$KEYBOARD_HOME/src/zmk/keyboards/testpad -DZMK_EXTRA_MODULES=$RGBWIDGET_HOME"
archive_testpad_unibody="mkdir -p $KEYBOARD_HOME/build/artifacts; [ -f build/testpad/zephyr/zmk.uf2 ] && mv -f build/testpad/zephyr/zmk.uf2 $KEYBOARD_HOME/build/artifacts/testpad-zmk.uf2"
alias build_testpad="cd ${ZMK_HOME} && ${build_testpad_unibody} && ${archive_testpad_unibody} && cd $KEYBOARD_HOME"
echo "Creating Reset build alias..."
build_reset_unibody="west build -s app -b nice_nano_v2 --build-dir build/reset -- -DSHIELD='settings_reset'"
archive_reset_unibody="mkdir -p $KEYBOARD_HOME/build/artifacts; [ -f build/reset/zephyr/zmk.uf2 ] && mv -f build/reset/zephyr/zmk.uf2 $KEYBOARD_HOME/build/artifacts/reset-zmk.uf2"
alias build_reset="${checkout_main_zmk} && cd ${ZMK_HOME} && ${build_reset_unibody} && ${archive_reset_unibody} && cd $KEYBOARD_HOME"
echo "Creating Zen build alias..."
build_zen_left="west build -s app -b corneish_zen_v2_left --build-dir build/corneish_zen_left -- -DZMK_CONFIG=$KEYBOARD_HOME/src/zmk/keyboards/lowprokb.ca/corneish-zen -DZMK_EXTRA_MODULES='$BEHAVIOR_MODULES'"
build_zen_right="west build -s app -b corneish_zen_v2_right --build-dir build/corneish_zen_right -- -DZMK_CONFIG=$KEYBOARD_HOME/src/zmk/keyboards/lowprokb.ca/corneish-zen -DZMK_EXTRA_MODULES='$BEHAVIOR_MODULES'"
archive_zen_left="mkdir -p $KEYBOARD_HOME/build/artifacts; [ -f build/corneish_zen_left/zephyr/zmk.uf2 ] && mv -f build/corneish_zen_left/zephyr/zmk.uf2 $KEYBOARD_HOME/build/artifacts/corneish_zen_v2_left-zmk.uf2"
archive_zen_right="mkdir -p $KEYBOARD_HOME/build/artifacts; [ -f build/corneish_zen_right/zephyr/zmk.uf2 ] && mv -f build/corneish_zen_right/zephyr/zmk.uf2 $KEYBOARD_HOME/build/artifacts/corneish_zen_v2_right-zmk.uf2"
alias build_zen_all="cd ${ZMK_HOME} && ${build_zen_left} && ${archive_zen_left} && ${build_zen_right} && ${archive_zen_right} && cd ${KEYBOARD_HOME}"
alias build_zen="${checkout_main_zmk} && cd ${ZMK_HOME} && ${build_zen_left} && ${archive_zen_left} && cd ${KEYBOARD_HOME}"
echo "Creating Rommana build alias..."
build_rommana_unibody="west build -s app -b seeeduino_xiao_rp2040 --build-dir build/rommana -- -DSHIELD='rommana' -DZMK_CONFIG=$KEYBOARD_HOME/src/zmk/keyboards/rommana -DZMK_EXTRA_MODULES='$BEHAVIOR_MODULES'"
archive_rommana_unibody="mkdir -p $KEYBOARD_HOME/build/artifacts; [ -f build/rommana/zephyr/zmk.uf2 ] && mv -f build/rommana/zephyr/zmk.uf2 $KEYBOARD_HOME/build/artifacts/rommana-zmk.uf2"
alias build_rommana="${checkout_main_zmk} && cd ${ZMK_HOME} && ${build_rommana_unibody} && ${archive_rommana_unibody} && cd $KEYBOARD_HOME"
echo "Creating Cygnus build alias..."
build_cygnus_left="west build -s app -b nice_nano_v2 --build-dir build/cygnus_left -- -DSHIELD='cygnus_left' -DZMK_CONFIG=$KEYBOARD_HOME/src/zmk/keyboards/cygnus -DZMK_EXTRA_MODULES='$BEHAVIOR_MODULES'"
build_cygnus_right="west build -s app -b nice_nano_v2 --build-dir build/cygnus_right -- -DSHIELD='cygnus_right' -DZMK_CONFIG=$KEYBOARD_HOME/src/zmk/keyboards/cygnus -DZMK_EXTRA_MODULES='$BEHAVIOR_MODULES'"
archive_cygnus_left="mkdir -p $KEYBOARD_HOME/build/artifacts; [ -f build/cygnus_left/zephyr/zmk.uf2 ] && mv -f build/cygnus_left/zephyr/zmk.uf2 $KEYBOARD_HOME/build/artifacts/cygnus_left-zmk.uf2"
archive_cygnus_right="mkdir -p $KEYBOARD_HOME/build/artifacts; [ -f build/cygnus_right/zephyr/zmk.uf2 ] && mv -f build/cygnus_right/zephyr/zmk.uf2 $KEYBOARD_HOME/build/artifacts/cygnus_right-zmk.uf2"
alias build_cygnus_all="${checkout_main_zmk} && cd ${ZMK_HOME} && ${build_cygnus_left} && ${archive_cygnus_left} && ${build_cygnus_right} && ${archive_cygnus_right} && cd ${KEYBOARD_HOME}"
alias build_cygnus="${checkout_main_zmk} && cd ${ZMK_HOME} && ${build_cygnus_left} && ${archive_cygnus_left} && cd $KEYBOARD_HOME"
echo "Creating Diamond build alias..."
build_diamond_central_dongle="west build -s app -b nice_nano_v2 --build-dir build/diamond_central_dongle -- -DSHIELD='diamond_central_dongle dongle_display' -DZMK_CONFIG=$KEYBOARD_HOME/src/zmk/keyboards/diamond -DZMK_EXTRA_MODULES='$DONGLE_HOME;$BEHAVIOR_MODULES'"
build_diamond_central_left="west build -s app -b nice_nano_v2 --build-dir build/diamond_central_left -- -DSHIELD='diamond_central_left' -DZMK_CONFIG=$KEYBOARD_HOME/src/zmk/keyboards/diamond -DZMK_EXTRA_MODULES='$BEHAVIOR_MODULES'"
build_diamond_peripheral_left="west build -s app -b nice_nano_v2 --build-dir build/diamond_peripheral_left -- -DSHIELD='diamond_peripheral_left' -DZMK_CONFIG=$KEYBOARD_HOME/src/zmk/keyboards/diamond -DZMK_EXTRA_MODULES='$BEHAVIOR_MODULES'"
build_diamond_peripheral_right="west build -s app -b nice_nano_v2 --build-dir build/diamond_peripheral_right -- -DSHIELD='diamond_peripheral_right' -DZMK_CONFIG=$KEYBOARD_HOME/src/zmk/keyboards/diamond -DZMK_EXTRA_MODULES='$BEHAVIOR_MODULES'"
archive_diamond_central_dongle="mkdir -p $KEYBOARD_HOME/build/artifacts; [ -f build/diamond_central_dongle/zephyr/zmk.uf2 ] && mv -f build/diamond_central_dongle/zephyr/zmk.uf2 $KEYBOARD_HOME/build/artifacts/diamond_central_dongle-zmk.uf2"
archive_diamond_central_left="mkdir -p $KEYBOARD_HOME/build/artifacts; [ -f build/diamond_central_left/zephyr/zmk.uf2 ] && mv -f build/diamond_central_left/zephyr/zmk.uf2 $KEYBOARD_HOME/build/artifacts/diamond_central_left-zmk.uf2"
archive_diamond_peripheral_left="mkdir -p $KEYBOARD_HOME/build/artifacts; [ -f build/diamond_peripheral_left/zephyr/zmk.uf2 ] && mv -f build/diamond_peripheral_left/zephyr/zmk.uf2 $KEYBOARD_HOME/build/artifacts/diamond_peripheral_left-zmk.uf2"
archive_diamond_peripheral_right="mkdir -p $KEYBOARD_HOME/build/artifacts; [ -f build/diamond_peripheral_right/zephyr/zmk.uf2 ] && mv -f build/diamond_peripheral_right/zephyr/zmk.uf2 $KEYBOARD_HOME/build/artifacts/diamond_peripheral_right-zmk.uf2"
alias build_diamond_all="${checkout_main_zmk} && cd ${ZMK_HOME} && ${build_diamond_central_left} && ${archive_diamond_central_left} && ${build_diamond_central_dongle} && ${archive_diamond_central_dongle} && ${build_diamond_peripheral_left} && ${archive_diamond_peripheral_left} && ${build_diamond_peripheral_right} && ${archive_diamond_peripheral_right} && cd ${KEYBOARD_HOME}"
alias build_diamond="${checkout_main_zmk} && cd ${ZMK_HOME} && ${build_diamond_central_left} && ${archive_diamond_central_left} && cd $KEYBOARD_HOME"
echo "Creating Wired Diamond build alias..."
build_wired_diamond_left="west build -p -s app -b seeeduino_xiao_rp2040 --build-dir build/wired_diamond_left -- -DSHIELD='wired_diamond_left' -DZMK_CONFIG=$KEYBOARD_HOME/src/zmk/keyboards/wired_diamond -DZMK_EXTRA_MODULES='$BEHAVIOR_MODULES'"
build_wired_diamond_right="west build -p -s app -b seeeduino_xiao_rp2040 --build-dir build/wired_diamond_right -- -DSHIELD='wired_diamond_right' -DZMK_CONFIG=$KEYBOARD_HOME/src/zmk/keyboards/wired_diamond -DZMK_EXTRA_MODULES='$BEHAVIOR_MODULES'"
archive_wired_diamond_left="mkdir -p $KEYBOARD_HOME/build/artifacts; [ -f build/wired_diamond_left/zephyr/zmk.uf2 ] && mv -f build/wired_diamond_left/zephyr/zmk.uf2 $KEYBOARD_HOME/build/artifacts/wired_diamond_left-zmk.uf2"
archive_wired_diamond_right="mkdir -p $KEYBOARD_HOME/build/artifacts; [ -f build/wired_diamond_right/zephyr/zmk.uf2 ] && mv -f build/wired_diamond_right/zephyr/zmk.uf2 $KEYBOARD_HOME/build/artifacts/wired_diamond_right-zmk.uf2"
alias build_wired_diamond_all="${checkout_wired_zmk} && cd ${ZMK_HOME} && ${build_wired_diamond_left} && ${archive_wired_diamond_left} && ${build_wired_diamond_right} && ${archive_wired_diamond_right} && cd ${KEYBOARD_HOME}"
alias build_wired_diamond="${checkout_wired_zmk} && cd ${ZMK_HOME} && ${build_wired_diamond_left} && ${archive_wired_diamond_left} && cd $KEYBOARD_HOME"
echo "Creating Keymap Drawer alias..."
prepare_tmp="mkdir -p ./tmp ; mkdir -p ./tmp"
prepare_no_separate_combos="\cp ./docs/keymap-drawer/keymap-drawer.yaml ./tmp/keymap-drawer-noseparatecombos.yaml"
prepare_only_separate_combos="\cp ./docs/keymap-drawer/keymap-drawer.yaml ./tmp/keymap-drawer-onlyseparatecombos.yaml"
prepare_only_vim_combos="\cp ./docs/keymap-drawer/keymap-drawer.yaml ./tmp/keymap-drawer-onlyvimcombos.yaml"
prepare_custom="\cp ./docs/keymap-drawer/keymap-drawer-custom.yaml ./tmp/keymap-drawer-custom.yaml"
write_no_separate_combos="yq -i 'del(.combos[] | select(.draw_separate == true))' ./tmp/keymap-drawer-noseparatecombos.yaml"
write_only_separate_combos="yq -i 'del(.combos[] | select(.draw_separate != true))' ./tmp/keymap-drawer-onlyseparatecombos.yaml"
write_only_vim_combos="yq -i 'del(.combos[] | select(.k.s != \"vim\"))' ./tmp/keymap-drawer-onlyvimcombos.yaml"
draw_overview="keymap -c ./docs/keymap-drawer/keymap-drawer-config.yaml draw -o ./tmp/overview.svg ./docs/keymap-drawer/keymap-drawer.yaml"
draw_separate_combos="keymap -c ./docs/keymap-drawer/keymap-drawer-config.yaml draw -s alpha1 --combos-only -o ./tmp/separatecombos.svg ./tmp/keymap-drawer-onlyseparatecombos.yaml"
draw_alphas="keymap -c ./docs/keymap-drawer/keymap-drawer-config.yaml draw -s alpha1 alpha2 ç-extension -o ./tmp/alphas.svg ./tmp/keymap-drawer-noseparatecombos.yaml"
draw_shifted="keymap -c ./docs/keymap-drawer/keymap-drawer-config.yaml draw -s shifted1 shifted2 -o ./tmp/shifted.svg ./tmp/keymap-drawer-noseparatecombos.yaml"
draw_symbols="keymap -c ./docs/keymap-drawer/keymap-drawer-config.yaml draw -s lower raise -o ./tmp/symbols.svg ./tmp/keymap-drawer-noseparatecombos.yaml"
draw_functions="keymap -c ./docs/keymap-drawer/keymap-drawer-config.yaml draw -s functions smartcases -o ./tmp/functions.svg ./tmp/keymap-drawer-noseparatecombos.yaml"
draw_shortcuts="keymap -c ./docs/keymap-drawer/keymap-drawer-config.yaml draw -s shortcuts custom -o ./tmp/shortcuts.svg ./tmp/keymap-drawer-noseparatecombos.yaml"
draw_navigation="keymap -c ./docs/keymap-drawer/keymap-drawer-config.yaml draw -s nav media -o ./tmp/navigation.svg ./tmp/keymap-drawer-noseparatecombos.yaml"
draw_vim="keymap -c ./docs/keymap-drawer/keymap-drawer-config.yaml draw -s alpha1_vim_bindings lower media -o ./tmp/vim.svg ./tmp/keymap-drawer-onlyvimcombos.yaml"
draw_custom="keymap -c ./docs/keymap-drawer/keymap-drawer-config.yaml draw -o ./tmp/custom.svg ./tmp/keymap-drawer-custom.yaml"
convert_overview="inkscape --export-type png --export-filename ./img/overview.png --export-dpi 300 --export-background=white ./tmp/overview.svg"
convert_separate_combos="inkscape --export-type png --export-filename ./img/separatecombos.png --export-dpi 300 --export-background=white ./tmp/separatecombos.svg"
convert_alphas="inkscape --export-type png --export-filename ./img/alphas.png --export-dpi 300 --export-background=white ./tmp/alphas.svg"
convert_shifted="inkscape --export-type png --export-filename ./img/shifted.png --export-dpi 300 --export-background=white ./tmp/shifted.svg"
convert_symbols="inkscape --export-type png --export-filename ./img/symbols.png --export-dpi 300 --export-background=white ./tmp/symbols.svg"
convert_functions="inkscape --export-type png --export-filename ./img/functions.png --export-dpi 300 --export-background=white ./tmp/functions.svg"
convert_shortcuts="inkscape --export-type png --export-filename ./img/shortcuts.png --export-dpi 300 --export-background=white ./tmp/shortcuts.svg"
convert_navigation="inkscape --export-type png --export-filename ./img/navigation.png --export-dpi 300 --export-background=white ./tmp/navigation.svg"
convert_vim="inkscape --export-type png --export-filename ./img/vim.png --export-dpi 300 --export-background=white ./tmp/vim.svg"
convert_custom="inkscape --export-type png --export-filename ./img/custom.png --export-dpi 300 --export-background=white ./tmp/custom.svg"
prepare="\
${prepare_tmp} ;
${prepare_no_separate_combos} ; ${prepare_only_separate_combos} ; ${prepare_only_vim_combos} ; ${prepare_custom} ; \
${write_no_separate_combos} ; ${write_only_separate_combos} ; ${write_only_vim_combos}\
"
draw="\
${draw_overview} ; ${draw_separate_combos} ; ${draw_alphas} ; ${draw_shifted} ; \
${draw_symbols} ; ${draw_functions} ; ${draw_shortcuts} ; ${draw_navigation} ; ${draw_vim} ; ${draw_custom} \
"
convert="\
${convert_overview} ; ${convert_separate_combos} ; ${convert_alphas} ; ${convert_shifted} ; \
${convert_symbols} ; ${convert_functions} ; ${convert_shortcuts} ; ${convert_navigation} ; ${convert_vim} ; ${convert_custom} \
"
alias build_diagram="${prepare} ; ${draw} ; ${convert}"