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"
request_wallpaper() {
tmpfile=$(mktemp)
trap 'rm -f "$tmpfile"' EXIT
if command -v curl >/dev/null 2>&1; then
curl -sSL "$1" -o "$tmpfile"
elif command -v wget >/dev/null 2>&1; then
wget -qO "$tmpfile" "$1"
else
echo "x) Unable to fetch image without 'curl' or 'wget'." >&2
exit 2
fi
set_wallpaper "$tmpfile"
}
if [ -f "$randomimage" ]; then
set_wallpaper "$randomimage"
exit 0
fi
tmpfile=$(mktemp)
trap 'rm -f "$tmpfile"' EXIT
if command -v curl >/dev/null 2>&1; then
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
exit 2
request_wallpaper "$randomimage"
fi
set_wallpaper "$tmpfile"