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 ¶
- func EscapeExec(args []string) string
- func EscapeString(s string) string
- func ExpandExec(args []string, opts Opts) []string
- func Get(group any, key string, locale Locale) (any, error)
- func Groups(v any) []any
- func Marshal(v any) ([]byte, error)
- func UnescapeExec(cmd string) []string
- func UnescapeString(s string) string
- func Unmarshal(data []byte, v any) error
- type Locale
- type Opts
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EscapeExec ¶
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 ¶
EscapeString returns a sanitized version of s.
func ExpandExec ¶
ExpandExec expands any format specifiers in the unescaped command-line arguments specified by args, using the provided information in opts.
func Get ¶
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 UnescapeExec ¶
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 ¶
UnescapeString returns s in its original form.
Types ¶
type Locale ¶
Locale represents a valid locale for a desktop entry.
func ParseLocale ¶
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.