Tray
A tray is a small icon placed in the OS status area (macOS menu bar, Windows system tray, or Linux app indicator area). Users can click or right-click the icon, and in most cases you'll attach a menu to it via Set Tray Menu.
Tray Icon Sizing
Each platform expects a different icon size. For best results, supply a platform-specific image. For a quick-and-easy setup, pass a single 64×64 @ 144 DPI PNG and Deskifier will rescale it.
<table><thead><tr><th width="130.33333333333331">Platform</th><th width="239">Desired Size & Type</th><th>Notes</th></tr></thead><tbody><tr><td>macOS</td><td>32x32 (144 DPI) .png</td><td>Set <code>darkModeSupport: true</code> to treat the icon as a <a href="https://www.electronjs.org/docs/latest/api/native-image#template-image-macos">TemplateImage</a>, which adapts to light/dark menu bars.</td></tr><tr><td>Windows</td><td>64x64 .png</td><td></td></tr><tr><td>Linux</td><td>24x24 .png</td><td></td></tr></tbody></table>
Methods
Create Tray
Creates a tray instance.
await window.deskifier.tray.create({ arguments })
Arguments
iconOptionsObject
Optional. By default, the app icon will be used.urlString (Conditionally Required)
The web URL of the resource. Not required if an exact path is given.pathString (Conditionally Required)
The local filesystem path of the icon. Not required if a url is given.darkModeSupportBoolean
Treats the icon as a template image so it adapts to light/dark menu bars. macOS only.
Returns
trayIdString
The ID of the new tray.successBoolean
If the action was successful.messageString
Additional confirmation, or error details if action was unsuccessful.
Example
const tray = await window.deskifier.tray.create({
iconOptions: {
url: 'https://www.deskifier.com/windowsTrayIcon.png'
}
});
console.log(tray.trayId);
// '7795d507-bf71-41d2-a505-16a0e48fe651'
Destroy Tray
Destroys a tray instance.
await window.deskifier.tray.destroy({ arguments })
Arguments
idString (Required)
Returns
successBoolean
If the action was successful.messageString
Additional confirmation, or error details if action was unsuccessful.
Set Tray Icon
Sets the tray icon. Refer to the create tray action for more details.
await window.deskifier.tray.setIcon({ arguments })
Arguments
iconOptionsObject (Required)urlString (Required)
The URL of the resource.darkModeSupportBoolean
Attempts to make the icon compatible with dark mode (macOS only)
idString (Required)
Returns
successBoolean
If the action was successful.messageString
Additional confirmation, or error details if action was unsuccessful.
Set Tray Tool Tip
Sets the tray tool tip.
await window.deskifier.tray.setToolTip({ arguments })
Arguments
toolTipString (Required)idString (Required)
Returns
successBoolean
If the action was successful.messageString
Additional confirmation, or error details if action was unsuccessful.
Set Tray Menu
Attaches a menu to a tray icon. The menu must already be created via Create Tray Menu.
await window.deskifier.tray.setMenu({ arguments })
Arguments
trayIdString (Required)menuIdString (Required)
Returns
successBoolean
If the action was successful.messageString
Additional confirmation, or error details if action was unsuccessful.
Set Tray Title
macOS Sets the title displayed next to the tray icon in the status bar.
await window.deskifier.tray.setTitle({ arguments })
Arguments
titleString (Required)idString (Required)
Returns
successBoolean
If the action was successful.messageString
Additional confirmation, or error details if action was unsuccessful.
Display Tray Balloon
Windows Displays a balloon-style notification anchored to the tray icon.
await window.deskifier.tray.displayBalloon({ arguments })
Arguments
idString (Required)balloonOptionsObject (Required)titleString (Required)contentString (Required)iconTypeString
One of'none','info','warning','error', or'custom'. Default is'none'.
Returns
successBoolean
If the action was successful.messageString
Additional confirmation, or error details if action was unsuccessful.
Remove Tray Balloon
Windows Removes the tray balloon.
await window.deskifier.tray.removeBalloon({ arguments })
Arguments
idString (Required)
Returns
successBoolean
If the action was successful.messageString
Additional confirmation, or error details if action was unsuccessful.
Properties
Get Tray Title
macOS Returns the title displayed next to the tray icon in the status bar.
await window.deskifier.tray.getTitle({ arguments })
Arguments
trayIdString (Required)
Returns
titleStringsuccessBoolean
If the action was successful.messageString
Additional confirmation, or error details if action was unsuccessful.
Get All Trays
Returns all active trays, including each tray's attached menus and destroy state.
await window.deskifier.tray.getAll()
Returns
successBoolean
If the action was successful.messageString
Additional confirmation, or error details if action was unsuccessful.traysArray Of ObjectsidString
The ID of the tray.menuIdsArray of Strings
IDs of any menus currently attached to this tray. Empty array if no menu is attached.isDestroyedBooleantrueif the tray has been destroyed.
Is Destroyed
Checks whether a specific tray has been destroyed. Useful for handling stale references.
After Destroy Tray, the tray is fully removed from the internal registry. Calling this method with that tray's ID returns { success: false }. For still-alive trays it returns { success: true, destroyed: false }.
await window.deskifier.tray.isDestroyed({ arguments })
Arguments
trayIdString (Required)
Returns
successBooleantrueif the tray exists.falseif the tray was fully destroyed or the ID is unknown.messageString
Additional confirmation, or error details if action was unsuccessful.destroyedBooleantrueif the tray is currently marked destroyed,falseif alive.
Events
Click
Fires when the tray icon is clicked.
window.deskifier.tray.onClick((data) => {})
Arguments
trayIdStringeventElectron.KeyboardEventboundsElectron.RectanglepositionElectron.Point
Example
<pre class="language-javascript"><code class="lang-javascript">window.deskifier.tray.onClick((data) => { console.log(data.trayId, data.event, data.bounds, data.position); }); <strong> </strong>/* { "trayId": "33f13130-62ad-471c-b46a-75fd75e2f099", "event": { "shiftKey": false, "ctrlKey": false, "altKey": false, "metaKey": false, "triggeredByAccelerator": true }, "bounds": { "x": 1675, "y": 1040, "width": 24, "height": 40 }, "position": { "x": 1684, "y": 1061 } } */ </code></pre>
Right Click
macOS Windows Fires when the tray icon is right clicked.
window.deskifier.tray.onRightClick((data) => {})
Arguments
trayIdStringeventElectron.KeyboardEventboundsElectron.Rectangle
Double Click
macOS Windows Fires when the tray icon is double clicked.
window.deskifier.tray.onDoubleClick((data) => {})
Arguments
trayIdStringeventElectron.KeyboardEventboundsElectron.Rectangle
Middle Click
Windows Fires when the tray icon is middle clicked.
window.deskifier.tray.onMiddleClick((data) => {})
Arguments
trayIdStringeventElectron.KeyboardEventboundsElectron.Rectangle
Balloon Show
Windows Fires when the tray balloon shows.
window.deskifier.tray.onBalloonShow((data) => {})
Arguments
trayIdString
Balloon Click
Windows Fires when the tray balloon is clicked.
window.deskifier.tray.onBalloonClick((data) => {})
Arguments
trayIdString
Balloon Closed
Windows Fires when the tray balloon is closed because of timeout or user manually closes it.
window.deskifier.tray.onBalloonClosed((data) => {})
Arguments
trayIdString
Drop
macOS Fires when any dragged items are dropped on the tray icon.
window.deskifier.tray.onDrop((data) => {})
Arguments
trayIdString
Drop Files
macOS Fires when dragged files are dropped in the tray icon.
window.deskifier.tray.onDropFiles((data) => {})
Arguments
trayIdStringfilesArrayfileString
The paths of the dropped files.
Drop Text
macOS Fires when dragged text is dropped in the tray icon.
window.deskifier.tray.onDropText((data) => {})
Arguments
trayIdStringtextString
The dropped text string.
Drag Enter
macOS Fires when a drag operation enters the tray icon.
window.deskifier.tray.onDragEnter((data) => {})
Arguments
trayIdString
Drag Leave
macOS Fires when a drag operation exits the tray icon.
window.deskifier.tray.onDragLeave((data) => {})
Arguments
trayIdString
Drag End
macOS Fires when a drag operation ends on the tray or ends at another location.
window.deskifier.tray.onDragEnd((data) => {})
Arguments
trayIdString
Mouse Up
macOS Fires when the mouse is released from clicking the tray icon.
This will not be emitted if you have set a context menu for your Tray as a result of macOS-level constraints.
window.deskifier.tray.onMouseUp((data) => {})
Arguments
trayIdStringeventElectron.KeyboardEventpositionElectron.Point
Mouse Down
macOS Fires when the mouse clicks the tray icon.
window.deskifier.tray.onMouseDown((data) => {})
Arguments
trayIdStringeventElectron.KeyboardEventpositionElectron.Point
Mouse Enter
macOS Windows Fires when the mouse enters the tray icon.
window.deskifier.tray.onMouseEnter((data) => {})
Arguments
trayIdStringeventElectron.KeyboardEventpositionElectron.Point
Mouse Leave
macOS Windows Fires when the mouse exits the tray icon.
window.deskifier.tray.onMouseLeave((data) => {})
Arguments
trayIdStringeventElectron.KeyboardEventpositionElectron.Point
Mouse Move
macOS Windows Fires when the mouse moves in the tray icon.
window.deskifier.tray.onMouseMove((data) => {})
Arguments
trayIdStringeventElectron.KeyboardEventpositionElectron.Point