markhuge MH\n s

Consolidated Dmenu Bookmarks

published:

signed with 0x683A22F9469CA4EB

tags:

This seems like something I could have just done with awk, but this works so I DGAF.

I wanted to be able to bookmark things from whatever browser I’m currently using, and still have it show up in dmenu.

  • chrome() works with the path of any chrome bookmarks json.
  • surfr() works with surfraw tab-delimited bookmarks.
  • moz() works with mozilla places.sqlite bookmarks.
#!/bin/sh

# Bookmark locations
brave="$XDG_CONFIG_HOME/BraveSoftware/Brave-Browser/Default/Bookmarks"
surfraw="$XDG_CONFIG_HOME/surfraw/bookmarks"
firefox="$HOME/.mozilla/firefox/path/to/places.sqlite"
librewolf="$HOME/.librewolf/path/to/places.sqlite"

# Browser specific parsers

# Surfraw
surfr () {
	cut -f2,4- $1 
}

# Chrome, Chromium, Brave
chrome () {
	jq -r '.roots[] | recurse(.children[]?) | select(.type != "folder") | {url, name} | join("\n")' $1 | paste - - 
}

# Firefox, Librewolf
moz() {
	query="select moz_places.id, moz_places.url, moz_places.title, moz_bookmarks.parent from moz_places left outer join moz_bookmarks on moz_places.id = moz_bookmarks.fk;"
	sqlite3 -separator '	' "$1" "$query" | cut -f2,3
}

sr $({ chrome $brave & surfr $surfraw & moz $firefox & moz $librewolf; } | sort | awk '!x[$1]++' | dmenu -l 20 | awk '{print $1}')



About the Author

Mark Wilkerson

0x683A22F9469CA4EB

R&D engineer @ Twitch. Previously Blizzard, Hightail, Co-Founder @ SpeakUp

Mark is building open source tools to make web3 and decentralized self-ownership easy for regular people.

Live dev streams at Twitch.tv

More Posts