flatpakapp

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2026 License: MIT Imports: 15 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 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

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 Ask

func Ask(ctx context.Context, getenv Getenv) error

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

func Change(getenv Getenv, keepRunning bool) (uint64, error)

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

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 this process runs in the app's own Flatpak.

func StateDir

func StateDir(getenv Getenv) (string, error)

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

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: 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 Getenv

type Getenv func(string) string

Getenv reads the environment; tests pass their own.

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

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