Linux system tray icon library using D-Bus StatusNotifierItem protocol. Supports dynamic icon changes, animations, context menus (DBusMenu), and multiple simultaneous icons. Hides D-Bus complexity behind a clean C# interface.
$ dotnet add package Olbrasoft.SystemTray.LinuxA modern .NET library for creating system tray icons on Linux using the D-Bus StatusNotifierItem protocol.
dotnet add package Olbrasoft.SystemTray.Linux
using Olbrasoft.Linux.SystemTray;
using Microsoft.Extensions.Logging;
// Create logger and icon renderer
var loggerFactory = LoggerFactory.Create(builder => builder.AddConsole());
var logger = loggerFactory.CreateLogger<TrayIcon>();
var iconRenderer = new IconRenderer(loggerFactory.CreateLogger<IconRenderer>());
// Create tray icon
var trayIcon = new TrayIcon(logger, iconRenderer, "my-app");
await trayIcon.InitializeAsync();
// Set icon
trayIcon.SetIcon("/path/to/icon.svg", "My Application");
// Handle clicks
trayIcon.Clicked += (sender, args) => Console.WriteLine("Icon clicked!");
// Cleanup
trayIcon.Dispose();
// Pre-cache animation frames
string[] frames = new[]
{
"/path/to/frame1.svg",
"/path/to/frame2.svg",
"/path/to/frame3.svg"
};
// Start animation (150ms interval)
trayIcon.StartAnimation(frames, intervalMs: 150, tooltip: "Working...");
// Stop animation
trayIcon.StopAnimation();
var manager = new TrayIconManager(
loggerFactory.CreateLogger<TrayIconManager>(),
loggerFactory,
iconRenderer
);
// Create left hand icon
var leftIcon = await manager.CreateIconAsync(
"left-hand",
"/icons/left-hand.svg",
"Left Hand Gesture"
);
// Create robot icon
var robotIcon = await manager.CreateIconAsync(
"robot",
"/icons/robot.svg",
"Main App"
);
// Create right hand icon
var rightIcon = await manager.CreateIconAsync(
"right-hand",
"/icons/right-hand.svg",
"Right Hand Gesture"
);
// Later: remove specific icon
manager.RemoveIcon("left-hand");
// Cleanup all icons
manager.Dispose();
This library is based on the D-Bus StatusNotifierItem protocol, which is the modern standard for system tray icons on Linux (replacing the deprecated X11 system tray).
The library implements several workarounds for GNOME Shell icon caching issues:
Tmds.DBus.Protocol - D-Bus communicationSkiaSharp - SVG renderingSvg.Skia - SVG loadingMicrosoft.Extensions.Logging - Logging abstractionThis library was extracted from three Olbrasoft projects:
The goal was to create a reusable NuGet package that other applications can easily integrate without copying D-Bus boilerplate code.
MIT
Contributions are welcome! Please open an issue or pull request on GitHub.
Based on Avalonia's DBusTrayIconImpl:
Developed by Olbrasoft (https://olbrasoft.cz)