diff --git a/bin/wallpaper-fetcher b/bin/wallpaper-fetcher new file mode 100755 index 0000000..69885f3 Binary files /dev/null and b/bin/wallpaper-fetcher differ diff --git a/mise.toml b/mise.toml index a4d479b..b1e7a08 100644 --- a/mise.toml +++ b/mise.toml @@ -98,6 +98,8 @@ dotfiles.default_mode = "symlink-each" "~/.local/bin/ykswap" = { source = "script/ykswap", mode = "symlink" } "~/.local/bin/bing-wallpaper" = { source = "script/bing-wallpaper", mode = "symlink" } +"~/.local/bin/set-wallpaper.sh" = { source = "script/set-wallpaper.sh", mode = "symlink" } +"~/.local/bin/wallpaper-fetcher" = { source = "bin/wallpaper-fetcher", mode = "symlink" } "~/.local/bin/omarchy-cmd-missing" = { source = "script/omarchy-cmd-missing", mode = "symlink" } "~/.local/bin/omarchy-cmd-present" = { source = "script/omarchy-cmd-present", mode = "symlink" } diff --git a/script/set-wallpaper.sh b/script/set-wallpaper.sh new file mode 100755 index 0000000..1032140 --- /dev/null +++ b/script/set-wallpaper.sh @@ -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