sqlectron / sqlectron-gui

A simple and lightweight SQL client desktop with cross database and platform support.
https://sqlectron.github.io/
MIT License
4.57k stars 524 forks source link

Use XDG basedir spec on linux #327

Closed jleclanche closed 7 years ago

jleclanche commented 7 years ago

https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html

TLDR: Configuration should be in the $XDG_CONFIG_HOME/sqlectron/ directory instead of in the homedir. If not defined, $XDG_CONFIG_HOME should be defaulted to $HOME/.config.

This is pretty standard and helps keep clutter out of the homedir :)

maxcnunes commented 7 years ago

Since we already have many users with their configuration at $HOME/.sqlectron.json. I believe it should follow this approach:

  1. Check if there is $HOME/.sqlectron.json 1.1. Yes - Load config from there. 1.2. No - Check if there is $XDG_CONFIG_HOME/sqlectron/config.json 1.2.1. Yes - Load config from there. 1.2.2. No - Create a config there and load config from there.
jleclanche commented 7 years ago

For what it's worth it looks like Electron does use xdg by default:

[23:52:43] adys@azura ~ % tree .config/Sqlectron           
.config/Sqlectron
├── GPUCache
│   ├── data_0
│   ├── data_1
│   ├── data_2
│   ├── data_3
│   └── index
├── Local Storage
└── Preferences

2 directories, 6 files
[23:52:48] adys@azura ~ % cat .config/Sqlectron/Preferences
{"brightray":{"media":{"device_id_salt":"2Hlo3B4A93z19AYKToAdzg=="}}}

I'm guessing there's probably an API you can use ...

jleclanche commented 7 years ago

https://electron.atom.io/docs/api/app/#appgetpathname