crystal-libnotify
crystal-libnotify
Crystal bindings for libnotify, the library for sending desktop notifications to a notification daemon (as defined by the Desktop Notifications Specification).
Requirements
- Crystal >= 1.21.0
libnotifydevelopment headers (libnotify-devon Debian/Ubuntu,libnotifyon Arch)
The low-level C bindings in crystal_lib/libnotify.cr are generated with crystal_lib and link against libnotify.
Installation
Add this to your application's shard.yml:
dependencies:
crystal-libnotify:
github: shpeckman/crystal-libnotify
Then run shards install.
Usage
require "crystal-libnotify"
# Quick one-liner
Libnotify.show("Hello, world!")
# Full example
n = Libnotify.new(summary: "Backup finished", body: "All files synced.")
n.timeout = 5.0 # seconds
n.urgency = :normal
n.show
# Block style
Libnotify.show do |n|
n.summary = "Build complete"
n.body = "Your shard compiled without errors."
n.urgency = :low
n.category = "build"
end
Notification properties
| Property | Type | Default | Notes |
|---|---|---|---|
summary |
String? |
nil |
Title of the notification |
body |
String? |
nil |
Body text |
icon_path |
String? |
nil |
Path to an icon image |
app_name |
String |
"default" |
Application name shown by the daemon |
timeout |
Int32 |
-1 |
Timeout in ms; -1 = server default; timeout= accepts seconds as a float |
category |
String? |
nil |
Notification category |
urgency |
Symbol |
:normal |
:low, :normal or :critical |
append |
Bool |
false |
Append to an existing notification |
transient |
Bool |
true |
Not kept in the notification history |
Actions
n = Libnotify.new("Deploy finished")
n.add_action("open", "Open dashboard") do
puts "Opening dashboard..."
end
n.show
Server information
Libnotify.server_caps # => ["actions", "body", "icon-static", ...]
Libnotify.server_info # => {name: "org.freedesktop.Notifications", vendor: "GNOME", ...}
Contributing
- Fork it
- Create your feature branch (
git checkout -b my-new-feature) - Commit your changes (
git commit -am 'Add some feature') - Push to the branch (
git push origin my-new-feature) - Create a new Pull Request
License
MIT
Repository
crystal-libnotify
Owner
Statistic
- 0
- 0
- 0
- 0
- 0
- about 5 hours ago
- September 7, 2026
License
MIT License
Links
Synced at
Mon, 07 Sep 2026 23:36:57 GMT
Languages