#!/bin/sh # This script does the following: # - Run by itself, set the wallpaper (at X start). # - If given a file, set that as the new wallpaper. # - If given a directory, choose random file in it. # - If wal is installed, also generate a colorscheme. # Location of link to wallpaper. bgloc="${XDG_CACHE_HOME:-$HOME/.cache/}bg" [ ! -L "$bgloc" ] && [ ! -e "$1" ] && echo 'Please provide a valid image or directory.' && exit 1 [ -f "$1" ] && ln -sf "$(readlink -f "$1")" "$bgloc" [ -d "$1" ] && ln -sf "$(find "$(readlink -f "$1")" -iregex '.*.\(jpg\|jpeg\|png\)' -type f | shuf -n 1)" "$bgloc" # If pywal is installed, use it. [ $(command -v wal) ] && wal -qsi "$(readlink -f "$bgloc")" -o "${XDG_CONFIG_HOME:-$HOME/.config}/wal/postrun" # Kill notification daemon (it should restart automatically). pkill dunst xwallpaper --zoom "$bgloc" & notify-send -u low -i "$bgloc" 'Wallpaper updated' "$(basename "$(readlink -f "$bgloc")")"