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
# Fetches bibata cursor svgs
set -e
start() {
_LAST_MSG="$@"
echo -e "\x1b[0;1;34m@\x1b[0;34m $@\x1b[0m"
}
complete() {
if [[ "$1" == "" ]]; then
complete "$_LAST_MSG"
else
echo -e "\x1b[0;1;32m+\x1b[0;32m $@\x1b[0m"
fi
}
err() {
if [[ "$1" == "" ]]; then
err "$_LAST_MSG"
else
echo -e "\x1b[0;1;31m!\x1b[0;31m $@\x1b[0m" 1>&2;
fi
}
info() {
echo -e "\x1b[0;1;94mi\x1b[0;94m $@\x1b[0m" 1>&2;
}
mkdir -p cursors
for type in Modern Original; do
type_dir="cursors/$type"
type_meta="$type_dir/meta.json"
mkdir -p "$type_dir"
start "Get Cursor Metadata for CursorType($type)"
curl -fsSL "https://www.bibata.live/api/svg?type=${type}&v=1.0.2" | jq -M > "$type_meta"
complete
jq -Mc '.data[]' "$type_meta" | while read cursor_json; do
cursor_name="$(jq -r .name <<< "$cursor_json")"
cursor_dir="$type_dir/$cursor_name"
cursor_assets="$cursor_dir/assets"
cursor_meta="$cursor_dir/meta.json"
cursorfile="$cursor_dir/cursor.json"
mkdir -p "$cursor_dir" "$cursor_assets"
if [[ -f "$cursor_meta" ]] && [[ "$(jq -M "." "$cursor_meta" | sha512sum | awk '{print $1}')" == "$(jq -M "." <<< "$cursor_json" | sha512sum | awk '{print $1}')" ]]; then
start "Ensuring all keyframes for Cursor($type, $cursor_name) are present"
idx=0
jq -Mcr '.node_ids[]' "$cursor_meta" | while read node_id; do
node="Node($type, $cursor_name, Node($idx, $node_id))"
if ! [[ -f "$cursor_assets/$node_id.svg" ]]; then
cursor_url="$(jq -Mr ".urls[${idx}]" "$cursor_meta")"
start "Fetch missing $node - NodeIndex($idx)"
curl -fsSL "$cursor_url" -o "$cursor_assets/$node_id.svg"
((idx=idx+1))
complete "Fetched missing $node"
else
info "$node is already present"
fi
done
complete "Ensured all keyframes for Cursor($type, $cursor_name) are present"
else
if [[ -f "$cursor_meta" ]]; then info "MetaFile($cursor_meta) already exists but differs (it has FileHash(sha512, $(jq -M "$cursor_meta" | sha512sum | awk '{print $1}')), new version has FileHash(sha512, $(jq -M <<< "$cursor_json" | sha512sum | awk '{print $1}')))"; mv "$cursor_meta"; fi
jq -M <<< "$cursor_json" > "$cursor_meta"
start "Get keyframes for Cursor($type, $cursor_name)"
idx=0
total=0
jq -Mcr '.node_ids[]' "$cursor_meta" | while read id; do
rm -f "$cursor_assets/$node_id.svg"
((total=total+1))
done
jq -Mcr '.urls[]' "$cursor_meta" | while read cursor_url; do
node_id="$(jq -Mr ".node_ids[${idx}]" "$cursor_meta")"
node="Node($type, $cursor_name, Node($idx, $node_id))"
start "Fetch $node - NodeIndex($idx) of NodeCount($total)"
curl -fsSL "$cursor_url" -o "$cursor_assets/$node_id.svg"
((idx=idx+1))
complete "Fetched $node"
done
complete "Got keyframes for Cursor($type, $cursor_name)"
fi
done
done
|