-
Notifications
You must be signed in to change notification settings - Fork 1
/
speedo.sh
executable file
·85 lines (62 loc) · 2.25 KB
/
speedo.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
#!/usr/bin/env bash
action="$1"
speedo_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
# TODO: Is there a better way? Submodule perhaps?
kbutil_dir="$( dirname "$speedo_dir" )/resources/kbutil"
kbutil_dll="$kbutil_dir/build/KbUtil.Console/bin/Release/kbutil.dll"
kbmath_dll="$kbutil_dir/build/KbMath.Console/bin/Release/KbMath.Console.dll"
svg_opener="inkscape"
function error() {
local msg="$1"
local COLOR_NONE='\033[0m'
local COLOR_ERROR='\033[0;31m'
>&2 echo -e "${COLOR_ERROR}ERROR: $msg${COLOR_NONE}"
exit 1
}
function generate_render() {
input="$speedo_dir/speedo.xml"
output="$speedo_dir/case"
options="--visual-switch-cutouts --keycap-overlays --keycap-legends --squash"
mkdir -p "./temp"
dotnet "$kbutil_dll" gen-svg $options "$input" "$output"
dotnet "$kbutil_dll" gen-key-bearings "$input" "./temp/keys.json" --debug-svg="./temp/bearings.svg"
"$svg_opener" "$output/speedo.svg"
}
function generate_case() {
input="$speedo_dir/speedo.xml"
output="$speedo_dir/case"
options="--visual-switch-cutouts"
mkdir -p "./temp"
dotnet "$kbutil_dll" gen-svg $options "$input" "$output"
dotnet "$kbutil_dll" gen-key-bearings "$input" "./temp/keys.json" --debug-svg="./temp/bearings.svg"
"$svg_opener" $output/speedo_*.svg
}
function generate_layouts() {
options="--visual-switch-cutouts --keycap-overlays --keycap-legends"
dotnet "$kbutil_dll" gen-svg $options \
"$speedo_dir/layout/speedo_layout.xml" \
"$speedo_dir/layout"
"$svg_opener" \
"$speedo_dir/layout/speedo_layer_default.svg" \
"$speedo_dir/layout/speedo_layer_fn.svg"
}
function print_usage() {
echo "USAGE: ./speedo.sh <action> [OPTIONS]"
echo ""
echo "Actions:"
echo " generate-render : Generate an svg render of the keyboard"
echo " generate-case : Generate svg renders of the keyboard case layers"
echo " help : Print this help dialog"
}
if [ "$action" = "generate-render" ]; then
generate_render
elif [ "$action" = "generate-case" ]; then
generate_case
elif [ "$action" = "generate-layouts" ]; then
generate_layouts
elif [ "$action" = "help" ]; then
print_usage
else
print_usage
exit 1
fi