Add xdg config home functionality, documentation

This commit is contained in:
asdf 2019-11-12 16:08:57 +11:00
parent 198f357d1d
commit 0239fdceba
2 changed files with 60 additions and 12 deletions

View File

@ -199,7 +199,7 @@ Writes data from a given url to a file. The file is named by the last component
write [link id]
Writes data from a given link id in the current document to a file. The file is named by the last component of the url path. If the last component is blank or \fI/\fP a default name will be used. The file saves to the directory set by the \fIsavelocation\fP setting. \fIw\fP can be entered rather than the full \fIwrite\fP.
.SH FILES
\fBbombadillo\fP keeps a hidden configuration file in a user's home directory. The file is a simplified ini file titled \fI.bombadillo.ini\fP. It is generated when a user first loads \fBbombadillo\fP and is updated with bookmarks and settings as a user adds them. The file can be directly edited, but it is best to use the SET command to update settings whenever possible. To return to the state of a fresh install, simply remove the file and a new one will be generated with the \fBbombadillo\fP defaults. On some systems an administrator may set the configuration file location to somewhere other than a user's home directory. If you do not see the file where you expect it, contact your system administrator.
\fBbombadillo\fP keeps a hidden configuration file in a user's XDG configuration directory. The file is a simplified ini file titled \fI.bombadillo.ini\fP. It is generated when a user first loads \fBbombadillo\fP and is updated with bookmarks and settings as a user adds them. The file can be directly edited, but it is best to use the SET command to update settings whenever possible. To return to the state of a fresh install, simply remove the file and a new one will be generated with the \fBbombadillo\fP defaults. On some systems an administrator may set the configuration file location to somewhere other than the default setting. If you do not see the file where you expect it, or if your settings are not being read, try \fI:check configlocation\fP to see where the file should be, or contact your system administrator for more information.
.SH SETTINGS
The following is a list of the settings that \fBbombadillo\fP recognizes, as well as a description of their valid values.
.TP

View File

@ -1,31 +1,79 @@
package main
import (
"os"
"os/user"
"path/filepath"
)
var userinfo, _ = user.Current()
var defaultOptions = map[string]string{
// The configuration options below control the default settings for
// users of Bombadillo.
//
// General configuration options
// Changes take effect when Bombadillo is built. Follow the standard
// install instructions after making a change.
//
// Edit these values before compile to have different default values
// ... though they can always be edited from within bombadillo as well
// it just may take more time/work.
// Most options can be changed by a user in the Bombadillo client, and
// changes made here will not overwrite an existing user's settings.
// The exception to both cases is "configlocation" which controls where
// .bombadillo.ini is stored. If you make changes to this setting,
// consider moving bombadillo.ini to the new location as well, so you
// (or your users) do not loose bookmarks or other preferences.
//
// To change the default location for the config you can enter
// any valid path as a string, if you want an absolute, or
// concatenate with the main default: `userinfo.HomeDir` like so:
// "configlocation": userinfo.HomeDir + "/config/"
// Further explanation of each option is available in the man page.
// Basic Usage
//
// Any option can be defined as a string, like this:
// "option": "value"
//
// Options can also have values calculated on startup. There are two
// functions below that do just this: homePath() and xdgConfigPath()
// You can set any value to use these functions like this:
// "option": homePath()
// "option": xdgConfigPath()
// See the comments for these functions for more information on what
// they do.
//
// You can also use `filepath.Join()` if you want to build a file path.
// For example, specify "~/bombadillo" like so:
// "option": filepath.Join(homePath(), bombadillo)
// Moving .bombadillo.ini out of your home directory
//
// To ensure .bombadillo.ini is saved as per XDG config spec, change
// the "configlocation" as follows:
// "configlocation": xdgConfigPath()
"homeurl": "gopher://bombadillo.colorfield.space:70/1/user-guide.map",
"savelocation": userinfo.HomeDir,
"savelocation": homePath(),
"searchengine": "gopher://gopher.floodgap.com:70/7/v2/vs",
"openhttp": "false",
"telnetcommand": "telnet",
"configlocation": userinfo.HomeDir,
"configlocation": xdgConfigPath(),
"theme": "normal", // "normal", "inverted"
"terminalonly": "true",
"tlscertificate": "",
"tlskey": "",
"lynxmode": "false",
}
// homePath will return the path to your home directory as a string
// Usage:
// "configlocation": homeConfigPath()
func homePath() string {
var userinfo, _ = user.Current()
return userinfo.HomeDir
}
// xdgConfigPath returns the path to your XDG base directory for configuration
// i.e the contents of environment variable XDG_CONFIG_HOME, or ~/.config/
// Usage:
// "configlocation": xdgConfigPath()
func xdgConfigPath() string {
configPath := os.Getenv("XDG_CONFIG_HOME")
if configPath == "" {
return filepath.Join(homePath(), ".config")
}
return configPath
}