source

package
v0.16.0 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2026 License: BSD-3-Clause Imports: 20 Imported by: 0

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

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

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) Apps

func (e *Embedded) Apps() *shell.AppIndex

Apps returns the curated app index.

func (*Embedded) Dir

func (e *Embedded) Dir() *shell.Dir

Dir returns the virtual directory listing.

func (*Embedded) IconBytes

func (e *Embedded) IconBytes(name string) ([]byte, bool)

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.

func (*Embedded) Menu

func (e *Embedded) Menu() *shell.MenuModel

Menu returns the curated application menu.

func (*Embedded) Resolve

func (e *Embedded) Resolve(name string, _ []byte) shell.OpenWith

Resolve classifies name by extension and returns its curated associations. content is unused (the embedded set carries no magic bytes), so this is a pure name-based classification — enough to drive the file grid + an "open with" menu in the browser.

func (*Embedded) ThumbKey

func (e *Embedded) ThumbKey(it shell.FileItem) string

ThumbKey returns the embedded thumbnail asset key for an image file (mapping the two curated photos to their preview PNGs), or "" for anything else.

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) Apps

func (x *XDG) Apps() *shell.AppIndex

Apps returns the scanned app index.

func (*XDG) Dir

func (x *XDG) Dir() *shell.Dir

Dir returns the classified directory listing (nil when unreadable).

func (*XDG) IconBytes

func (x *XDG) IconBytes(name string) ([]byte, bool)

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.

func (*XDG) Menu

func (x *XDG) Menu() *shell.MenuModel

Menu returns the loaded application menu.

func (*XDG) Resolve

func (x *XDG) Resolve(name string, content []byte) shell.OpenWith

Resolve answers "open with" for a bare name plus content bytes.

func (*XDG) Resolver

func (x *XDG) Resolver() *shell.Resolver

Resolver returns the MIME/association resolver (so the native binary can answer "open with" for an arbitrary path).

func (*XDG) ThumbKey

func (x *XDG) ThumbKey(it shell.FileItem) string

ThumbKey returns the on-disk thumbnail cache path for an image item when the thumbnail has already been generated, or "" otherwise (a directory, a non- image, or a not-yet-thumbnailed file).

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.

Jump to

Keyboard shortcuts

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