go-desktopenv

module
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2026 License: MIT

README

go-desktopenv

Go


What a packaged Go desktop app needs to reach its desktop: xdg-desktop-portal calls, Flatpak detection and host commands, per-user folders, console-less Windows children, Desktop Entry Exec values, an AppImage-free child environment, installed fonts, the system accent colour, the UI language, Windows shortcut files, URL scheme handling and browser native messaging. Module github.com/Rethunk-Tech/go-desktopenv, twelve packages: portal, flatpak, userdirs, desktopentry, nowindow, hostenv, fonts, sysaccent, locale, lnk, schemehandler and nativemessaging. Import only the ones you need; portal pulls in godbus, lnk go-ole on Windows, nowindow, fonts, sysaccent, locale, schemehandler and nativemessaging golang.org/x/sys on Windows, and schemehandler and nativemessaging go-safefs. The rest pull in no third-party code.

A Flatpak app needs --talk-name=org.freedesktop.Flatpak for flatpak; portals need nothing extra. A portal call waits on a user dialog until its context ends, so set a deadline. RetrieveSecret works only inside a Flatpak.

Quick start

go get github.com/Rethunk-Tech/go-desktopenv

A worked example and the contracts: HUMANS.md.

Features

  • portal: autostart, launchers, the per-app secret, desktop settings and notifications (with click and button actions), each bounded by your context
  • flatpak: detect a sandbox, run or build a command for the host, end the host child on cancel
  • userdirs: config and data folders per home, honouring only absolute environment values for the real home
  • desktopentry: escape, build and read Desktop Entry Exec= values
  • nowindow: no console window for a console child of a Windows GUI process
  • hostenv: a child process's environment without what an AppImage's AppRun injected
  • fonts: the installed font families, from fontconfig or the Windows registry
  • sysaccent: the desktop's accent colour as #rrggbb, from the DWM or the Settings portal
  • locale: the user's UI language as a BCP-47-ish tag, from the Windows preferred UI languages or LC_ALL, LC_MESSAGES and LANG
  • lnk: write a Windows .lnk with target, arguments, working folder, icon and description, read its arguments, list a folder's shortcuts
  • schemehandler: register a program for URL schemes (desktop entry and xdg-mime defaults, or HKCU classes), yield to an AppImage integrator's entry, hand each scheme back to its previous handler, forward a URL to that handler, and report who owns a scheme
  • nativemessaging: write, remove and check browser native-messaging host manifests for Chromium-family browsers and Firefox, and read and write the length-prefixed stdio frames

Documentation

Doc Audience
HUMANS.md Running and using the package
AGENTS.md Internals, invariants, and why
CONTRIBUTING.md Process — commits, tests, docs
SECURITY.md Vulnerability disclosure
CHANGELOG.md Release notes

License

MIT — see LICENSE. © 2026 Rethunk.Tech, LLC.

Directories

Path Synopsis
Package desktopentry escapes and reads the string values of a freedesktop Desktop Entry file, chiefly the Exec key.
Package desktopentry escapes and reads the string values of a freedesktop Desktop Entry file, chiefly the Exec key.
Package flatpak detects a Flatpak sandbox and runs commands on the host from inside one.
Package flatpak detects a Flatpak sandbox and runs commands on the host from inside one.
Package fonts lists the font families installed on this computer.
Package fonts lists the font families installed on this computer.
Package hostenv gives child processes the environment the program was started from, minus what an AppImage's AppRun injected for the bundle's own libraries.
Package hostenv gives child processes the environment the program was started from, minus what an AppImage's AppRun injected for the bundle's own libraries.
internal
hostfile
Package hostfile reaches the user's desktop configuration (mimeapps.list, browser manifests) where it lives: the plain file call outside a Flatpak, a host sh script through flatpak-spawn inside one, which is not granted those files.
Package hostfile reaches the user's desktop configuration (mimeapps.list, browser manifests) where it lives: the plain file call outside a Flatpak, a host sh script through flatpak-spawn inside one, which is not granted those files.
Package lnk writes and reads Windows .lnk shortcut files, the Windows counterpart of package desktopentry.
Package lnk writes and reads Windows .lnk shortcut files, the Windows counterpart of package desktopentry.
Package locale reads the language the user has chosen for their desktop.
Package locale reads the language the user has chosen for their desktop.
Package nativemessaging lets a browser extension start this program as a native-messaging host: it writes and removes the host manifests Chromium-family browsers and Firefox look for, reports whether each installed browser's manifest points at the program, and reads and writes the stdio frames the browser exchanges with the host.
Package nativemessaging lets a browser extension start this program as a native-messaging host: it writes and removes the host manifests Chromium-family browsers and Firefox look for, reports whether each installed browser's manifest points at the program, and reads and writes the stdio frames the browser exchanges with the host.
Package nowindow starts console programs from a GUI process without a console window.
Package nowindow starts console programs from a GUI process without a console window.
Package portal calls the xdg-desktop-portal interfaces a Flatpak app uses instead of writing host folders: the Background portal for starting at sign-in, DynamicLauncher for desktop launchers, Secret for a per-app master secret, Settings for desktop appearance values, and Notification for desktop notifications.
Package portal calls the xdg-desktop-portal interfaces a Flatpak app uses instead of writing host folders: the Background portal for starting at sign-in, DynamicLauncher for desktop launchers, Secret for a per-app master secret, Settings for desktop appearance values, and Notification for desktop notifications.
Package schemehandler registers a program as the user's handler of URL schemes, hands each scheme back to the handler it replaced, and forwards a URL to that handler.
Package schemehandler registers a program as the user's handler of URL schemes, hands each scheme back to the handler it replaced, and forwards a URL to that handler.
Package sysaccent reads the accent colour the operating system's desktop is set to.
Package sysaccent reads the accent colour the operating system's desktop is set to.
Package userdirs answers where a user's config and data folders are for a given home.
Package userdirs answers where a user's config and data folders are for a given home.

Jump to

Keyboard shortcuts

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