-
Notifications
You must be signed in to change notification settings - Fork 0
/
update-keyboard-firmware-left.sh
executable file
·51 lines (41 loc) · 1.14 KB
/
update-keyboard-firmware-left.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
#!/bin/bash
# Required parameters:
# @raycast.schemaVersion 1
# @raycast.title Update keyboard firmware [left]
# @raycast.mode compact
# Optional parameters:
# @raycast.icon ⌨️
BASE_DIR="/Users/tim/Downloads/"
ZIP_NAME="firmware.zip"
ZIP_PATH="${BASE_DIR}${ZIP_NAME}"
DELAY_SECONDS=2
TARGET_FILES=("corne_left-nice_nano_v2-zmk.uf2" "gbEnki_left-nice_nano_v2-zmk.uf2")
DESTINATION="/Volumes/NICENANO"
sleep $DELAY_SECONDS
if [ ! -f "$ZIP_PATH" ]; then
echo "$ZIP_NAME not found"
exit 1
fi
if [ ! -d "$DESTINATION" ]; then
echo "Keyboard is not ready."
exit 1
fi
unzip -o "$ZIP_PATH" -d "$(dirname "$ZIP_PATH")"
found_file=""
for target_file in "${TARGET_FILES[@]}"; do
result_file="$(dirname "$ZIP_PATH")/$target_file"
if [ ! -f "$result_file" ]; then
result_file="$(dirname "$ZIP_PATH")/firmware/$target_file"
fi
if [ -f "$result_file" ]; then
found_file="$result_file"
break
fi
done
if [ -f "$found_file" ]; then
cp "$found_file" "$DESTINATION/"
echo "Firmware $(basename "$found_file") updated."
rm -f "$ZIP_PATH" "$found_file"
else
echo "No target firmware files found."
fi