Ruby bindings for libnotify using FFI.
require 'libnotify'
Libnotify.show(:body => "hello", :summary => "world", :timeout => 2.5)
require 'libnotify'
n = Libnotify.new do |notify|
notify.summary = "hello"
notify.body = "world"
notify.timeout = 1.5 # 1.5 (s), 1000 (ms), "2", nil, false
notify.urgency = :critical # :low, :normal, :critical
notify.append = false # default true - append onto existing notification
notify.transient = true # default false - keep the notifications around after display
notify.icon_path = "/usr/share/icons/gnome/scalable/emblems/emblem-default.svg"
end
n.show!
require 'libnotify'
# Mixed syntax
options = {:body => "world", :timeout => 20}
Libnotify.show(options) do |opts|
opts.timeout = 1.5 # overrides :timeout in options
end
require 'libnotify'
# Icon path auto-detection
Libnotify.icon_dirs << "/usr/share/icons/gnome/*/"
Libnotify.show(:icon_path => "emblem-default.png")
Libnotify.show(:icon_path => :"emblem-default")
# Update pre-existing notification then close it
n = Libnotify.new(:summary => "hello", :body => "world")
n.update # identical to show! if not shown before
Kernel.sleep 1
n.update(:body => "my love") do |notify|
notify.summary = "goodbye"
end
Kernel.sleep 1
n.close
gem install libnotify
You'll need libnotify. On Debian just type:
apt-get install libnotify1
git clone git://github.com/splattael/libnotify.git
cd libnotify
(gem install bundler)
bundle install
rake
COVERAGE=1 rake
timeout
and append
options might not work on Ubuntu.
See GH #21 for details.
#21 (comment)
- Peter Leitzen (https://github.com/splattael)
- Dennis Collective (https://github.com/denniscollective)
- Daniel Mack (https://github.com/zonque)
- Nuisance of Cats (https://github.com/nuisanceofcats)
- Jason Staten (https://github.com/statianzo)
- Jeremy Lawler (https://github.com/jlawler)
- Kero van Gelder (https://github.com/keroami)
- René Föhring (https://github.com/rrrene)
- Cezary Baginski (https://github.com/e2)
- robisacommonusername (https://github.com/robisacommonusername)
- Fernando Briano (https://github.com/picandocodigo)
-
Unify show/update interface -> simplifies code
-
Turn FFI module into a class -> more plugabble
-
Support newer features of
libnotify
-> actions, hints? See https://developer-next.gnome.org/libnotify/0.7/NotifyNotification.html -
Support older versions of
libnotify
-> prior0.4
?