#!/bin/sh # Open URLs from bookmarks file BOOKMARKS="$HOME/Documents/bookmarks.json" _folders() { jq -r '.children[] | select(.root == "unfiledBookmarksFolder") | .children[] | select(.type == "text/x-moz-place-container") | .title' "$BOOKMARKS" } _bookmarks_in_folder() { jq -r --arg title "$1" ' .. | select(.type? == "text/x-moz-place-container" and .title? == $title) | .children[]? | select(.type == "text/x-moz-place") | .title ' "$BOOKMARKS" } _bookmarks() { jq -r ' .. | select(.type? == "text/x-moz-place") | .title ' "$BOOKMARKS" } _uri_from_title() { jq -r --arg title "$1" ' .. | select(.type? == "text/x-moz-place" and .title? == $title) | .uri ' "$BOOKMARKS" } opt="$1" case "$opt" in folders) folder="$(_folders | menu "dmenu" "Folder:")" _bookmarks_in_folder "$folder" ;; *) title="$(_bookmarks | menu "dmenu" "Bookmark:")" _uri_from_title "$title" ;; esac