Skip to content

Commit 07b0f29

Browse files
authored
chore: add script to check newest reshade release (#24)
1 parent ec645a2 commit 07b0f29

1 file changed

Lines changed: 56 additions & 0 deletions

File tree

scripts/check_reshade.sh

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
#!/usr/bin/env bash
2+
# Check if a new ReShade version is available.
3+
# Usage: ./check_reshade.sh 6.6.1
4+
# Exit codes: 0 up-to-date, 1 update available, 2 error
5+
6+
set -euo pipefail
7+
8+
CURRENT="${1:-}"
9+
if [[ -z "$CURRENT" ]]; then
10+
echo "Usage: $0 <current_version>"
11+
exit 2
12+
fi
13+
14+
fetch() {
15+
curl -fsSL --max-time 20 "https://reshade.me/"
16+
}
17+
18+
get_latest() {
19+
local html
20+
html="$(fetch || true)"
21+
[[ -z "$html" ]] && return 1
22+
23+
if [[ "$html" =~ Download[[:space:]]+ReShade[[:space:]]+([0-9]+\.[0-9]+\.[0-9]+) ]]; then
24+
echo "${BASH_REMATCH[1]}"
25+
return 0
26+
fi
27+
28+
return 1
29+
}
30+
31+
LATEST="$(get_latest || true)"
32+
if [[ -z "$LATEST" ]]; then
33+
echo "Could not determine latest ReShade version."
34+
exit 2
35+
fi
36+
37+
CMP="$(python3 - <<PY
38+
def norm(v):
39+
p=v.split('.')
40+
return list(map(int,(p+[0,0])[:3]))
41+
a=norm("$LATEST"); b=norm("$CURRENT")
42+
print((a>b)-(a<b))
43+
PY
44+
)"
45+
46+
if [[ "$CMP" -gt 0 ]]; then
47+
echo "New ReShade version available: $LATEST (you have $CURRENT)"
48+
echo "Download: https://reshade.me/"
49+
exit 1
50+
elif [[ "$CMP" -eq 0 ]]; then
51+
echo "You are up-to-date: $CURRENT"
52+
exit 0
53+
else
54+
echo "Your version ($CURRENT) is newer than site ($LATEST)."
55+
exit 0
56+
fi

0 commit comments

Comments
 (0)