desktop

package module
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2020 License: MIT Imports: 13 Imported by: 3

README

desktop

GoDoc CI status Donate

Desktop entry scanner and parser

Linux is currently the only supported operating system. Windows support is planned.

Documentation

Documentation is available via gdooc.

Support

Please share issues and suggestions here.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DataDirs

func DataDirs() []string

DataDirs returns a slice of directories where desktop entries are stored.

func RunScript

func RunScript(exec string) (string, error)

RunScript creates a temporary run script consisting of a bash script which removes itself and executes the specified command.

func Scan

func Scan(dirs []string) ([][]*Entry, error)

Scan non-recursively scans provided directories for desktop entry files and parses them. A slice of parsed entries is returned for each directory.

Types

type Entry

type Entry struct {
	// Type is the type of the entry. It may be Application, Link or Directory.
	Type EntryType

	// Name is the name of the entry.
	Name string

	// GenericName is a generic description of the entry.
	GenericName string

	// Comment is extra information about the entry.
	Comment string

	// Icon is the path to an icon file or name of a themed icon.
	Icon string

	// Path is the directory to start in.
	Path string

	// Exec is the command(s) to be executed when launched.
	Exec string

	// URL is the URL to be visited when launched.
	URL string

	// Terminal controls whether to run in a terminal.
	Terminal bool
}

Entry represents a parsed desktop entry.

func Parse

func Parse(content io.Reader, buf []byte) (*Entry, error)

Parse reads and parses a .desktop file into an *Entry.

func (*Entry) ExpandExec

func (e *Entry) ExpandExec(args string) string

ExpandExec fills keywords in the provided entry's Exec with user arguments.

type EntryType

type EntryType int

EntryType may be Application, Link or Directory.

const (
	Unknown     EntryType = iota // Unspecified or unrecognized
	Application                  // Execute command
	Link                         // Open browser
	Directory                    // Open file manager
)

All entry types

func (EntryType) String

func (t EntryType) String() string

Jump to

Keyboard shortcuts

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