Syncing Lagrange Bookmarks via the Cloud

04 October 2021

If you can forgive the somewhat buzzword-ary nature of the title, here we're going to see how to sync bookmarks for Lagrange.

Lagrange is a superb browser for the Gemini protocol; just a lovely piece of software that's comfortable and in line with the protocol it's built to be used with, is very good on resources. If only our web browsers could be this nice and light at the same time!

Thankfully it also has the option to save bookmarks to a simple bookmarks.gmi file (press CTRL+S while on the bookmarks page). Try it, it's easy and we'll need it for our next steps further on.

Lagrange ALSO has the ability to use any Gemini page containing links as a bookmark source. This is very handy, and this will allow us to create a (albeit crude) way to sync bookmarks between our devices.

Note that the below instructions apply to a Linux machine specifically, but could be easily extrapolated to any other operating system that Lagrange runs on, you'll just have to adapt the config directory for Lagrange accordingly.

The Cloud

Honestly, I hate using this word. The 'cloud'. I'm cringing as I write this.

Nevertheless, though, for lack of a better word, this method of syncing uses some form of cloud syncing. In my case, I use NextCloud. But you could use any similar automatic files syncing service, like Dropbox or any such similar thing.

Let's Do It

Assuming on your original computer you have saved the exported bookmarks.gmi file to ~/Downloads, the next thing to do is to copy the file to our cloud storage syncing folder, eg:

cp ~/Downloads/bookmarks.gmi ~/NextCloud/lagrange-bookmarks.gmi

Next, making sure Lagrange is closed so nothing gets messed up, you'll want to delete Lagrange's internal bookmarks storage file. Yes, you heard that right. You'll see why in a moment. If the existing bookmarks remain, you'll end up with doubled up bookmark entries.

NOTE - Update 2021-10-06: The author of Lagrange, 'skyjake', has since told me that he doesn't recommend deleting the bookmarks.ini file as this will also delete any saved feeds and custom icons you may have set. Please keep that in mind. If, like me, you only are concerned with bookmarks then you can delete the file safely, but otherwise either leave it in place as-is or you could edit the file and carefully delete the bookmark entries within, but make sure to back up the file first!

We can do this as thus:

rm ~/.config/lagrange/bookmarks.ini

Please note that prior to Lagrange 1.7.0, the bookmarks file is actually called bookmarks.txt.

Then, fire up Lagrange and enter into your location bar the location of your now syncing bookmarks file from earlier, eg:

file://~/NextCloud/lagrange-bookmarks.gmi

This will bring up the file that you exported earlier. Now for the final bit of magic. Hit CTRL-D or click Bookmark Page.... When the bookmark dialog comes up, then click Use as Bookmark Source. This is important! This is what saves the bookmark as a Remote Source. Call it whatever you want, I called it simply My Bookmarks.

Once your bookmarks file is, well, bookmarked... then go to your actual bookmarks in Lagrange. You'll simply now see an entry called My Bookmarks as the sole bookmark and if you click it, you'll be taken to the full list of the bookmarks that were exported earlier!

Ordinarily, hitting Refresh on the bookmarks page should automatically display the full list of links in Lagrange's bookmark page without having to click on the My Bookmarks entry first, but I found this only works after restarting Lagrange after adding the bookmark source. YMMV and all that.

Done

And that's it!

To access your sync'd bookmarks file on another device, you simply repeat the above process of adding that file as a Bookmark Source on that device's install of Lagrange, eg. by bookmarking the file, and setting it as a Bookmark Source.

The obvious downside to this is it's not completely automatic, as anytime you want to add more bookmarks to the synchronised bookmark source file, you'll have to repeat the process of exporting the bookmarks again or simply adding them by hand to the already exported file. Saving a bookmark via the Lagrange interface like normal will still just save the bookmark locally to that instance of Lagrange. Still, it allows us to easily get our bookmarks list across our devices, all without any sync features being built into the browser or using some external service.

Note that if you have your own Gemini capsule, you could ALSO simply store the remote bookmarks file on your server as well, negating even using a file syncing service at all. You would just point Lagrange at the Gemini address of your server where the file is stored and bookmark... save as bookmark source... etc. Very easy.

If anyone has any better ideas or improvements to this, do let me know!