Posts

Logseq and Syncthing

Oct 28, 2023 | 7 minutes to read

Today I think I may have solved a real problem I’ve been having, namely how I can keep notes I take on all my devices in sync. I have used various note taking apps on my PCs for a while but keeping my notes in sync between my two PCs and my phone has always been a challenge. At work, I use OneNote from MS and it’s great. But it’s not open source, and there is no eay way to run it natively on Linux (my home PC’s OS) and there’s definitely no way to sync notes between OneNote and any other application. So, I am stuck with just trying to sync notes between my Home PC and my phone. To date, I’ve been using Joplin and syncing its database to Dropbox, but that was slow and didn’t always work well, for some reason I could never figure out. Sooo…. I’ve been looking for a better note take app and a way to sync my notes across these devices, for a while now.

logseq

I looked around, and found that a number of people swear by a note-taking app called Logseq. Not the prettiest name, but it turns out, it’s a very nice and capable note taking app. It is open source and, very important to me, it saves all of your notes into plain text markdown (.md) files, and saves any images or other attachments as files too. This is great because then I can version control those files using my local ForgeJo git repo as I make edits over time. (This is all very geeky, I know, but well… :)

There are two things to know about Logseq though:

  • There’s a mobile version for Android but it’s not available in either the Google Play store or F-Droid.
  • There’s no file synching built into Logseq so if you want to share notes among your devices, you have to figure that out on your own.

For the first problem, you just have to download the .APK file from the Logseq app’s web site on your phone. When you do this, and then try to open that file, your browser (preferably Firefox of course) will complain that you’re not allowed to open APK files from random web site, but you can quickly change the setting to allow that for just this one web site, and then - boom! - the app is installed on your phone.

For the second issue, some quick research revealed that there’s a very nice tool which is prefectly suited to syncing files between your own devices - Syncthing. With this tool on your phone and other cumputing devices, any folders or files you choose to sync will be kept up to date auto-magically as you work in the Logseq app.

So here then are the steps I followed today to get Logseq and Syncthing set up on all of my devices. I did this on my Ubuntu desktop PC, my Ubuntu server PC and my Android phone. There are IOS and Windows versions of both apps too.

  • On my Ubuntu desktop PC:

    sudo apt update
    
    sudo apt install syncthing 
    
    sudo systemctl start syncthing@peter
    
    sudo systemctl enable syncthing@peter
    (that makes it run after a reboot)
    
    

    In the Unbuntu UI, visit the logseq.com/downloads page and download the .AppImage file for my OS.

    Then, I followed steps you’ll find online to create a .desktop shortcut file for the AppImage to make it run just like any other app installed on my PC.

    By default, when you first install Syncthing, the web GUI is only accessible on the same PC, via the localhost IP address - 127.0.0.1. For me, that’s OK on this desktop PC so I left that alone here. (I change that on my server below) You can edit the Syncthing config.xml file as you like. This page tells you what you can change: https://docs.syncthing.net/users/config.html

    If you have a Windows PC, the above process is very similar, except you install Syncthing via the GUI or chocolately or something like that.

  • On my Ubuntu server (optional, but useful for me):

    sudo apt update
    
    sudo apt install syncthing
    
    sudo systemctl start syncthing@peter
    
    sudo systemctl enable syncthing@peter
    (that makes it run after a reboot)
    
    nano ~/.config/syncthing/config.xml
    (Edit that config file, change the IP address syncthing listens on to the server's IP, e.g. 192.168.0.44 or whatever)
    
    

    I did not install Logseq on my server, since it’s a client app.

    Now Syncthing is running on my server (which is where my backups are made) and the web GUI is listening on port 8384 by default.

  • On my Android 10 phone:

    Visit the logseq web site, choose your mobile OS (Android for me), and choose to download the Android .APK file.

    Tell your browser you want to open that file, go into Settings when prompted and allow installs from this site, then install the APK file.

    If you don’t already have it, install the F-Droid application from the Google Play Store or from the F-Droid web site. You will need to grant it access to allow this.

    Run the F-Droid app on your phone. Search its repos for Syncthing and install the app.

Now, I have Logseq installed on my phone and my desktop PC. And I have Syncthing installed on all of the devices I want to keep in sync. For the remaining steps, I’m just going to tell Syncthing that I want to keep my Logseq files synced between my PC, server and phone. There are lots of tutorials online for how to do this, so I’m not going to provide all the details here - just the overview.

  • Now I got a new Logseq “graph” started and saved it into a folder on my desktop PC.

    • Run Logseq on the desktop PC. It will tell you to choose a folder to store its files. I selected “/home/peter/AndroidDocuments/PeterLogseq” (since I might want to sync other files in the future) as the name of that folder. Now I have a Logseq “graph” going (as they call the application’s file store).
  • Now I can sync that across all three devices.

    • Access the Syncthing web GUI on the desktop PC – http://127.0.0.1:8384, unless you changed it while installing above.
    • First, add a “Remote Device”.
      • I added both my Phone and my Server as remote devices.
      • On those devices, a pop up will appear asking if you want them to sync. Click Accept.
    • Then, from the desktop PC, “Add Folder”.
      • I set up the /home/peter/AndroidDocuments folder here.
      • I then shared that with both the server and the phone.
      • On those other devices, I accepted / added that folder for syncing, in Syncthing.
        • On the phone, I had to choose a local folder for those files to sync into and I found that I had to choose a folder on the phone’s storage for that to be read-write enabled.
        • When I tried to choose a folder on the SD Card, Android wasn’t allowing Syncthing to write to the folder.

And voila! Whatever files I update/save into the AndroidDocuments folder on my PC are now very quickly synced to the other two devices - and that includes anything I add in Logseq. So now I can edit my notes on either my PC or my phone and they show up on the other device right away.

I should note: This is all working with direct connections over wifi while I am at home. When I take my phone out into the world, the Syncthing connection won’t be able to reach the PC or the server though. For that, I already have a WireGuard VPN setup, which makes my phone act as if it’s still at home on my local network. I prefer this over trying to open ports in my router to allow Syncthing to reach my home computers over a non-secured network.

I hope these notes help anyone else thinking about setting up these great, free apps.


You can leave a comment on this post here.