Nat TaylorBlog, Product Management & Tinkering

Chrome Bookmarks in MacOS Spotlight Search

Published on . Updated on

Spotlight is incredibly convenient but it only supports Safari bookmarks. I came up with the following solution to add Chrome bookmarks. I run this script periodically, and it writes out .webloc files that get picked up by Spotlight.

#!/usr/bin/env python3

"""Write Chrome Bookmarks as .webloc files in a folder so they show up in Spotlight"""

import json
import logging

template = """<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "">
<plist version="1.0">

with open('/Users/ntaylor/Library/Application Support/Google/Chrome/Default/Bookmarks') as f:
    bookmarks = json.load(f)

keepers = [c for b in bookmarks['roots']['other']['children']
             if 'children' in b and b['name'] == 'Jesica' for c in b['children']]

for k in keepers:['name'])
    with open(f'/Users/ntaylor/Links/{k["name"]}.webloc', 'w') as f:
        f.write(template.format(url = k["url"]))

Popular Posts

Post Navigation