What is this?
This is a small script to quick find Firefox bookmarks, in Linux, using DMENU or/and FZF
What you will need...
For this to work, you need to have installed the following:
- firefox ;)
- sqlite3
- dmenu or fzf
How it works...
The trick part of all this to work is the actual bookmark database of Firefox. First you have to find it and then you have to copy it, in another place, cause when Firefox runs, the database is locked. In the snap
version of Firefox, you can find the database with this command:
find ~/snap/firefox/ -name places.sqlite
If you have multiple profiles, it will list more than one file. You have to find which is the one, you are using right now. Search the net, to find how. After that, place the full file path and name into the appropriate variable of the script.
The script, copies the original database to another place (by default in the .config
dir) and then uses sqlite3
to extract the bookmarks. After that, easily pass the output to dmenu
or fzf
to select a bookmark.
Don't forget to bind this script to a key shortcut, for easier and quicker access. After making this, it's the only way i use to access my bookmarks :)
Da script...
#!/bin/bash
# Use this command to find the correct file
#PLACES="$(find ~/snap/firefox/ -name places.sqlite | head -1)"
# Replace the file path/name with the correct one. Use full path and name.
PLACES="~/snap/firefox/common/.mozilla/firefox/[profile]/places.sqlite"
# Change this, if you want the bookmark file to be copied somewhere else
TEMP="$HOME/.config/places.sqlite"
# Use --update to copy an updated version of your bookmark file
if [ "$1" == "--update" ]; then
echo "Copying file:"
echo "> $PLACES"
echo "To: $TEMP"
cp "$PLACES" "$TEMP"
echo "Copied! Exiting..."
exit
fi
bk="$(sqlite3 $TEMP "SELECT h.url, b.title
FROM moz_places h
JOIN moz_bookmarks b
ON h.id = b.fk;" | dmenu -l 15)"
if [ ! -z "$bk" ]; then
firefox "$(echo "$bk" | cut -d"|" -f1 )"
fi