chbg:现在用于systemd服务也能正常清理下载下来的临时文件叻
This commit is contained in:
29
bin/chbg
29
bin/chbg
@@ -132,19 +132,22 @@ done
|
||||
|
||||
echo "Selected: $randomimage"
|
||||
|
||||
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
|
||||
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"
|
||||
else
|
||||
request_wallpaper "$randomimage"
|
||||
fi
|
||||
set_wallpaper "$tmpfile"
|
||||
|
||||
Reference in New Issue
Block a user