Skip to content

Instantly share code, notes, and snippets.

@641i130
Created August 19, 2023 05:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 641i130/43ff5ab6fb0891beb7980bd71441545c to your computer and use it in GitHub Desktop.
Save 641i130/43ff5ab6fb0891beb7980bd71441545c to your computer and use it in GitHub Desktop.
Randomly shuffle over 20 images script
#!/bin/bash
# Assuming this Wallpapers folder is a nas mount
IMAGE_DIR="/home/user/Wallpapers/cats/"
TMP_DIR="/tmp/wallpapers"
NUM_IMAGES=20
# Create temporary directory if it doesn't exist
mkdir -p $TMP_DIR
# Check if the temporary directory is empty
if [ -z "$(ls -A $TMP_DIR)" ]; then
# Find and copy 20 random images to the temporary directory
find $IMAGE_DIR -type f \( -iname \*.jpg -o -iname \*.jpeg -o -iname \*.png -o -iname \*.gif \) | shuf -n $NUM_IMAGES | xargs -I {} cp {} $TMP_DIR
fi
# Set wallpaper using feh
feh --bg-max --randomize $TMP_DIR/*
# Optional: You might want to remove the copied images from /tmp after some time
# rm -f $TMP_DIR/*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment