TrayIcon
Module @netwiv/api/tray · Kind Constant
import { TrayIcon } from '@netwiv/api/tray';Instance members
Section titled “Instance members”close(): Promise<void>Destroys and cleans up this resource from memory. You should not call any method on this object anymore and should drop any reference to it.
id: stringThe id associated with this tray icon.
rid: numbersetIcon
Section titled “setIcon”setIcon(icon: string | number[] | Image | ArrayBuffer | Uint8Array<ArrayBufferLike> | null): Promise<void>Sets a new tray icon. If null is provided, it will remove the icon.
Note that you may need the image-ico or image-png Cargo features to use this API.
To enable it, change your Cargo.toml file:
[dependencies]tauri = { version = "...", features = ["...", "image-png"] }setIconAsTemplate
Section titled “setIconAsTemplate”setIconAsTemplate(asTemplate: boolean): Promise<void>Sets the current icon as a template. macOS only
setIconWithAsTemplate
Section titled “setIconWithAsTemplate”setIconWithAsTemplate(icon: string | number[] | Image | ArrayBuffer | Uint8Array<ArrayBufferLike> | null, asTemplate: boolean): Promise<void>Sets a new tray icon and template status atomically. macOS only.
Note that you may need the image-ico or image-png Cargo features to use this API.
To enable it, change your Cargo.toml file:
[dependencies]tauri = { version = "...", features = ["...", "image-png"] }setMenu
Section titled “setMenu”setMenu(menu: Menu | Submenu | null): Promise<void>Sets a new tray menu.
Platform-specific:
Section titled “Platform-specific:”- Linux: once a menu is set it cannot be removed so
nullhas no effect
setMenuOnLeftClick
Section titled “setMenuOnLeftClick”setMenuOnLeftClick(onLeft: boolean): Promise<void>Disable or enable showing the tray menu on left click.
Platform-specific:
Section titled “Platform-specific:”- Linux: Unsupported.
Deprecated use {@linkcode TrayIcon.setShowMenuOnLeftClick} instead.
setShowMenuOnLeftClick
Section titled “setShowMenuOnLeftClick”setShowMenuOnLeftClick(onLeft: boolean): Promise<void>Disable or enable showing the tray menu on left click.
Platform-specific:
Section titled “Platform-specific:”- Linux: Unsupported.
setTempDirPath
Section titled “setTempDirPath”setTempDirPath(path: string | null): Promise<void>Sets the tray icon temp dir path. Linux only.
On Linux, we need to write the icon to the disk and usually it will
be $XDG_RUNTIME_DIR/tray-icon or $TEMP/tray-icon.
setTitle
Section titled “setTitle”setTitle(title: string | null): Promise<void>Sets the tooltip for this tray icon.
Platform-specific:
Section titled “Platform-specific:”- Linux: The title will not be shown unless there is an icon as well. The title is useful for numerical and other frequently updated information. In general, it shouldn’t be shown unless a user requests it as it can take up a significant amount of space on the user’s panel. This may not be shown in all visualizations.
- Windows: Unsupported
setTooltip
Section titled “setTooltip”setTooltip(tooltip: string | null): Promise<void>Sets the tooltip for this tray icon.
Platform-specific:
Section titled “Platform-specific:”- Linux: Unsupported
setVisible
Section titled “setVisible”setVisible(visible: boolean): Promise<void>Show or hide this tray icon.
Descriptions come from the pinned @tauri-apps/api@2.11.1 declarations (MIT OR Apache-2.0); imports are shown with @netwiv/api paths.