forked from gamehelp16/now-clocking
-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathfetch-art
executable file
·47 lines (39 loc) · 1.15 KB
/
fetch-art
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
#!/bin/bash
set -e
cd "$(dirname "$0")"
source ./common
platform="$(get_platform)"
if [ -z "$platform" ]; then
exit
fi
source="$("$platform"_get_source)"
art="$("$platform"_get_art)"
data_dir="$(realpath ../data)"
mkdir -p "$data_dir"
cache_path="$data_dir/$source.cache"
img_path="$data_dir/$source.png"
touch "$cache_path"
content="$(cat "$cache_path")"
expected_content="$art $NOW_CLOCKING_ARTWORK_TINT"
if [ "$content" != "$expected_content" ]; then
echo "$expected_content" > "$cache_path"
test -f "$img_path" && rm "$img_path"
if [ -n "$art" ]; then
if [[ "$art" = http* ]] || [[ "$art" = file:* ]]; then
curl -s "$art" -o "$img_path"
elif [ -f "$art" ]; then
cp "$art" "$img_path"
else
echo "unknown art: $art" >&2
exit 1
fi
if [ -n "$NOW_CLOCKING_ARTWORK_TINT" ] && command -v convert >/dev/null; then
convert "$img_path" -colorspace gray -fill "$NOW_CLOCKING_ARTWORK_TINT" -tint 100 "$img_path"
fi
fi
fi
if [ -f "$img_path" ] && [ "$(wc -c "$img_path" | awk '{print $1}')" -gt 0 ]; then
echo "\${image $img_path -p 0,0 -s 125x125 -n}"
else
echo "\${image ./placeholder.png -p 0,0 -s 125x125}"
fi