Skip to content
Ruby bindings for libnotify using FFI.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
etc Add a new screenshow on Gnome 3 Oct 2, 2014
lib Release 0.9.4 Dec 21, 2017
test
.gitignore
.simplecov Code coverage with simplecov. Jul 2, 2013
.travis.yml
Gemfile
LICENSE
README.md Suschlik -> Leitzen Jul 5, 2017
Rakefile Split up test cases into separate files. Jun 18, 2013
libnotify.gemspec Suschlik -> Leitzen second pass Dec 21, 2017

README.md

Libnotify

Build Status Gem Version Code Climate Inline docs

Ruby bindings for libnotify using FFI.

Gem | Source | RDoc

libnotify libnotify

Usage

Hash Syntax

require 'libnotify'
Libnotify.show(:body => "hello", :summary => "world", :timeout => 2.5)

Block Syntax

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!

Mixed Syntax

require 'libnotify'

# Mixed syntax
options = {:body => "world", :timeout => 20}
Libnotify.show(options) do |opts|
  opts.timeout = 1.5     # overrides :timeout in options
end

Managing Icon Paths

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")

Updating existing notification and closing it

# 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

Installation

gem install libnotify

You'll need libnotify. On Debian just type:

apt-get install libnotify1

Testing

git clone git://github.com/splattael/libnotify.git
cd libnotify
(gem install bundler)
bundle install
rake

Code coverage

COVERAGE=1 rake

Caveats

Ubuntu

timeout and append options might not work on Ubuntu. See GH #21 for details. https://github.com/splattael/libnotify/issues/21#issuecomment-19114127

Authors

Contributors

License

MIT License

TODO

You can’t perform that action at this time.