If it's for windows, the API itself is quite simple (maybe it's not hard for
other platforms too). There are several gui frameworks available, there may be
this functionality available, better check them first.
A quick example for WInAPI (`nimble install oldwinapi` to make `windows`
available):
import windows, os
# some missing stuff
const NIF_ICON = 0x00000002
const NIF_TIP = 0x00000004
const NIF_STATE = 0x00000008
const NIM_ADD = 0.DWORD
const NIM_MODIFY= 1.DWORD
const NIM_DELETE= 2.DWORD
# a dummy window, to pass its handle to tray icon's creation proc;
# use any your program's window instead, and then just skip this piece of
code
let className = "BUTTON"
let windowName = "test"
let hw=CreateWindow(
className.cstring,
windowName.cstring,
0, # dwStyle
400, 300, 200, 60, # position and size
0, # hWndParent
0, # hMenu
0, #hInstance
nil)
# just filling the structure, describing your icon, and passing it to the
API proc;
# a callback can be set here too
var nid: NotifyIconDataA
nid.cbSize = nid.sizeof.DWORD
nid.Wnd = hw
nid.uFlags = NIF_ICON or NIF_TIP
nid.hIcon = LoadIcon(0, IDI_EXCLAMATION)
var s = "Hello from WinAPI!"
copyMem nid.szTip.addr, s[0].addr, s.len
nid.szTip[s.len] = '\0'
discard Shell_NotifyIconA(NIM_ADD, addr nid)
# here should be your message loop; you have that propbably already;
# instead, for a demostration, we just keep the process alive for some
seconds,
# enough to see icon working, with a hint on it
sleep 8_000