Coder Social home page Coder Social logo

libnotify's Introduction

Libnotify

Build Status Gem Version Code Climate Inline docs

Ruby bindings for libnotify using FFI.

Gem | Source | RDoc

libnotify

Usage

require 'libnotify'

# Block syntax
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!

# Hash syntax
Libnotify.show(:body => "hello", :summary => "world", :timeout => 2.5)

# Mixed syntax
Libnotify.show(options) do |n|
  n.timeout = 1.5     # overrides :timeout in options
end

# 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

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. splattael#21 (comment)

Authors

Contributors

License

MIT License

TODO

libnotify's People

Contributors

dnsco avatar insidewhy avatar jlawler avatar rrrene avatar splattael avatar statianzo avatar zonque avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.