#!/usr/bin/env bash # MIT License # Copyright (c) 2022 Angel Jumbo # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: # The above copyright notice and this permission notice shall be included in all # copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. write_section_header(){ echo "

" >> $3 echo "$2" | tr a-z A-Z >> $3 echo "

" >> $3 } write_img(){ echo " $1" >> $2 } rm *.html touch ./index.html echo " Gruvbox wallpapers

Gruvbox Wallpapers

" > ./index.html color=1 maxPerPage=8 declare -a sections for subdir in ./wallpapers/* do section="${subdir##*/}" sections+=("$section") write_section_header $color "$section" ./index.html page=1 img_count=0 subhtml="${section}_page${page}.html" touch ./$subhtml echo "
" >> ./index.html echo "
" >> ./index.html countImgs=$(find "$subdir" -type f | wc -l) countImgs=$((countImgs - 1)) for i in $(seq 1 $((( $countImgs / $maxPerPage)+1))); do echo "" >> ./index.html done echo "
" >> ./index.html echo "
" >> ./index.html echo "
" >> ./$subhtml for wallpaper in ${subdir}/* do if [ "$img_count" -ge $maxPerPage ]; then echo "
" >> ./$subhtml page=$((page + 1)) subhtml="${section}_page${page}.html" touch ./$subhtml echo "
" >> ./$subhtml img_count=0 fi write_img $wallpaper ./$subhtml img_count=$((img_count + 1)) done echo "
" >> ./$subhtml echo "
" >> ./index.html echo "
" >> ./index.html color=$((color + 1)) if [ "$color" -eq 8 ]; then color=1 fi done echo "
" >> ./index.html echo "" >> ./index.html echo " " >> ./index.html