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 ¶
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 ¶
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 ¶
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.