diff --git a/home/scripts/randomwp.sh b/home/scripts/randomwp.sh index 38e3905..276c272 100644 --- a/home/scripts/randomwp.sh +++ b/home/scripts/randomwp.sh @@ -10,7 +10,16 @@ if ! [ -d "$WALLPAPER_DIR" ]; then exit 1 fi -wallpaper_path=$(find "$WALLPAPER_DIR" -mindepth 1 | grep png| sort -R | tail -n 1) +if [ "$#" -eq 1 ]; then + wallpaper_path="$1" + ext=$(file --extension "$wallpaper_path" | cut -d" " -f2) + if ! [ "$ext" == "png" ]; then + echo "$wallpaper_path is an invalid wallpaper" + fi +else + wallpaper_path=$(find "$WALLPAPER_DIR" -mindepth 1 | grep png| sort -R | tail -n 1) +fi + if [ -z "$wallpaper_path" ]; then echo "Unable to find wallpaper"