feat: add wallpaper-fetcher binary and set-wallpaper wrapper script
Add a compiled wallpaper-fetcher binary that downloads images from backiee.com, and a set-wallpaper.sh wrapper that downloads a random wallpaper and sets it as the desktop background via awww.
This commit is contained in:
Executable
+53
@@ -0,0 +1,53 @@
|
||||
#!/bin/sh -e
|
||||
|
||||
# Wrapper around wallpaper-fetcher: downloads a random new wallpaper from
|
||||
# backiee.com and sets it as the desktop background via awww.
|
||||
#
|
||||
# Usage: set-wallpaper.sh [backiee-path] [-r WxH]
|
||||
#
|
||||
# backiee-path Path segment on backiee.com (default: latest)
|
||||
# -r WxH Max resolution (e.g. "1920x1080") — passed through to wallpaper-fetcher
|
||||
|
||||
BACKIEE_PATH="${1:-latest}"
|
||||
|
||||
# Check for -r flag (may be first or second arg)
|
||||
RES_ARGS=""
|
||||
if [[ "$1" == "-r" ]]; then
|
||||
RES_ARGS="-r $2"
|
||||
elif [[ "$2" == "-r" ]]; then
|
||||
RES_ARGS="-r $3"
|
||||
fi
|
||||
|
||||
if [[ ! -x /usr/bin/awww ]]; then
|
||||
echo "required awww — please install with yay -S awww" >&2
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Paths
|
||||
BACKGROUNDS_DIR="$HOME/Sync/Shared/wallpapers"
|
||||
CURRENT_BACKGROUND_LINK="$HOME/.config/omarchy/current/background"
|
||||
|
||||
[ -d "$BACKGROUNDS_DIR" ] || mkdir -p "$BACKGROUNDS_DIR"
|
||||
|
||||
# Run wallpaper-fetcher (stdout = bare filename, stderr = log output)
|
||||
FILENAME=$(wallpaper-fetcher "$BACKIEE_PATH" -o "$BACKGROUNDS_DIR" $RES_ARGS 2>/dev/null)
|
||||
|
||||
if [[ -z "$FILENAME" ]]; then
|
||||
echo "wallpaper-fetcher failed — no image downloaded" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
FILE_PATH="$BACKGROUNDS_DIR/$FILENAME"
|
||||
|
||||
echo "Wallpaper: $FILENAME"
|
||||
|
||||
if [[ ! -f "$FILE_PATH" ]]; then
|
||||
echo "File not found: $FILE_PATH" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
ln -nsf "$FILE_PATH" "$CURRENT_BACKGROUND_LINK" &&
|
||||
setsid uwsm app -- awww img "$CURRENT_BACKGROUND_LINK" &&
|
||||
exit 0
|
||||
|
||||
exit 1
|
||||
Reference in New Issue
Block a user