Storing my internet bookmarks to disk in a non-proprietry way and making them easily accessible was my main goal in the research for this blog post.
A while back I decided that I wanted to TRY to break away from Google in as many ways as I could, not using Chrome as a web browser was one of the biggies. But one of the most convenient things about Chrome is the bookmark sync. The downside to Chrome, is they are tracking everything you do. Whether this is a bad thing or not I leave up to you.
I tried so many different bookmark managers, but so many of them use databases and require complex setup, or special syncing software running.
I wanted something that:
- Stored to disk in a text file
- Let me use my Dropbox / Nextcloud or normal Cloud sync software to take care of syncing between devices
- Works in Chrome / Firefox / Surf / anything
- Easily accessible
- Super lightweight
I settled on an amazingly simple bookmark manager called bm, and using dmenu (which I was already using as my main menu bar).
Simply hitting Super + Shift + B brings up the bookmark manager
Final result:
The plan
- What is bm?
- What is dmenu?
- My dmenu-bm script
- Link to the script on github
- Conclusion
1. What is bm?
Enter bm for “Simple Bash CLI bookmarks” https://github.com/tj/bm
Format of the bookmarks file
| Each bookmark gets a single line in the text file, and is delimited by |
Example:
bd8b3eff7fa82a0382a3e7576c5363b6|2016-01-18T07:21:36Z|:1|https://github.com/tj/bm|bm a cool enhanced bookmark tool for your console|default,shell
- First column is the GUID
- Second column is the DateTime added
- Third column… I’m not sure?
- Fourth column is the URL link
- Five column is the Description text
- Sixth column are the tags comma delimited
CLI commands
You can access and manipulate your bookmarks from the CLI. Although I don’t feel this is the most useful way to access it.
Adding bookmarks
bm add https://www.duckduckgo.com "DuckDuckGo Search Engine" search privacy
Listing bookmarks
bm -l
Searching bookmarks
bm -s 'string'
Opening bookmarks
bm -o 'string'
The downside
It doesn’t make it very easily accessible, at least not enough for me. I want to be able to launch a webpage without having to go into a terminal.
2. What is dmenu?
dmenu is a super lightweight menu bar for linux.
dmenu was development by the guys at suckless. They build software “with a focus on simplicity, clarity and frugality.” Basically they create minimal software that is hyper-performant. Sounds cool eh?
https://tools.suckless.org/dmenu/
I love dmenu, it’s lightweight, and allows me to customise it with scripts. It’s become my main menu system on my Linux machine. I’m adding more and more scripts to it and optimising my workflow.
3. My dmenu bookmarks script
dmenu-bm.sh
#!/usr/bin/env bash
declare -A g bmarray;
while IFS=\| read -r guid date id url title tags;
do
bookmark="$title "-" "$url" "-" "$tags"";
bmarray["$bookmark"]="$url";
done < /home/owen/Nextcloud/bookmarks/bm.lnk
function load() {
while IFS=\| read -r guid date id url title tags;
do
bookmark="$title "-" "$url" "-" "$tags"";
printf "$bookmark\n";
done < /home/owen/Nextcloud/bookmarks/bm.lnk
printf
}
choice=$(load | dmenu -i -l 15 -p "Add/Open bookmark:")
case "$choice" in
Add) dmenu-bm-add.sh ;;
*) bm -o ${bmarray[$choice]} ;;
esac
dmenu-bm-add.sh
#!/bin/sh
result() {
echo -n | dmenu -p "$1"
}
url="$result "URL:")"
title="$(result "Title:")"
tags="$(result "Tags (comma delimited):")"
bm -b '/home/owen/Nextcloud/bookmarks/bm.lnk' -a $url -T "$title" -t "$tags"
My shortcut in dwm
config.def.h
static const char *bookmarkscmd[] = { "dmenu-bm.sh", NULL };
TODO:
I still have some tidying of this up, some code duplication in the dmenu-bm.sh script. But for the most part this works, and I use this in my day to day workflow.
4. Link to the script on github
You can find the above files in my github at https://github.com/Owen-Davies/dmenu-bm/
5. Conclusion
There we have it, a very simple bookmark management solution that I use day to day.
I’m a big fan of dmenu, do you have any dmenu scripts that you use that you recommend?
Still a bit new to bash scripting, so please point me in the direction of any improvements, I will try to revisit this once I get better. But for now it works, so :-)
You can check out some other dmenu scripts on the subreddit https://www.reddit.com/r/dmenu/
Top comments (0)