#!/usr/bin/env bash # Original script steal from (specific commit): # https://github.com/lime-desu/dootsfile/blob/58abca63dfd596d4812fcf95567cc3ad63ffbb6f/scripts/set-random-wallpaper.sh WALLPAPER_DIR=${HOME}/Drives/Stuff/Pictures/Waifus WALLPAPER_PREFIX="Fondos_PC.*" RANDOM_PICTURE=$(fd -apt f "$WALLPAPER_PREFIX" "$WALLPAPER_DIR" | shuf -n 1) CURRENT_DESKTOP="$(echo "$XDG_CURRENT_DESKTOP" | awk '{for (i=1;i<=NF;i++) { $i=toupper(substr($i,1,1)) tolower(substr($i,2)) }}1')" case "$CURRENT_DESKTOP" in Gnome) gsettings set org.gnome.desktop.background picture-uri "file://$RANDOM_PICTURE" gsettings set org.gnome.desktop.background picture-uri-dark "file://$RANDOM_PICTURE" ;; Xfce) backdrop=$(xfconf-query --channel xfce4-desktop --property /backdrop --list | grep -E -e "screen.*/monitor.*image-path$" -e "screen.*/monitor.*/last-image$") for i in ${backdrop}; do xfconf-query --channel xfce4-desktop --property "$i" --create --type string --set "$RANDOM_PICTURE" xfconf-query --channel xfce4-desktop --property "$i" --set "$RANDOM_PICTURE" done ;; KDE) export DISPLAY=:0 kwriteconfig5 --file kdeglobals --group Wallpaper --key Picture "$RANDOM_PICTURE" qdbus org.kde.plasmashell /PlasmaShell org.kde.PlasmaShell.evaluateScript ' var allDesktops = desktops(); print (allDesktops); for (i=0;i/dev/null; then feh --bg-scale "$RANDOM_PICTURE" elif command -v nitrogen >/dev/null; then nitrogen --set-scaled "$RANDOM_PICTURE" fi ;; *) notify-send "Error: $(basename "$0")" "This script does not support $CURRENT_DESKTOP." exit 1 ;; esac if [[ "$CURRENT_DESKTOP" =~ ^(Gnome|Xfce|KDE|Sway|i3)$ ]]; then display_path="$(echo "$RANDOM_PICTURE" | awk -F '/' '{print "(...)/"$(NF-1)"/"$NF}')" notify-send 'Wallpaper changed:' "$display_path" fi