🧰
Tray
We allow you to add to the system's tray (notification area)

What is the Tray

The Tray is the area where applications can put their icons to be easily accessed by users. On macOS this is the menubar and on Windows it's the system tray.

todesktop.tray.setTitle(title)

Works on macOS only. Will throw on Windows & Linux
1
todesktop.tray.setTitle('title')
Copied!

todesktop.tray.destroy()

This will destroy the tray item immediately
1
todesktop.tray.destroy()
Copied!

Example: Building a tray timer

Suppose we wanted to show users a 60 second timer in the tray
1
​
2
function startTimer () {
3
let remainingTime = 60;
4
let timer = setInterval(() => {
5
// Set the tray title to the remaining time
6
window.todesktop.tray.setTitle(
7
`Remaining: ${remainingTime}`
8
);
9
10
remainingTime -= 1;
11
if (remainingTime < 0) clearInterval(timer);
12
}, 1000);
13
}
Copied!
This will give you something like:
Last modified 8mo ago