Documentation
¶
Overview ¶
Package flatpakapp is what the Flatpak org.frostyard.Frostnotes keeps beside notesd: where its files live, the end of notesd's log, and the setting for background activity (docs/design/app.md#the-flatpak). notesctl reads and changes them. It imports no UI.
Index ¶
- Constants
- func Ask(ctx context.Context, getenv Getenv) error
- func Change(getenv Getenv, keepRunning bool) (uint64, error)
- func ConfigDir(getenv Getenv) (string, error)
- func InFlatpak(getenv Getenv) bool
- func StateDir(getenv Getenv) (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 Ask ¶
Ask runs the Background portal's request helper and waits until it exits: it stays on the bus until the portal answers, at most 10 minutes, and the portal drops a request whose caller left. The helper reads the setting itself, writes its outcome for GetBackground and always exits 0; Ask fails only when it cannot run it, or when ctx ends first. Its output is appended to background.log in the state directory.
func Change ¶
Change writes the setting and counts the change, in the Flatpak only. It answers the change's number: an answer of the portal whose generation is at least that read the new setting. Ask then asks the portal.
func ConfigDir ¶
ConfigDir is $XDG_CONFIG_HOME/frostnotes, else ~/.config/frostnotes: in the Flatpak, the app's own, which all of its sandboxes share.
Types ¶
type Background ¶
type Background struct {
// KeepRunning: the portal may start notesd at login, and notesd keeps
// syncing with no client.
KeepRunning bool `json:"keepRunning"`
Portal *PortalAnswer `json:"portal"`
// Generation is this change's number, 0 from GetBackground and when
// the helper could not start.
Generation uint64 `json:"generation,omitzero"`
}
Background is the setting and the portal's last answer.
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, starts the Background portal's request without waiting for it, and answers the new state. A process that stays in its sandbox until the portal answers, as a window does, can use it; one that exits sooner uses Change and Ask.
type NotesdLog ¶
type NotesdLog struct {
Path string `json:"path"`
// LastLine is the log's last line that holds text, "" for none.
LastLine string `json:"lastLine"`
// Lines are the log's last lines that hold text, at most 10, oldest
// first; LastLine is the last of them.
Lines []string `json:"lines"`
// PortalRefused says that line is the launcher's: the Flatpak portal
// did not start notesd.
PortalRefused bool `json:"portalRefused"`
}
NotesdLog is what notesd.log says of 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.