Documentation
¶
Overview ¶
Package system is what the desktop app needs of the system around it (plan 0009): where its files live, the end of notesd's log, and the Flatpak's background setting. It imports no UI.
Index ¶
- Constants
- func ConfigDir(getenv Getenv) (string, error)
- func InFlatpak(getenv Getenv) bool
- func OpenableExtensions() []string
- func StateDir(getenv Getenv) (string, error)
- func StopOnExit(ctx context.Context, getenv Getenv)
- func VaultFile(root, p string) (string, error)
- func WebURL(raw string) (string, error)
- func WriteFile(path string, data []byte) error
- type Background
- type Getenv
- type NotesdLog
- type PortalAnswer
Constants ¶
const PortalFailure = "frostnotes: notesd did not start through the Flatpak portal (flatpak-spawn)"
PortalFailure starts the line the launcher appends when no notesd answers after flatpak-spawn. internal/packagecheck pins it to the launcher.
Variables ¶
This section is empty.
Functions ¶
func ConfigDir ¶
ConfigDir is $XDG_CONFIG_HOME/frostnotes, else ~/.config/frostnotes: in the Flatpak, the app's own, which all of its sandboxes share.
func OpenableExtensions ¶
func OpenableExtensions() []string
OpenableExtensions are the extensions Open in default app opens: documents and media, never anything a desktop runs or a browser scripts.
func StopOnExit ¶
StopOnExit stops notesd when the app exits with the setting Off, so that Off holds also where the desktop's own background permission is on. Only the process that owns the window calls it, and only the Flatpak stops notesd: elsewhere notesd is a service of its own.
func VaultFile ¶
VaultFile resolves p inside the vault folder root to a file Open in default app may open.
func WebURL ¶
WebURL checks that raw may open in the system's browser and returns what to open: an http or https link with a host, or a mailto link as frostui.SanitizeMailto returns it (frostui's ADR-0010). That keeps only its addressees, subject and body, and drops whatever else it asks of the mail client, such as attaching a file, and its fragment, which a client might read as more fields (#200).
Types ¶
type Background ¶
type Background struct {
// KeepRunning: notesd keeps syncing after the last window closes, and
// the portal may start it at login.
KeepRunning bool
Portal *PortalAnswer
// Generation is this change's number, 0 from GetBackground and when
// the helper could not start.
Generation uint64
}
Background is the setting and the portal's last answer, for the window.
func GetBackground ¶
func GetBackground(getenv Getenv) (b Background, ok bool)
GetBackground reports the setting in the Flatpak; ok is false anywhere else, where notesd is a service the desktop and systemd run.
func SetBackground ¶
func SetBackground(getenv Getenv, keepRunning bool) (Background, error)
SetBackground writes the setting, asks the Background portal again, and answers the new state.
type NotesdLog ¶
type NotesdLog struct {
Path string
// LastLine is the log's last line that holds text, "" for none.
LastLine string
// PortalRefused says that line is the launcher's: the Flatpak portal
// did not start notesd.
PortalRefused bool
}
NotesdLog is what the window learns from notesd.log: why notesd is not running (docs/design/app.md#the-flatpak).
func ReadNotesdLog ¶
ReadNotesdLog reports the end of notesd.log in the Flatpak; ok is false anywhere else, where a notesd a person runs has its own log.
type PortalAnswer ¶
type PortalAnswer struct {
At string `json:"at"`
AutostartRequested bool `json:"autostartRequested"`
Response *uint8 `json:"response"`
Background *bool `json:"background"`
Autostart *bool `json:"autostart"`
Error *string `json:"error"`
Generation *uint64 `json:"generation"`
}
PortalAnswer is the portal's last message, as the helper wrote it.