#!/bin/bash --norc # ╭───────────────╮ # │ SWWW-settings │ # ╰───────────────╯ export SWWW_TRANSITION_FPS=60 export SWWW_TRANSITION_STEP=60 export SWWW_TRANSITION=center # ╭───────────────────────────────────────────────────────────────────────────╮ # │ Set default excluded directories if SWWW_EXCLUDED_DIRS is not already set │ # │ Dirs to exclude: Anime, Colorful, Gaming, Gifs, Gruvbox, Logos, Muted, │ # │ Nordic, Windoof │ # ╰───────────────────────────────────────────────────────────────────────────╯ : "${SWWW_EXCLUDED_DIRS:=Anime,Colorful,Gaming,Gifs,Logos,Nordic,Windoof}" _swww() { if [ -z "$1" ]; then # ─< random wallpaper selection >───────────────────────────────────────────────────────── local wall_dir="$HOME/.wallpapers" # ─< Create an array of directories to exclude >────────────────────────────────────────── IFS=',' read -ra EXCLUDED_DIRS <<<"$SWWW_EXCLUDED_DIRS" # ─< Build the find command with exclusions >───────────────────────────────────────────── local find_cmd="find \"$wall_dir\" -type f \( -iname \"*.png\" -o -iname \"*.jpg\" -o -iname \"*.gif\" -o -iname \"*.PNG\" -o -iname \"*.JPG\" -o -iname \"*.GIF\" \) -not -path \"*/\.git/*\"" for dir in "${EXCLUDED_DIRS[@]}"; do find_cmd+=" -not -path \"$wall_dir/$dir/*\"" done # ─< Select a random picture >──────────────────────────────────────────────────────────── local pic=$(eval $find_cmd | shuf -n 1) # ─< checking for swww >────────────────────────────────────────────────────────────────── if command -v swww >/dev/null 2>&1; then # ─< Check if swww daemon is running, start if not >───────────────────────────────────── if ! pgrep -x "swww" >/dev/null; then notify-send "SWWW" "swww not running - starting it now" swww-daemon sleep 1 # Give the daemon a second to start if pgrep -x "swww" >/dev/null; then notify-send "SWWW" "started successfully" else notify-send "ERROR" "seems like swww didn't come up as exspected" fi fi # ─< checking the wall_dir variable >───────────────────────────────────────────────────── if [[ -d "$wall_dir" ]]; then # ─< executing swww with the random $pic >──────────────────────────────────────────────── swww img "$pic" # --transition-fps "$SWWW_TRANSITION_FPS" --transition-step "$SWWW_TRANSITION_STEP" --transition-type "$SWWW_TRANSITION" notify-send "󰸉 " "Changed wallpaper to $pic" notify-send " " "Not sourcing from: $SWWW_EXCLUDED_DIRS" else notify-send "ERROR" "$wall_dir path not found" fi else notify-send "ERROR" "swww was not found on the system" fi else if command -v swww >/dev/null 2>&1; then # ─< Check if swww daemon is running, start if not >───────────────────────────────────── if ! pgrep -x "swww" >/dev/null; then notify-send "SWWW" "swww not running - starting it now" swww-daemon sleep 1 # Give the daemon a second to start if pgrep -x "swww" >/dev/null; then notify-send "SWWW" "started successfully" else notify-send "ERROR" "seems like swww didn't come up as exspected" fi fi # ─< executing swww with the random $pic >──────────────────────────────────────────────── swww img "$1" # --transition-fps "$SWWW_TRANSITION_FPS" --transition-step "$SWWW_TRANSITION_STEP" --transition-type "$SWWW_TRANSITION" notify-send "󰸉 " "Changed wallpaper to $1" else notify-send "ERROR" "$1 not found" fi fi } _swww "$@"