Improve randomwp
Some checks failed
pre-commit / pre-commit (push) Failing after 17s

This commit is contained in:
Torjus Håkestad 2024-04-21 12:33:14 +02:00
parent ffd89a2bbb
commit 40c90f7fee

View File

@ -10,7 +10,16 @@ if ! [ -d "$WALLPAPER_DIR" ]; then
exit 1 exit 1
fi fi
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) wallpaper_path=$(find "$WALLPAPER_DIR" -mindepth 1 | grep png| sort -R | tail -n 1)
fi
if [ -z "$wallpaper_path" ]; then if [ -z "$wallpaper_path" ]; then
echo "Unable to find wallpaper" echo "Unable to find wallpaper"