random-image-picker/shuffle.sh
2026-03-07 00:48:37 +05:00

13 lines
349 B
Bash
Executable file

#!/bin/bash
SOURCE_DIR=$(dirname -- "${BASH_SOURCE[0]}")
EXTRACTION_DIR=$SOURCE_DIR/selection/
SFW_DIR=$SOURCE_DIR/sfw/
EXTRACTED_FILE=$EXTRACTION_DIR$(ls $SOURCE_DIR/selection/ | shuf -n 1 -)
magick $EXTRACTED_FILE $SOURCE_DIR/selected.jpg
if [ "$OVERRIDE_SFW" = "1" ]; then
cp $SFW_DIR$(ls $SFW_DIR | shuf -n 1 -) $SOURCE_DIR/selected.jpg
fi