desktop

package
v1.1.4 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2026 License: MIT Imports: 15 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 desktop holds the pieces of the Windows application that do not need Win32.

Index

Constants

View Source
const (
	DensityLarge    = "large"
	DensityStandard = "standard"
	DensityCompact  = "compact"
)

Variables

This section is empty.

Functions

func AutostartEnabled added in v1.1.1

func AutostartEnabled() bool

AutostartEnabled reports whether the program starts when the user logs in.

func DIBFromIcon

func DIBFromIcon(ico []byte) []byte

DIBFromIcon returns the image data of a single-image .ico (without the ICO header), which is what CreateIconFromResourceEx expects.

func FormatRate

func FormatRate(bytesPerSec int64, bits bool) string

FormatRate writes a speed given in bytes per second, either as bytes (КБ/с, МБ/с: binary prefixes, like sizes) or as bits (Кб/с, Мб/с: decimal prefixes, the way networks are measured).

func FormatRateIn added in v1.0.25

func FormatRateIn(bytesPerSec int64, bits, english bool) string

FormatRateIn is FormatRate in Russian (english false) or in English (KB/s, Mb/s).

func HaveSessionBus added in v1.1.1

func HaveSessionBus() bool

HaveSessionBus reports whether the user's session bus is there to connect to. Without one, godbus would try to start one with dbus-launch, and the tray library would fail on a connection it never got: a desktop without D-Bus, or a program started over SSH, then runs with no tray and no notifications.

func Icon

func Icon() []byte

Icon returns a 32x32 .ico image: equinox, drawn as a circle split into a sunlit half and a night half, tilted by Earth's axial tilt (23.4°), with a sun and a moon set into the two halves. It is drawn in code so the executable needs no resource files.

func LauncherPath added in v1.1.1

func LauncherPath() (string, error)

LauncherPath is the program file that a menu entry or the autostart should start. Inside an AppImage the running file is in a mount that changes on every start, so the AppImage itself ($APPIMAGE) is taken instead.

func MakeDefault added in v1.1.1

func MakeDefault() error

MakeDefault makes the program the one that opens .torrent files and magnet links (xdg-mime, which every desktop follows). The packages bring their own menu entry; an AppImage or a program unpacked by hand gets one made for the user, with the icon, so that the system has something to point at.

func Notify added in v1.1.1

func Notify(title, text string) error

Notify shows a notification with the program's name and icon.

func PNG

func PNG(n int) []byte

PNG returns the same picture as a PNG of the given size (for the executable's resources).

func PosVisible added in v1.0.1

func PosVisible(x, y, vx, vy, vw, vh int) bool

PosVisible reports whether a window at (x, y) would still be reachable on a screen area (the whole desktop): a monitor that was unplugged must not leave the window out of sight.

func SetAutostart added in v1.1.1

func SetAutostart(on, hidden bool) error

SetAutostart turns starting at login on or off; hidden starts it in the tray without opening the browser.

func ValidDensity added in v1.0.1

func ValidDensity(d string) bool

ValidDensity reports whether d is one of the known densities.

func WatchNotificationClicks added in v1.1.1

func WatchNotificationClicks(onClick func())

WatchNotificationClicks calls onClick when the user clicks one of this program's notifications.

Types

type Size added in v1.0.1

type Size struct {
	W int `json:"w"`
	H int `json:"h"`
}

Size is in pixels.

func DefaultSize added in v1.0.1

func DefaultSize(d string) Size

DefaultSize is the client size of a window that has no remembered size.

func MinSize added in v1.0.1

func MinSize(d string) Size

MinSize is the smallest outer size the window may be given.

type WindowPrefs added in v1.0.1

type WindowPrefs struct {
	Density string          `json:"density"`
	HasPos  bool            `json:"hasPos"`
	X       int             `json:"x"` // outer position
	Y       int             `json:"y"`
	Max     bool            `json:"maximized"`
	Sizes   map[string]Size `json:"sizes"` // outer sizes the person has left the window at
}

WindowPrefs is what is remembered about the window.

func LoadWindowPrefs added in v1.0.1

func LoadWindowPrefs(path string) WindowPrefs

LoadWindowPrefs reads the file; a missing or broken file gives the defaults.

func (*WindowPrefs) ForgetSize added in v1.0.1

func (p *WindowPrefs) ForgetSize(d string)

ForgetSize drops the remembered size of a density, so it goes back to the default.

func (WindowPrefs) Save added in v1.0.1

func (p WindowPrefs) Save(path string) error

Save writes the file (through a temporary one, so a crash cannot leave half of it).

func (WindowPrefs) Saved added in v1.0.1

func (p WindowPrefs) Saved(d string) (Size, bool)

Saved returns the remembered outer size for a density, if there is one.

func (*WindowPrefs) SetSize added in v1.0.1

func (p *WindowPrefs) SetSize(d string, s Size)

SetSize remembers the outer size for a density.

Jump to

Keyboard shortcuts

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