From 40c90f7fee5728ea58feaf10452c55e1c70d6d92 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torjus=20H=C3=A5kestad?= Date: Sun, 21 Apr 2024 12:33:14 +0200 Subject: [PATCH] Improve randomwp --- home/scripts/randomwp.sh | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) 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"