Merge branch 'main' into hefty-hype

This commit is contained in:
end-4
2026-05-25 00:27:46 +02:00
6 changed files with 60 additions and 23 deletions
@@ -29,14 +29,15 @@ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
mkdir -p "$PICTURES_DIR/Wallpapers"
page=$((1 + RANDOM % 1000));
response=$(curl "https://konachan.net/post.json?tags=rating%3Asafe&limit=1&page=$page")
illogicalImpulseConfigPath="$HOME/.config/illogical-impulse/config.json"
userAgent=$(jq -r '.networking.userAgent // empty' "$illogicalImpulseConfigPath" 2>/dev/null)
response=$(curl -A "$userAgent" "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="$PICTURES_DIR/Wallpapers/random_wallpaper.$ext"
illogicalImpulseConfigPath="$HOME/.config/illogical-impulse/config.json"
currentWallpaperPath=$(jq -r '.background.wallpaperPath' $illogicalImpulseConfigPath)
currentWallpaperPath=$(jq -r '.background.wallpaperPath' "$illogicalImpulseConfigPath")
if [ "$downloadPath" == "$currentWallpaperPath" ]; then
downloadPath="$PICTURES_DIR/Wallpapers/random_wallpaper-1.$ext"
fi
curl "$link" -o "$downloadPath"
curl -A "$userAgent" "$link" -o "$downloadPath"
"$SCRIPT_DIR/../switchwall.sh" --image "$downloadPath"
@@ -444,6 +444,30 @@ main() {
fi
fi
# If mode_flag is dark or light, try to find a variant with that mode suffix
if [[ "$mode_flag" == "dark" || "$mode_flag" == "light" ]]; then
# Get directory, filename without extension, and extension
local imgdir="$(dirname "$imgpath")"
local imgbase="$(basename "$imgpath")"
local imgname="${imgbase%.*}"
local imgext="${imgbase##*.}"
# Strip existing -dark or -light suffix
local stripped_name="${imgname%-dark}"
stripped_name="${stripped_name%-light}"
# Construct the new path with the requested mode suffix
local new_imgpath="${imgdir}/${stripped_name}-${mode_flag}.${imgext}"
local new_stripped_imgpath="${imgdir}/${stripped_name}.${imgext}"
# If the variant exists, use it
if [[ -f "$new_imgpath" ]]; then
imgpath="$new_imgpath"
elif [[ -f "$new_stripped_imgpath" ]]; then
imgpath="$new_stripped_imgpath"
fi
fi
switch "$imgpath" "$mode_flag" "$type_flag" "$color_flag" "$color"
}