Click here to Skip to main content
15,881,882 members
Articles / Chrome

Super Lightweight Bookmarks Manager - dmenu Bookmarks with bm

Rate me:
Please Sign up or sign in to vote.
0.00/5 (No votes)
21 May 2020CPOL3 min read 2.9K   1  
How to store internet bookmarks to disk in a non-proprietary way and make them easily accessible
Storing my internet bookmarks to disk in a non-proprietary way and making them easily accessible was my main goal in the research for this blog post.

A while ago, 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

Click to enlarge image

The Plan

  1. What is bm?
  2. What is dmenu?
  3. My dmenu-bm script
  4. Link to the script on github
  5. 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 developed 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?

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

Bash
#!/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 up of this, 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.

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/.

This article was originally posted at https://owendavies.net/articles/dmenu-bookmarks-with-bm

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Architect
United Kingdom United Kingdom
I have been working in software development for over 16 years, during that time I have worn many hats.

I have worked as a Software Engineer, Architect, Agile Coach and Trainer. I’ve created teams, I’ve lead teams, but my main goal is to help teams build great software and enjoy the process.

I help a whole range of businesses – from startups with just an idea who want to build a team to take that idea into reality and FTSE 100 businesses who need to optimise existing teams – I train, mentor and coach them to success.

If you happen to know of anybody who could benefit from results like this, then please go to my contact page and get in touch.

Owen Davies

Comments and Discussions

 
-- There are no messages in this forum --