skyjake / lagrange

A Beautiful Gemini Client
https://gmi.skyjake.fi/lagrange/
BSD 2-Clause "Simplified" License
1.21k stars 65 forks source link

Better config directories layout to make synchronisation of data files easy #444

Open cjsthompson opened 2 years ago

cjsthompson commented 2 years ago

Hi,

Right now Lagrange on UNIX stores all it's data files in $XDG_CONFIG_DIR/.config/lagrange. I guess this is because it is easier to support macOS and Windows with this layout. However it would be a nice improvement to move some of these data files to ~/.cache/lagrange and ~/.local/share/lagrange for the following reasons:

The fonts directory, the idents directory, idents.lgr and bookmarks.ini could go in ~/.local/share/lagrange. This data can be shared between several computers independently even if those computers have different lagrange settings. But you might also explicitly not want to share this between computers with different operating systems some of which you trust less than others.

State.lgr and visited.2.txt could go in ~/.cache/lagrange so it would be as trivial as rm -rf'ing ~/.cache/lagrange to clean cached data which is easily recreated. This data you often don't want to share between several computers.

The prefs.cfg could be split into two files, with one of them for settings that are machine dependent such as "window.setrect" which is a problem to share between several computers that have different screen sizes such as a laptop with a smaller screen and a desktop with a huge screen.

This would make it easy to synchronize lagrange data files one might need between several computers with tools like rsync/syncthing instead of the various over-engineered syncing solutions for major web browsers that are bolted on top to sort through the disorganized data files.

skyjake commented 2 years ago

I like this idea. Splitting the configuration and files into multiple directories based on usage would have some nice benefits indeed. The current implementation is mostly for simplicity: there's just one directory to manage instead of multiple different ones.

This doesn't have to be XDG-specific, though. macOS has comparable directories like ~/Library/Caches/ and ~/Library/Preferences/ where some of the data could be placed. Windows has the Roaming and Local AppData directories, for example.

Migrating to a new runtime directory layout will require some careful management, though, and will likely not allow sharing data with earlier versions of the app.

cjsthompson commented 2 years ago

It's definitely not a set of changes to rush into. It takes a bit of thought to figure out a good layout for the data files that would be future proof. I just thought I'd share this idea I had yesterday while setting up lagrange on a laptop. I sync all my config files with syncthing and I didn't run into any other problems so far except for the window.setrect setting. But I haven't been in a situation yet where I'm running lagrange on two machines at the same time.

skyjake commented 2 years ago

Something to consider: the export/import feature in v1.12 could be leveraged to build an automated sync mechanism.