Plover GitHub Dictionaries

Plover dictionaries on GitHub

2021-02-03

First page of commits.In ten days, I've already made 200 commits (though a lot of it is diagnosing and testing).

I like to use Plover on my main laptop at home as well as on my tablet I bring to school. But it's a good idea to keep the dictionaries synced across my devices, so I've looked for different solutions. At first, I decided to keep a main folder on my file server, and have a bash script in the background to sync the local dictionaries on a device with that file server.

At first, I tried it by mounting the folder with sshfs and using a script to check if a file had been modified more recently. This would update either the local or the server version to keep it up-to-date. This worked okay, but I didn't like the idea of having to keep a folder mounted on my devices. If the network connection died while updaing, some weird stuff might happen and it just didn't seem like such a clean solution.

I had also wanted to dabble with git for a while, but I didn't originally want to use git because I had no idea how to implement something like that. But I finally decided to dive in and have a look. As it turns out, git is actually perfect for this job.

I had wanted to keep a git repository on my file server, but to keep things simple for now, I just used GitHub. This way, it's also easy to view history via the web interface and I could easily check stuff on my phone if I wanted to. I also didn't feel like finding out how to access git repos on an ssh file server. I'm sure it's simple, but I'm lazy!

I set up a local git repository in ~/.config/plover/I run Plover from source, and so the location for the dictionaries is different than on the two year old AppImage version which is in ~/.local/share/plover/. on all my devices and uploaded all the dictionaries to a private GitHub repository. This would be the upstream location.

For the syncing aspect, I found a script here which does exactly what I need. I modified it slightly so that it first checks for the network connection, and also delivers a notification if the local dictionaries are updated.This is because Plover first loads the dictionaries into memory, and so any updates to files on the disk would require a Plover refresh if it's running. If there's no network connectivity, the code just loops back and waits until there is a network connection. The way I check for connectivity is with ping, and I'm not sure if that's the best way to do so, but it has worked so far.

You can see the code on pastebin: https://pastebin.com/pUHZTA3M.

One "issue" I have with this is that the script pushes all commits to the GitHub repository as soon as any changes are made to the files. This is not ideal if I make a change to a dictionary, save it, and then make another change right after and save it again. This would result in two commits. I should probably add some sort of delay so that the repository isn't spammed with commits, but I haven't really thought of it as a big problem, so for now it'll just be like this.

It would be also be nice if the commit message had something a little more insightful than just "Auto-Commit", but I couldn't be bothered to work on this anymore. If it ain't broke, don't fix it! Overall I'm just really pleased with it and it works well enough.

If you use Plover a lot on several devices, this is a great way to sync your dictionaries. Of course, there are things like Dropbox and Google Drive where you can mount (?) folders easily, but I didn't want to do that because I'm not sure how well they would work with being offline, and also just connecting a Google account or Dropbox to my Linux desktop is not really something that appeals to me.

One other benefit with git reposetories, however, is that you can view the history really easily and it provides a lot of insight if you're interested in that sort of thing. It's nice to know when you added a certain entry, or removed something.


Back