desktop

package
v0.0.0-...-8379ce7 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2024 License: Unlicense Imports: 3 Imported by: 0

Documentation

Overview

Package desktop implements encoding and decoding of Linux desktop entries.

Refer to the following document for the complete format specification: https://specifications.freedesktop.org/desktop-entry-spec/desktop-entry-spec-latest.html

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EscapeExec

func EscapeExec(args []string) string

EscapeExec applies quoting and escaping rules to the command line arguments specified by args, and returns a single, sanitized command line. The resulting command line must be sanitized as a string with EscapeString before embedding into a Linux desktop entry.

func EscapeString

func EscapeString(s string) string

EscapeString returns a sanitized version of s.

func ExpandExec

func ExpandExec(args []string, opts Opts) []string

ExpandExec expands any format specifiers in the unescaped command-line arguments specified by args, using the provided information in opts.

func Get

func Get(group any, key string, locale Locale) (any, error)

Get attempts to get the value associated with the specified key in the specified group, for locale. Returns an error if the key is not found.

func Groups

func Groups(v any) []any

Groups returns a slice of key-value pair groups from the desktop entry at v.

func Marshal

func Marshal(v any) ([]byte, error)

Marshal returns the Linux desktop entry encoding of v.

func UnescapeExec

func UnescapeExec(cmd string) []string

UnescapeExec reverses any quoting and escaping rules applied to the command line arguments in cmd, and returns a slice of command-line arguments.

func UnescapeString

func UnescapeString(s string) string

UnescapeString returns s in its original form.

func Unmarshal

func Unmarshal(data []byte, v any) error

Unmarshal parses the encoded desktop entry and stores the result in the value pointed to by v.

Types

type Locale

type Locale struct {
	Lang     string
	Country  string
	Encoding string
	Modifier string
}

Locale represents a valid locale for a desktop entry.

func ParseLocale

func ParseLocale(s string) (Locale, error)

ParseLocale returns a Locale for string s, which must be of the form lang_COUNTRY.ENCODING@MODIFIER

type Opts

type Opts struct {
	// File will expand the `%f` format specifier. It is a single file path
	// (even if multiple file paths are provided to the application launcher. If
	// File is a URL, the file will be downloaded and `%f` will expand to the
	// path to the downloaded temporary file.
	File string
	// Like File, but will expand the `%F` format specifier, and may include
	// multiple files which will expand to several command-line arguments.
	Files []string
	// URL will expand the `%u` format specifier. It is a single URL. Locally
	// available files may either be passed as `file://` URLs or as a Unix file
	// path.
	URL string
	// Like URL, but will expand the `%U` format specifier and may include
	// multiple URLs which will expand to several command-line arguments.
	URLs []string
	// Icon will expand the `%i` format specifier. It represents the value of
	// the desktop entry Icon key.
	Icon string
	// Name will expand the `%c` format specifier. It represents the appropriate
	// localized value of the desktop entry Name key.
	Name string
	// Path will expand the `%k` format specifier. It represents the path to the
	// desktop entry as either a URI (if accessed through Linux-specific
	// filesystems not attached to the system file view), a Unix file path, or
	// an empty string if no location is known.
	Path string
}

Opts represents the possible arguments that an Exec format specifier may expand to.

Jump to

Keyboard shortcuts

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