Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Idea: linux-app should use ~/.config for anything that needs write access #1410

Open
GeopJr opened this issue Oct 2, 2021 · 2 comments
Labels
Enhancement New feature or request

Comments

@GeopJr
Copy link

GeopJr commented Oct 2, 2021

Summary

linux-app should use $XDG_CONFIG_HOME and $HOME/.config to save everything that requires write access.

How important this is to me and why

Importance: High

Use cases:

  1. Distribute as a package
  2. Per-user config and database

Additional context/similar features

I've spent some time working on packaging focalboard into the following formats: rpm, deb, flatpak
While everything is going as planned there's a major issue; apps don't have write access to their installed location by default (in focalboard's case, /opt/focalboard-app).

While there might be workarounds, the best practice would be to move anything that requires write access to .config (dbconfig & filespath (?)). Doing so will also allow each user to have their own .db as well as ease backups and restores.

From a look at the source, it seems that config.json is being ignored (for the app at least).

Here's some solutions I came up with:

  • Use the values from the config.json in combination with the hardcoded ones.
  • Use cli flags or env vars to override them
  • Change the hardcoded value to use ~/.config
// linux/main.go
...
func runServer(port int) (*server.Server, error) {
	logger, _ := mlog.NewLogger()
+	configFolder := os.Getenv("XDG_CONFIG_HOME")
+	if len(configFolder) == 0 {
+		configFolder = os.Getenv("HOME") + "/.config"
+	}

+	configFolder = configFolder + "/focalboard-app"

+	if _, err := os.Stat(configFolder); os.IsNotExist(err) {
+		_ = os.Mkdir(configFolder, 0755)
+	}

	config := &config.Configuration{
		ServerRoot:              fmt.Sprintf("http://localhost:%d", port),
		Port:                    port,
		DBType:                  "sqlite3",
+		DBConfigString:          configFolder + "/focalboard.db",
		UseSSL:                  false,
		SecureCookie:            true,
		WebPath:                 "./pack",
		FilesDriver:             "local",
+		FilesPath:               configFolder + "/focalboard_files",
		Telemetry:               true,
		WebhookUpdate:           []string{},
		SessionExpireTime:       259200000000,
		SessionRefreshTime:      18000,
		LocalOnly:               false,
		EnableLocalMode:         false,
		LocalModeSocketLocation: "",
		AuthMode:                "native",
	}
...

Some notes on them:

After a solution to this is found, I'll be able to continue working on packaging focalboard in more formats (rpm, deb, flatpak, appimage, snap).

@GeopJr GeopJr added the Enhancement New feature or request label Oct 2, 2021
@CodeCubeNeo
Copy link

I strongly agree, any updates on this? My main point also being to distribute this app as a flatpak!

@skewballfox
Copy link

skewballfox commented Jan 12, 2023

while I mostly agree, $XDG_CONFIG_HOME (i.e. ~/.config) is for configuration files whereas $XDG_DATA_HOME (i.e. ~/.local/share) is where applications store state.

Though there are applications that ignore this and use config home for both, (vscode and obsidian come to mind). I'd definitely appreciate following spec though.

here's the relevant spec if you want more info

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants