desktopsetup

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2026 License: MIT Imports: 8 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package desktopsetup writes and removes Emetos's own desktop entry and icon theme files, so that application menus and launchers show it (SPEC §16 "Desktop entry and icon"): the same files scripts/install-desktop.sh writes or removes, for the --install-desktop and --uninstall-desktop flags of cmd/emetos (SPEC §10.11), so that a user without a shell, or on a launcher whose PATH lacks go install's folder, can still add Emetos to their menu, or remove it, with the program itself.

Index

Constants

This section is empty.

Variables

View Source
var IconSizes = []int{16, 22, 24, 32, 48, 64, 128, 256, 512}

IconSizes are the icon sizes Install writes and Uninstall removes: the sizes assets/icons embeds, which are kit.AppIconSizes (internal/gui/kit, which desktopsetup, a core package, never imports).

Functions

This section is empty.

Types

type Icons

type Icons func(size int) (data []byte, ok bool)

Icons gives the PNG bytes of Emetos's own icon at size, and whether there is one. It is assets/icons.PNG, taken as a parameter so this package stays free of that package's embedded data and is easy to test with fakes.

type Result

type Result struct {
	// DesktopFile is the desktop entry under dirs.DataHome/applications. Empty when Uninstall found
	// none there.
	DesktopFile string
	// IconFiles are the icon files under dirs.DataHome/icons/hicolor, one per size in IconSizes that
	// Install had a picture for, or that Uninstall found there.
	IconFiles []string
}

Result tells which of Emetos's files Install wrote, or Uninstall removed.

func Install

func Install(ctx context.Context, dirs storage.Paths, appID string, template []byte, icons Icons, exe string) (Result, error)

Install writes Emetos's own desktop entry to <dirs.DataHome>/applications/<appID>.desktop, and its icon to <dirs.DataHome>/icons/hicolor/<N>x<N>/apps/<appID>.png for each size in IconSizes that icons has a picture for. template is the desktop entry as committed (assets.DesktopEntry()); every line that starts with "Exec=emetos " has that program replaced by exe, the absolute path of the running program. Missing folders are made with mode 0755 and every file gets mode 0644, each written through a temporary file renamed over the target, so a second call replaces the files of an earlier one. Install runs no command (scripts/install-desktop.sh also refreshes update-desktop-database and gtk-update-icon-cache when they are installed; a desktop environment picks up a new or changed file under $XDG_DATA_HOME on its own, a little later, without them).

The tags are InstallExeNotAbsolute, InstallExeUnsafe, InstallCanceled, InstallDirCreateFailed and InstallFileWriteFailed.

func Uninstall

func Uninstall(ctx context.Context, dirs storage.Paths, appID string) (Result, error)

Uninstall removes the files Install (or scripts/install-desktop.sh) wrote: the same <dirs.DataHome>/applications/<appID>.desktop and <dirs.DataHome>/icons/hicolor/<N>x<N>/apps/<appID>.png for each size in IconSizes. A file that is not there is not an error, and Result lists only the ones that existed and were removed. An icons/hicolor/<N>x<N> or its apps folder that Uninstall leaves empty is removed too, so a hicolor icon theme with other icons in it stays; that cleanup never fails Uninstall.

The tags are UninstallCanceled and UninstallRemoveFailed.

Jump to

Keyboard shortcuts

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