System tray icons via D-Bus

I was trying to implement a basic system tray icon using some gui kit but ended up making this c lib. Turned out this is a pretty challenging (?) topic. GTK4 dropped support, 3rd party libs are deprecated or require GTK3 (the ones I thought I could get to work).

So this is a pure c dbus system tray handler wrapped in Zig. No Glib, no GTK, no QT. Dynamic icons/titles work, as well as simple menus + callbacks. Pretty minimal, I am trying to expand.

Testing on FreeBSD/Hyprland/eww.

stray1

demo:

 zig build run

Not sure if this works on macos, there is dbus brew tho. Need to figure out if I can test it on BSD.

7 Likes

There is also GitHub - AyatanaIndicators/libayatana-appindicator-glib: Ayatana Application Indicators Shared Library (GLib-2.0 reimplementation, 100% GTK-free, 100% dbusmenu-free) but its GPL and broken README lies about being implementation of StatusNotifierItem · Issue #89 · AyatanaIndicators/libayatana-appindicator-glib · GitHub.

I’ve been looking to do this exact thing for my little break notification app. I was getting nowhere with dbus docs, so this will be a great help. Thanks.

1 Like

No worries! I hope it works for you! I am pushing a fix for linux in a few.

Yea the docs are not great, but I guess the level is too low, so there are not many consumers.

zig 0.15-ready

0.1.0

Bug Fixes

  • Update callconv()
  • Update sleep()

Documentation

  • Add README.md
  • Update features
  • Fix TrayIcon comment
  • Update comments

Features

  • Add menu support
  • Add demo app

Miscellaneous tasks

  • Add LICENSE
  • Set indentations
  • Add gitignore
  • Ignore zig-out

Operations

  • Add demo test
  • Install dependencies

Refactor

  • Move declarations

Styling

  • Change alignment
  • Fix formatting
  • Break open brackets

Build

  • Add docs step
  • Fix library links

0.1.1

Bug Fixes

  • Drop c_allocator
  • Resolve leaking items
  • Fix array list
  • Update onQuit

Documentation

  • Update description
  • Adjust description
  • Reformat comments

Miscellaneous tasks

  • Add CI badge

Operations

  • Add test job

Testing

  • Add basic app

Build

  • Bump MSZV to 0.15.2
1 Like