host

package
v1.0.31-alpha.1 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2026 License: Apache-2.0 Imports: 21 Imported by: 1 module, 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 host has the platform services of giode.App that don't need its window, for apps that host Giode themselves - in a GLFW window, as an embedded view (see docs/low-level.md): keeping the screen on, the single-instance lock, and the clipboard bridge between Gio's input router and the host's clipboard. App uses them too. The package doesn't import gioui.org/app.

Index

Constants

View Source
const WaitArg = "--giode-wait-pid="

WaitArg is the argument an app restarted with other rights (see giode's App.RestartElevated) gets before its own, naming the old process to wait for: elevation (UAC, pkexec, an administrator prompt) doesn't pass the environment on.

Variables

View Source
var ErrNotSupported = errors.New("giode: not supported on this platform")

ErrNotSupported is returned by features the current platform lacks. giode.ErrNotSupported is the same error.

Functions

func KeepAwake

func KeepAwake(reason string) (release func(), err error)

KeepAwake keeps the computer from sleeping while idle until release is called: a systemd-logind inhibitor lock, listed with reason.

func KeepScreenOn

func KeepScreenOn(on bool) error

KeepScreenOn keeps the screen from dimming and locking while on is set: the freedesktop screen saver inhibition.

func ServeClipboard

func ServeClipboard(router *input.Router, read func() string, write func(text string))

ServeClipboard connects Gio's input router to the host's clipboard (GLFW's, the OS's): text components copy (editors, SelectionArea, kit.WriteClipboard) goes to write, and their paste requests are answered with read's text. Call it every frame, after router.Frame. giode.App's window does this itself.

func TakeWaitArg

func TakeWaitArg() int

TakeWaitArg removes WaitArg from os.Args and returns its pid, or 0.

func WaitForUpdate

func WaitForUpdate()

WaitForUpdate waits, in an app restarted by an update (see the update package), for the old process to exit, so the new one takes over its files and lock. LockInstance calls it; an app without the lock calls it early in main.

Types

type InstanceLock

type InstanceLock struct {
	// contains filtered or unexported fields
}

InstanceLock is the single-instance lock of an application id, held by the first instance to start. Get it with LockInstance.

func LockInstance

func LockInstance(id string) *InstanceLock

LockInstance claims the single-instance lock for id (the app's id, "com.example.player"). When another live instance holds it, Running reports true: hand it this launch's arguments with Forward and exit. Otherwise this instance holds the lock: Serve receives later instances' arguments, and Release frees the lock on exit. An app restarted by an update first waits for the old process to exit.

func (*InstanceLock) Forward

func (l *InstanceLock) Forward(args []string) error

Forward hands args to the instance holding the lock, which gets them through its Serve function.

func (*InstanceLock) Release

func (l *InstanceLock) Release()

Release frees a lock this instance holds.

func (*InstanceLock) Running

func (l *InstanceLock) Running() bool

Running reports whether another instance holds the lock.

func (*InstanceLock) Serve

func (l *InstanceLock) Serve(fn func(args []string))

Serve calls fn, on its own goroutine, with the arguments of each later instance that forwards its launch. It does nothing when another instance holds the lock.

Jump to

Keyboard shortcuts

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