-
-
Save Next-Door-Tech/a94bf2b1a666506d0d806229300dc4a0 to your computer and use it in GitHub Desktop.
Fix Safari FavIcons
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/zsh | |
# Fix Safari Favorites Icons | |
LSD="Library/Safari" | |
TIC="Touch Icons Cache" | |
TAB="cache_settings" | |
DIR="/$HOME/$LSD/$TIC/" | |
DBF="$DIR/${${TIC// /}%s*}${${(C)TAB}/_/}.db" | |
SQL=$(sqlite3 "$DBF" "SELECT host FROM $TAB") | |
diff <(ls "$DIR/Images") <(for i in "${=SQL}"; do echo ${(U)$(md5 -qs $i)}.png; done | sort) | |
sqlite3 "$DBF" "UPDATE $TAB SET ${${${(L)TIC// /_}#*_*}/s/_is_in}=1,download_status_flags=1" | |
for file in "$1"/*.png; do | |
URL="$(plutil -convert xml1 -o - "$HOME/$LSD/Bookmarks.plist" | \ | |
awk -F '[</>]' -v f="${${file##*/}%%.*}" '{if($3~f){for(i=0;i<3;i++)getline;print $5}}')"; \ | |
cp -fv "$file" "$HOME/$LSD/Touch Icons Cache/Images/${(U)$(md5 -q -s $URL)}.png" | |
done | |
exit |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@Cancun101 take a look at the new revision.