aboutsummaryrefslogtreecommitdiff
path: root/random-wall
diff options
context:
space:
mode:
authorsrdusr <trevorgray@srdusr.com>2025-09-24 05:01:20 +0200
committersrdusr <trevorgray@srdusr.com>2025-09-24 05:01:20 +0200
commit553cb2204b0bf27afe13c6332f5679bbd47172a0 (patch)
tree75c86ff018122a682e0afd7a0e2a0228a63e44bd /random-wall
parentb20e4e004be74884cc72c57a3128e36fd5177d7a (diff)
downloaddotfiles-553cb2204b0bf27afe13c6332f5679bbd47172a0.tar.gz
dotfiles-553cb2204b0bf27afe13c6332f5679bbd47172a0.zip
Update/Overhaul
Diffstat (limited to 'random-wall')
-rwxr-xr-xrandom-wall128
1 files changed, 0 insertions, 128 deletions
diff --git a/random-wall b/random-wall
deleted file mode 100755
index bd23983..0000000
--- a/random-wall
+++ /dev/null
@@ -1,128 +0,0 @@
-#!/bin/bash
-
-WPDIR="$HOME/pictures/wallpapers"
-LAST_WP_FILE="$HOME/.config/random-wall_last_wp.txt"
-CURRENT_WP_FILE="$HOME/.config/nitrogen/bg-saved.cfg"
-
-random=true
-apply=true
-wpfile=""
-
-function usage {
- local stream exitcode
- if [ "$1" -eq 1 ]; then
- stream=2
- exitcode=255
- else
- stream=1
- exitcode=0
- fi
- echo "Usage: $(basename "$0") [-n|--noapply] [-h|--help] [wallpaper_location]" >&"$stream"
- echo "If wallpaper location is not given, a random wallpaper from $WPDIR will be chosen" >&"$stream"
- exit "$exitcode"
-}
-
-# Check if last wallpaper file exists and get its content
-if [ -f "$LAST_WP_FILE" ]; then
- LAST_WP=$(<"$LAST_WP_FILE")
-else
- LAST_WP=""
-fi
-
-# Function to get a random wallpaper from $WPDIR, excluding the last and current wallpapers
-function get_random_wallpaper {
- local wallpapers
- shopt -s nullglob
- wallpapers=("$WPDIR"/*.jpg)
- if [ ${#wallpapers[@]} -eq 0 ]; then
- echo "No wallpapers found in $WPDIR" >&2
- exit 1
- fi
-
- # If there is only one wallpaper, return it
- if [ ${#wallpapers[@]} -eq 1 ]; then
- echo "${wallpapers[0]}"
- return
- fi
-
- local exclude=()
- if [ "$LAST_WP" != "" ]; then
- exclude+=("$LAST_WP")
- fi
- if [ "$CURRENT_WP" != "" ]; then
- exclude+=("$CURRENT_WP")
- fi
-
- local random_wallpaper
- while true; do
- random_wallpaper="${wallpapers[RANDOM % ${#wallpapers[@]}]}"
- if [[ ! " ${exclude[@]} " =~ " ${random_wallpaper} " ]]; then
- echo "$random_wallpaper"
- return
- fi
- done
-}
-
-# handle arguments
-while [ $# -gt 0 ]; do
- case "$1" in
- "--help" | "-h")
- usage 0
- ;;
- "--noapply" | "-n")
- apply=false
- ;;
- *)
- if ! "$random"; then
- usage 1
- elif [ ! -f "$1" ]; then
- echo "File '$1' not found" >&2
- exit 1
- fi
- random=false
- wpfile="$1"
- ;;
- esac
- shift
-done
-
-# Choose a random wallpaper if necessary
-if "$random"; then
- wpfile=$(get_random_wallpaper)
- echo "Chose: $wpfile" >&2
-fi
-
-# Set the desktop wallpaper
-cat >"$HOME/.config/nitrogen/bg-saved.cfg" <<EOF
-[xin_-1]
-file=$wpfile
-mode=4
-bgcolor=#000000
-EOF
-
-# Set the lock screen wallpaper
-"$HOME/.scripts/lockscreen-wallpaper" "$wpfile" &
-
-# Set the LightDM wallpaper
-cp "$wpfile" "/usr/share/lightdm-webkit/themes/glorious/assets/bg.jpg"
-
-# Save the last chosen wallpaper
-echo "$wpfile" >"$LAST_WP_FILE"
-
-# Sync wallpaper using AccountsService D-Bus
-if [ "$wpfile" != "" ]; then
- dbus-send \
- --print-reply \
- --system \
- --dest=org.freedesktop.Accounts \
- /org/freedesktop/Accounts/User"$(id -u)" \
- org.freedesktop.DBus.Properties.Set \
- string:org.freedesktop.DisplayManager.AccountsService \
- string:BackgroundFile \
- variant:string:"$wpfile"
-fi
-
-# Apply the desktop wallpaper if requested
-if "$apply"; then
- nitrogen --restore
-fi