From 800074e1d2e205319f8e3ad66e6ee88c2283719e Mon Sep 17 00:00:00 2001 From: "SilverAg.L" Date: Sat, 4 Apr 2026 23:18:51 +0800 Subject: [PATCH] =?UTF-8?q?chbg=EF=BC=9A=E7=8E=B0=E5=9C=A8=E7=94=A8?= =?UTF-8?q?=E4=BA=8Esystemd=E6=9C=8D=E5=8A=A1=E4=B9=9F=E8=83=BD=E6=AD=A3?= =?UTF-8?q?=E5=B8=B8=E6=B8=85=E7=90=86=E4=B8=8B=E8=BD=BD=E4=B8=8B=E6=9D=A5?= =?UTF-8?q?=E7=9A=84=E4=B8=B4=E6=97=B6=E6=96=87=E4=BB=B6=E5=8F=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bin/chbg | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/bin/chbg b/bin/chbg index 01e7b7b..38150a0 100755 --- a/bin/chbg +++ b/bin/chbg @@ -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"