appctl

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2026 License: MIT Imports: 8 Imported by: ? 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 appctl controls the app as a whole in the window manager: hide and show all its windows, the dock / taskbar badge and progress bar, bouncing the dock icon or flashing the taskbar button, and the dock icon itself (tray-only apps).

appctl.SetBadge(app, "3")      // "" clears
appctl.SetProgress(app, 0.5)   // negative hides
appctl.RequestAttention(app, false)

Support by platform:

                  macOS   Windows                    Linux
Hide / Show       yes     yes (all windows)          yes (all windows)
SetBadge          yes     digits, as overlay icon    digits, Unity launcher API (Ubuntu Dock, KDE)
SetProgress       yes     yes (taskbar)              Unity launcher API
RequestAttention  yes     yes (FlashWindowEx)        yes (urgency hint)
SetDockVisible    yes     no                         no

Functions are safe from any goroutine once the app runs. They return ErrUnsupported when the platform cannot do it (Supports tells beforehand), and tango.ErrNotRunning after the app quit. The badge and progress also appear on windows created after they were set.

Index

Constants

View Source
const (
	CtlHide      = platform.CtlHide      // Hide, Show
	CtlBadge     = platform.CtlBadge     // SetBadge with counts
	CtlBadgeText = platform.CtlBadgeText // SetBadge with any text
	CtlProgress  = platform.CtlProgress  // SetProgress
	CtlAttention = platform.CtlAttention // RequestAttention
	CtlDock      = platform.CtlDock      // SetDockVisible
)

Operations, for Supports.

Variables

View Source
var ErrUnsupported = platform.ErrUnsupported

ErrUnsupported is platform.ErrUnsupported, re-exported for callers outside the module.

Functions

func HelperBundlePath

func HelperBundlePath(name string) (string, error)

HelperBundlePath returns the absolute path to a helper declared in macos.helperApps in tan.json. It works from either the main macOS app or one of its helpers. Other platforms return ErrUnsupported.

func Hide

func Hide(a *tango.App) error

Hide hides all of the app's windows (Cmd+H on macOS).

func LaunchHelper

func LaunchHelper(name string, args ...string) error

LaunchHelper starts the named macOS helper app in the background with args. On Windows and Linux it starts the current executable with args. Other platforms return ErrUnsupported. Use sys/single to route repeated launches to an existing instance.

func LaunchMain

func LaunchMain(args ...string) error

LaunchMain starts the containing main macOS app with args. On Windows and Linux it starts the current executable with args. Other platforms return ErrUnsupported.

func MainBundlePath

func MainBundlePath() (string, error)

MainBundlePath returns the absolute path to the containing main macOS app bundle. From a tan helper app it returns the outer bundle. Other platforms return ErrUnsupported.

func RequestAttention

func RequestAttention(a *tango.App, critical bool) error

RequestAttention bounces the dock icon or flashes the taskbar button until the user activates the app. critical keeps it going on macOS (informational requests bounce once).

func SetBadge

func SetBadge(a *tango.App, text string) error

SetBadge shows text on the dock icon / taskbar button; "" clears it. Windows and Linux only show numbers: other text returns ErrUnsupported there (and clears the badge).

func SetDockVisible

func SetDockVisible(a *tango.App, visible bool) error

SetDockVisible shows or hides the app's dock icon (macOS). Without it the app has no menu bar either and lives in a tray icon.

func SetProgress

func SetProgress(a *tango.App, p float64) error

SetProgress shows a progress bar in [0, 1] on the dock icon / taskbar button; values above 1 are clamped, a negative value hides it.

func Show

func Show(a *tango.App) error

Show shows the windows Hide hid and brings the app to the front.

func Supports

func Supports(a *tango.App, op platform.AppControlOp) bool

Supports reports whether the platform performs every operation in op.

Types

This section is empty.

Jump to

Keyboard shortcuts

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