Heya,
One of my biggest gripes with Nim since the past few months has been the lack of a Nim-native DBus library. I was once talking about it with a friend a few months back, and they just told me to write one myself since it's not that complex. I'd been holding onto it for a while, but I'm finally done with it, coincidentally just around the time @ASVI released their own library.
ybus is a D-Bus package that ships:
...all in ~1100 lines of Nim. A few things are remaining here and there, but most of the core has been solidly laid.
If you wished to write some Nim code targetting org.freedesktop.Notifications to send notifications from your Nim app, you can run:
$ bindgen -I /org/freedesktop/Notifications org.freedesktop.Notifications > notifs.nim
then, in your main source file:
import std/[options, tables]
import notifs
import pkg/ybus/client/unix_sync
var client = newBusClient()
client.connect()
echo get client.getServerInformation() # e.g on GNOME: @["gnome-shell", "GNOME", "49.3", "1.2"]
echo get client.getCapabilities() # e.g on GNOME: @["actions", "body", "body-markup", "icon-static", "persistence", "sound"]
echo get client.notify(
"ybus",
0'u32,
"org.gnome.Nautilus",
"hello, ybus!",
"this was sent through the autogenerated Notifications API bindings (bindgen)",
@[],
initTable[string, Variant](),
5000'i32,
) # send a notification to the user .. image:: https://files.catbox.moe/yw6idi.png
bindgen can essentially introspect a service on your system (if it supports it), get its interface' XML and generate Nim bindings targetting ybus for it, making it pretty neat and native-y.
Source Code: https://github.com/nim-windowing/ybus
That's mostly because I'm lazy. :P
And sure, I'll add tinydbus to the benchmarks too when I eventually get along to them.