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
- Variables
- func HelperBundlePath(name string) (string, error)
- func Hide(a *tango.App) error
- func LaunchHelper(name string, args ...string) error
- func LaunchMain(args ...string) error
- func MainBundlePath() (string, error)
- func RequestAttention(a *tango.App, critical bool) error
- func SetBadge(a *tango.App, text string) error
- func SetDockVisible(a *tango.App, visible bool) error
- func SetProgress(a *tango.App, p float64) error
- func Show(a *tango.App) error
- func Supports(a *tango.App, op platform.AppControlOp) bool
Constants ¶
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 ¶
var ErrUnsupported = platform.ErrUnsupported
ErrUnsupported is platform.ErrUnsupported, re-exported for callers outside the module.
Functions ¶
func HelperBundlePath ¶
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 LaunchHelper ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
SetProgress shows a progress bar in [0, 1] on the dock icon / taskbar button; values above 1 are clamped, a negative value hides it.
Types ¶
This section is empty.