Documentation
¶
Overview ¶
Package source provides the two concrete shell.AppSource implementations that feed the desktop shell: the native xdgSource (source_xdg.go, !js), which scans a real XDG filesystem, and the embeddedSource (this file), which serves a curated app set, icon set and virtual file listing from an embed.FS. The embedded source is what makes the shell portable to the browser (js/wasm), where no real filesystem exists — the same shell/render composition renders a real, populated desktop with data baked into the binary.
Index ¶
- type Darwin
- func (d *Darwin) Apps() *shell.AppIndex
- func (d *Darwin) Dir() *shell.Dir
- func (d *Darwin) IconBytes(name string) ([]byte, bool)
- func (d *Darwin) Menu() *shell.MenuModel
- func (d *Darwin) Resolve(name string, content []byte) shell.OpenWith
- func (d *Darwin) Resolver() *shell.Resolver
- func (d *Darwin) ThumbKey(it shell.FileItem) string
- type DarwinOptions
- type Embedded
- type XDG
- func (x *XDG) Apps() *shell.AppIndex
- func (x *XDG) Dir() *shell.Dir
- func (x *XDG) IconBytes(name string) ([]byte, bool)
- func (x *XDG) Menu() *shell.MenuModel
- func (x *XDG) Resolve(name string, content []byte) shell.OpenWith
- func (x *XDG) Resolver() *shell.Resolver
- func (x *XDG) ThumbKey(it shell.FileItem) string
- type XDGOptions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Darwin ¶ added in v0.6.0
type Darwin struct {
// contains filtered or unexported fields
}
Darwin is the native macOS shell.AppSource: the darwin peer of the XDG source. It enumerates the .app bundles under the standard application directories, reads each bundle's Contents/Info.plist (binary or XML), decodes its .icns icon to a PNG, groups the apps by their LSApplicationCategoryType into the application menu, and lists the user's home directory into the file grid — exposing all of it through the identical AppSource seam, so the exact same shell/render composition renders a populated desktop of REAL macOS apps.
It only builds the app model; launching an app (the `open -a` action captured in each entry's Exec) is the shell's native-only job, never performed here.
func NewDarwin ¶ added in v0.6.0
func NewDarwin(o DarwinOptions) *Darwin
NewDarwin scans the macOS application directories and builds the native source. Like NewXDG it never fails: an unreadable directory, a bundle with no Info.plist and a missing or non-PNG icon each degrade gracefully rather than aborting the scan.
func (*Darwin) Dir ¶ added in v0.6.0
Dir returns the classified home-directory listing (nil when unreadable).
func (*Darwin) IconBytes ¶ added in v0.6.0
IconBytes returns the PNG bytes for an app's icon key, or reads an absolute path (a thumbnail cache file) directly, and ok=false when neither resolves.
func (*Darwin) Resolve ¶ added in v0.6.0
Resolve answers "open with" for a bare name plus content bytes.
type DarwinOptions ¶ added in v0.6.0
type DarwinOptions struct {
// Dir is the directory shown in the file grid (empty -> the user home).
Dir string
// IconSize is retained for parity with XDGOptions; the icns reader already
// picks the largest embedded representation, so it currently only documents
// intent.
IconSize int
// contains filtered or unexported fields
}
DarwinOptions parametrises the macOS scan.
type Embedded ¶
type Embedded struct {
// contains filtered or unexported fields
}
Embedded is the browser-facing shell.AppSource: a curated set of desktop entries, an application menu, a small virtual directory and the icons for all of them, served from an embed.FS with no filesystem access. It renders the identical shell/render composition the native xdgSource does.
func NewEmbedded ¶
func NewEmbedded() *Embedded
NewEmbedded builds the curated, filesystem-free shell.AppSource.
func (*Embedded) IconBytes ¶
IconBytes resolves an icon name (or a "thumb-*" key) to its embedded PNG bytes, falling back through the mime name to a generic icon so a cell always gets a real image rather than a placeholder when a specific icon is absent.
type XDG ¶
type XDG struct {
// contains filtered or unexported fields
}
XDG is the native shell.AppSource: it scans a real XDG filesystem exactly as the shell always has — desktopentry.Scan for the app index, menu.Load for the categorized menu, mime + mimeapps for "open with", go-thumbnail for thumbnails and an icontheme.Theme for icons — and exposes it through the portable AppSource seam so the identical shell/render composition runs on a real Linux desktop and in the browser alike.
func NewXDG ¶
func NewXDG(o XDGOptions) *XDG
NewXDG scans the filesystem and builds the native source. It never fails: a missing MIME database, unreadable menu or unreadable directory each degrade to an empty-but-valid model, exactly as the shell's original buildScene did.
func (*XDG) IconBytes ¶
IconBytes resolves an icon name (or absolute path) to its encoded file bytes through the icon theme, and ok=false when it cannot be found or read.
type XDGOptions ¶
type XDGOptions struct {
// Dir is the directory shown in the file grid (empty -> the user home,
// then the working directory, then the filesystem root).
Dir string
// IconTheme is the icon-theme name (empty -> hicolor).
IconTheme string
// IconSize is the nominal icon size requested from the theme (0 ->
// render.DefaultIconSize's 48).
IconSize int
}
XDGOptions parametrises the native filesystem scan.