system

package
v0.7.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 18, 2026 License: MIT Imports: 19 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

View Source
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

func ConfigDir(getenv Getenv) (string, error)

ConfigDir is $XDG_CONFIG_HOME/frostnotes, else ~/.config/frostnotes: in the Flatpak, the app's own, which all of its sandboxes share.

func InFlatpak

func InFlatpak(getenv Getenv) bool

InFlatpak reports whether the app runs in its own Flatpak.

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 StateDir

func StateDir(getenv Getenv) (string, error)

StateDir is $XDG_STATE_HOME/frostnotes, else ~/.local/state/frostnotes.

func StopOnExit

func StopOnExit(ctx context.Context, getenv Getenv)

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

func VaultFile(root, p string) (string, error)

VaultFile resolves p inside the vault folder root to a file Open in default app may open.

func WebURL

func WebURL(raw string) (string, error)

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).

func WriteFile

func WriteFile(path string, data []byte) error

WriteFile writes data to path atomically: a temporary file in the same directory, then a rename, so a crash leaves the old file or the new one.

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 Getenv

type Getenv func(string) string

Getenv reads the environment; tests pass their own.

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

func ReadNotesdLog(getenv Getenv) (log NotesdLog, ok bool)

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL