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

  • iconOptions Object
    Optional. By default, the app icon will be used.
    • url String (Conditionally Required)
      The web URL of the resource. Not required if an exact path is given.
    • path String (Conditionally Required)
      The local filesystem path of the icon. Not required if a url is given.
    • darkModeSupport Boolean
      Treats the icon as a template image so it adapts to light/dark menu bars. macOS only.

Returns

  • trayId String
    The ID of the new tray.
  • success Boolean
    If the action was successful.
  • message String
    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

  • id String (Required)

Returns

  • success Boolean
    If the action was successful.
  • message String
    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

  • iconOptions Object (Required)
    • url String (Required)
      The URL of the resource.
    • darkModeSupport Boolean
      Attempts to make the icon compatible with dark mode (macOS only)
  • id String (Required)

Returns

  • success Boolean
    If the action was successful.
  • message String
    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

  • toolTip String (Required)
  • id String (Required)

Returns

  • success Boolean
    If the action was successful.
  • message String
    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

  • trayId String (Required)
  • menuId String (Required)

Returns

  • success Boolean
    If the action was successful.
  • message String
    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

  • title String (Required)
  • id String (Required)

Returns

  • success Boolean
    If the action was successful.
  • message String
    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

  • id String (Required)
  • balloonOptions Object (Required)
    • title String (Required)
    • content String (Required)
    • iconType String
      One of 'none', 'info', 'warning', 'error', or 'custom'. Default is 'none'.

Returns

  • success Boolean
    If the action was successful.
  • message String
    Additional confirmation, or error details if action was unsuccessful.

Remove Tray Balloon

Windows Removes the tray balloon.

await window.deskifier.tray.removeBalloon({ arguments })

Arguments

  • id String (Required)

Returns

  • success Boolean
    If the action was successful.
  • message String
    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

  • trayId String (Required)

Returns

  • title String
  • success Boolean
    If the action was successful.
  • message String
    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

  • success Boolean
    If the action was successful.
  • message String
    Additional confirmation, or error details if action was unsuccessful.
  • trays Array Of Objects
    • id String
      The ID of the tray.
    • menuIds Array of Strings
      IDs of any menus currently attached to this tray. Empty array if no menu is attached.
    • isDestroyed Boolean
      true if 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

  • trayId String (Required)

Returns

  • success Boolean
    true if the tray exists. false if the tray was fully destroyed or the ID is unknown.
  • message String
    Additional confirmation, or error details if action was unsuccessful.
  • destroyed Boolean
    true if the tray is currently marked destroyed, false if alive.

Events

Click

Fires when the tray icon is clicked.

window.deskifier.tray.onClick((data) => {})

Arguments

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


Double Click

macOS Windows Fires when the tray icon is double clicked.

window.deskifier.tray.onDoubleClick((data) => {})

Arguments


Middle Click

Windows Fires when the tray icon is middle clicked.

window.deskifier.tray.onMiddleClick((data) => {})

Arguments


Balloon Show

Windows Fires when the tray balloon shows.

window.deskifier.tray.onBalloonShow((data) => {})

Arguments

  • trayId String

Balloon Click

Windows Fires when the tray balloon is clicked.

window.deskifier.tray.onBalloonClick((data) => {})

Arguments

  • trayId String

Balloon Closed

Windows Fires when the tray balloon is closed because of timeout or user manually closes it.

window.deskifier.tray.onBalloonClosed((data) => {})

Arguments

  • trayId String

Drop

macOS Fires when any dragged items are dropped on the tray icon.

window.deskifier.tray.onDrop((data) => {})

Arguments

  • trayId String

Drop Files

macOS Fires when dragged files are dropped in the tray icon.

window.deskifier.tray.onDropFiles((data) => {})

Arguments

  • trayId String
  • files Array
    • file String
      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

  • trayId String
  • text String
    The dropped text string.

Drag Enter

macOS Fires when a drag operation enters the tray icon.

window.deskifier.tray.onDragEnter((data) => {})

Arguments

  • trayId String

Drag Leave

macOS Fires when a drag operation exits the tray icon.

window.deskifier.tray.onDragLeave((data) => {})

Arguments

  • trayId String

Drag End

macOS Fires when a drag operation ends on the tray or ends at another location.

window.deskifier.tray.onDragEnd((data) => {})

Arguments

  • trayId String

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


Mouse Down

macOS Fires when the mouse clicks the tray icon.

window.deskifier.tray.onMouseDown((data) => {})

Arguments


Mouse Enter

macOS Windows Fires when the mouse enters the tray icon.

window.deskifier.tray.onMouseEnter((data) => {})

Arguments


Mouse Leave

macOS Windows Fires when the mouse exits the tray icon.

window.deskifier.tray.onMouseLeave((data) => {})

Arguments


Mouse Move

macOS Windows Fires when the mouse moves in the tray icon.

window.deskifier.tray.onMouseMove((data) => {})

Arguments