chbg:现在用于systemd服务也能正常清理下载下来的临时文件叻
This commit is contained in:
29
bin/chbg
29
bin/chbg
@@ -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"
|
|
||||||
|
|||||||
Reference in New Issue
Block a user