desktop

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2026 License: MIT Imports: 11 Imported by: ? 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 desktop starts programs, opens URLs, uses the clipboard and finds per-user directories the way the current desktop platform expects.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Copy

func Copy(text string) error

Copy puts text on the clipboard, waiting for the clipboard tool to finish. It tries each installed tool in turn until one succeeds, as a tool can be installed but unusable, such as wl-copy in an X11 session.

func DataDir

func DataDir() (string, error)

DataDir returns the default directory for user-specific data files. Callers should create their own subdirectory within it. It need not exist yet.

On Linux and BSD it is $XDG_DATA_HOME, or ~/.local/share if that is unset or relative. On macOS it is ~/Library/Application Support, and on Windows %AppData%.

func Launch

func Launch(name string, args ...string) error

Launch starts a program detached from this one, in its own session (or process group on Windows) with no standard input or output, and returns without waiting for it. The program is reaped in the background once it exits, so it never lingers as a zombie.

func Open

func Open(url string) error

Open opens a URL or file with the desktop's default handler, started the same detached way as Launch. It refuses a url starting with "-", which the handler would take as an option; pass a file named that way as "./-name".

func RuntimeDir

func RuntimeDir() (string, error)

RuntimeDir returns the default directory for user-specific runtime files such as sockets and pipes. Callers should create their own subdirectory within it.

On Linux and BSD it is $XDG_RUNTIME_DIR, and an error if that is unset or relative as there is no safe default. On macOS and Windows it is os.TempDir.

func StateDir

func StateDir() (string, error)

StateDir returns the default directory for user-specific state that should persist but isn't worth backing up, such as logs and history. Callers should create their own subdirectory within it. It need not exist yet.

On Linux and BSD it is $XDG_STATE_HOME, or ~/.local/state if that is unset or relative. On macOS it is ~/Library/Application Support, and on Windows %LocalAppData%.

Types

This section is empty.

Jump to

Keyboard shortcuts

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