Tags: crystal, devblog, programming
This is just a quick announcement for notify.cr, my latest Crystal library (“shard”).
notify.cr is a library for
Desktop Notifications, the standard used by
most Linux desktops to provide the user with notifications. It connects to the user’s notification
daemon via DBus, and should work with any complaint daemon (e.g.,
The easiest way to install notify.cr is via Crystal’s
shards dependency manager.
You can find the relevant steps in the repository
In use, notify.cr has only five methods:
#capability? are used to perform feature checking.
the underlying feature list, while
#capability? checks for the availability of any particular
1 2 3 4 5 6 require "notify" notifier = Notify.new notifier.capabilities # => ["body", "body-markup", "body-hyperlinks"] notifier.capability? "body" # => true
#information returns a list of strings, indicating vendor information:
1 notifier.information # => ["mynotifier", "authorname", "1.0"]
#close do the main work of displaying and hiding notifications from the
#notify returns a
UInt32 that identifies the displayed notification, allowing it
to be closed via
#close or overwritten by a subsequent
1 2 3 4 5 6 7 id = notifier.notify "hello", body: "world!", expire_timeout: 5000 # replace the previous notification with this one *without* creating a new ID notifier.notify "look ma", body: "no flicker!", replaces_id: id # finally, close the notification if it's still on the screen notifier.close id
replaces_id are just two of several parameters that
#notify can take.
Check out the API documentation for more.
Thanks for reading!