Olbrasoft.SystemTray.Linux
1.1.15
dotnet add package Olbrasoft.SystemTray.Linux --version 1.1.15
NuGet\Install-Package Olbrasoft.SystemTray.Linux -Version 1.1.15
<PackageReference Include="Olbrasoft.SystemTray.Linux" Version="1.1.15" />
<PackageVersion Include="Olbrasoft.SystemTray.Linux" Version="1.1.15" />
<PackageReference Include="Olbrasoft.SystemTray.Linux" />
paket add Olbrasoft.SystemTray.Linux --version 1.1.15
#r "nuget: Olbrasoft.SystemTray.Linux, 1.1.15"
#:package Olbrasoft.SystemTray.Linux@1.1.15
#addin nuget:?package=Olbrasoft.SystemTray.Linux&version=1.1.15
#tool nuget:?package=Olbrasoft.SystemTray.Linux&version=1.1.15
Olbrasoft.SystemTray.Linux
A modern .NET library for creating system tray icons on Linux using the D-Bus StatusNotifierItem protocol.
Features
- ✅ Clean C# API - Hides D-Bus complexity behind simple interfaces
- ✅ Dynamic Icon Changes - Update icons on-the-fly
- ✅ Animations - Frame-based icon animations with customizable intervals
- ✅ Multiple Icons - Display multiple tray icons simultaneously (like GestureEvolution's 3-hand approach)
- ✅ SVG Support - Renders SVG icons to ARGB pixmaps using SkiaSharp
- ✅ Cache Busting - Workarounds for GNOME Shell icon caching issues
- ✅ .NET 10 - Built for the latest .NET
Installation
dotnet add package Olbrasoft.SystemTray.Linux
Quick Start
Single Icon
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();
Animated Icon
// 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();
Multiple Icons
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();
Architecture
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).
Key Components
- ITrayIcon - Main interface for single tray icon
- ITrayIconManager - Manager for multiple simultaneous icons
- IIconRenderer - SVG to ARGB rendering with caching
- StatusNotifierItemHandler - Internal D-Bus protocol implementation
D-Bus Workarounds
The library implements several workarounds for GNOME Shell icon caching issues:
- Timestamp in Icon ID - Changes icon ID with timestamp during animations
- Signal Re-emission - Re-emits D-Bus signals after delays for slow shells
- Unique Connection Names - Uses D-Bus unique names to avoid duplicate detection
Requirements
- .NET 10 or later
- Linux with D-Bus session bus
- StatusNotifierWatcher service (provided by GNOME Shell, KDE Plasma, or standalone)
Dependencies
Tmds.DBus.Protocol- D-Bus communicationSkiaSharp- SVG renderingSvg.Skia- SVG loadingMicrosoft.Extensions.Logging- Logging abstraction
Background
This library was extracted from three Olbrasoft projects:
- PushToTalk - Advanced D-Bus implementation with cache busting
- VirtualAssistant - GTK/AppIndicator approach
- GestureEvolution - Multiple simultaneous icons (3 hands/robot)
The goal was to create a reusable NuGet package that other applications can easily integrate without copying D-Bus boilerplate code.
License
MIT
Contributing
Contributions are welcome! Please open an issue or pull request on GitHub.
Credits
Based on Avalonia's DBusTrayIconImpl:
Developed by Olbrasoft (https://olbrasoft.cz)
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- Microsoft.Extensions.Logging (>= 10.0.1)
- Moq (>= 4.20.72)
- SkiaSharp (>= 3.119.1)
- SkiaSharp.NativeAssets.Linux.NoDependencies (>= 3.119.1)
- Svg.Skia (>= 3.2.1)
- Tmds.DBus.Protocol (>= 0.23.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Fixed CS8619 nullable warnings in generated D-Bus code. Implemented automatic versioning via GitHub Actions (1.1.x).