chbg:现在用于systemd服务也能正常清理下载下来的临时文件叻

This commit is contained in:
2026-04-04 23:18:51 +08:00
parent 2dbf833d80
commit 800074e1d2

View File

@@ -132,19 +132,22 @@ done
echo "Selected: $randomimage" echo "Selected: $randomimage"
if [ -f "$randomimage" ]; then request_wallpaper() {
set_wallpaper "$randomimage" tmpfile=$(mktemp)
exit 0 trap 'rm -f "$tmpfile"' EXIT
fi if command -v curl >/dev/null 2>&1; then
curl -sSL "$1" -o "$tmpfile"
tmpfile=$(mktemp) elif command -v wget >/dev/null 2>&1; then
trap 'rm -f "$tmpfile"' EXIT wget -qO "$tmpfile" "$1"
if command -v curl >/dev/null 2>&1; then else
curl -sSL "$randomimage" -o "$tmpfile"
elif command -v wget >/dev/null 2>&1; then
wget -qO "$tmpfile" "$randomimage"
else
echo "x) Unable to fetch image without 'curl' or 'wget'." >&2 echo "x) Unable to fetch image without 'curl' or 'wget'." >&2
exit 2 exit 2
fi
set_wallpaper "$tmpfile"
}
if [ -f "$randomimage" ]; then
set_wallpaper "$randomimage"
else
request_wallpaper "$randomimage"
fi fi
set_wallpaper "$tmpfile"