use different filename if already used by config

This commit is contained in:
Dignity
2025-07-19 19:24:49 +02:00
parent 6a4b8cc778
commit 084508db84
@@ -14,11 +14,11 @@ page=$((1 + RANDOM % 1000));
response=$(curl "https://konachan.net/post.json?tags=rating%3Asafe&limit=1&page=$page")
link=$(echo "$response" | jq '.[0].file_url' -r);
ext=$(echo "$link" | awk -F. '{print $NF}')
downloadPath="$HOME/Pictures/Wallpapers/konachan_random_image-0.$ext"
counter=0
while [ -e $downloadPath ]; do
counter=$((counter + 1))
downloadPath="$HOME/Pictures/Wallpapers/konachan_random_image-$counter.$ext"
done
downloadPath="$HOME/Pictures/Wallpapers/konachan_random_image.$ext"
illogicalImpulseConfigPath="$HOME/.config/illogical-impulse/config.json"
currentWallpaperPath=$(jq -r '.background.wallpaperPath' $illogicalImpulseConfigPath)
if [ "$downloadPath" == "$currentWallpaperPath" ]; then
downloadPath="$HOME/Pictures/Wallpapers/konachan_random_image-1.$ext"
fi
curl "$link" -o "$downloadPath"
"$SCRIPT_DIR/switchwall.sh" --image "$downloadPath"