Files
dotfiles/script/set-wallpaper.sh
T
gitadmin b6b738fc7b chore: migrate omarchy state from ~/.config to ~/.local/state
Move all omarchy runtime state (themes, backgrounds, current theme)
from ~/.config/omarchy/current to ~/.local/state/omarchy/current
to keep the config dir free of generated files. Add mise task for
recreating symlinks and update credential helpers for tea.
2026-09-03 20:46:18 -04:00

54 lines
1.4 KiB
Bash
Executable File

#!/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/.local/state/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