Guest User

Untitled

a guest
Dec 13th, 2017
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. #!/bin/zsh
  2. # Fix Safari Favorites Icons
  3.  
  4. LSD="Library/Safari"; TIC="Touch Icons Cache"; TAB="cache_settings"; DIR="/$HOME/$LSD/$TIC/"
  5. DBF="$DIR/${${TIC// /}%s*}${${(C)TAB}/_/}.db"; SQL=$(sqlite3 "$DBF" "SELECT host FROM $TAB")
  6. diff <(ls "$DIR/Images") <(for i in "${=SQL}"; do echo ${(U)$(md5 -qs $i)}.png; done | sort)
  7.  
  8. for file in "$1"/*.png; do URL="$(plutil -convert xml1 -o - "$HOME/$LSD/Bookmarks.plist" | \
  9. awk -F '[</>]' -v f="${${file##*/}%%.*}" '{if($3~f){for(i=0;i<3;i++)getline;print $5}}')"; \
  10. cp -fv "$file" "$HOME/$LSD/Touch Icons Cache/Images/${(U)$(md5 -q -s $URL)}.png"; done; exit
Add Comment
Please, Sign In to add comment