#!/usr/bin/env bash # orionwallpaper — set or restore the OrionOS desktop wallpaper # # Usage: # orionwallpaper # restore saved wallpaper (called from xinitrc) # orionwallpaper /path/to/image.jpg # set new wallpaper and save it # orionwallpaper --color "#6B8FB5" # set solid color # orionwallpaper --reset # reset to default blue-gray solid color # orionwallpaper --slideshow DIR [SECS] # rotate images in DIR every SECS seconds (default 300) # # Wallpaper preference is stored in ~/.config/orionos/wallpaper CONF_DIR="$HOME/.config/orionos" CONF_FILE="$CONF_DIR/wallpaper" DEFAULT_COLOR="#1A2840" WALLPAPER_DIR="/usr/share/orionos/wallpapers" mkdir -p "$CONF_DIR" case "${1:-}" in --slideshow) DIR="${2:-$WALLPAPER_DIR}" SECS="${3:-300}" if [[ ! -d "$DIR" ]]; then echo "Error: directory not found: $DIR" >&2 exit 1 fi while true; do IMG="$(find "$DIR" -maxdepth 1 -type f \( -iname '*.png' -o -iname '*.jpg' -o -iname '*.jpeg' \) | shuf -n1)" if [[ -n "$IMG" ]]; then feh --no-fehbg --bg-fill "$IMG" fi sleep "$SECS" done ;; --reset) echo "color:$DEFAULT_COLOR" > "$CONF_FILE" xsetroot -solid "$DEFAULT_COLOR" echo "Wallpaper reset to default color." ;; --color) COLOR="${2:-$DEFAULT_COLOR}" echo "color:$COLOR" > "$CONF_FILE" xsetroot -solid "$COLOR" echo "Wallpaper set to solid $COLOR." ;; "") # Restore from saved config if [[ -f "$CONF_FILE" ]]; then SAVED="$(cat "$CONF_FILE")" if [[ "$SAVED" == color:* ]]; then xsetroot -solid "${SAVED#color:}" elif [[ -f "$SAVED" ]]; then feh --no-fehbg --bg-fill "$SAVED" else xsetroot -solid "$DEFAULT_COLOR" fi else # First run: use default wallpaper if it exists, else solid color if [[ -f "$WALLPAPER_DIR/orionos-default.png" ]]; then feh --no-fehbg --bg-fill "$WALLPAPER_DIR/orionos-default.png" echo "$WALLPAPER_DIR/orionos-default.png" > "$CONF_FILE" else xsetroot -solid "$DEFAULT_COLOR" echo "color:$DEFAULT_COLOR" > "$CONF_FILE" fi fi ;; *) # Set specific image file IMG="$1" if [[ ! -f "$IMG" ]]; then echo "Error: file not found: $IMG" >&2 exit 1 fi echo "$IMG" > "$CONF_FILE" feh --no-fehbg --bg-fill "$IMG" echo "Wallpaper set to: $IMG" ;; esac