libnotify-0.9.4/0000755000175000017500000000000013663153301013450 5ustar utkarshutkarshlibnotify-0.9.4/.travis.yml0000644000175000017500000000040013663153301015553 0ustar utkarshutkarshlanguage: ruby rvm: - 1.9.3 - 2.0 - 2.1 - 2.2.9 - 2.3.5 - 2.4.2 - jruby-9.1.15.0 - ruby-head matrix: allow_failures: - rvm: ruby-head fast_finish: true before_install: - "sudo apt-get install libnotify4" - "gem install bundler" libnotify-0.9.4/etc/0000755000175000017500000000000013663153301014223 5ustar utkarshutkarshlibnotify-0.9.4/etc/libnotify-ubuntu.png0000644000175000017500000003231013663153301020247 0ustar utkarshutkarshPNG  IHDRaOLr IDATx}wEwUOxa, J3AAr@*](<F ""0_ɀH9"vʽ $L/9χ{oQQ|J&@$(WV!0CUEEQ! \BaHv5<ܞ69/ N< @[G2~ cfD<Shb֬-_vm.8D:H9ZokprƳᲡ+CA+~|!7\Tv,lP ͞{1iqdj zvm?FGtH@A";>t@W 9tdMX&?ˍ ˥ "*4d*I?dē @U~i&2LErlT5fyu1Z,T`H'`z˪5T7ͭwZ oS8'nLf=k$l"[#2]aq"l wvmؿyfql{ +FvBرئb?V)?h7/Y,[kղ[Pq/7 Qy7fI?^~D-lُ;$@" J׵gU/|K׵o $eD5}v>@muQvgHXL=G_t1+LHnU v1&{\8!l~ɤ+L!R"~Bu||aDžԈNY%[ w Av\Xo+8co|O'|\W& .0g[AX~͇t<1"G:xk'ʪ^ez00q8@ 0F  @ y,fÆu^7OowYNvzHaY~ݏ鼳Uĉ SUDHOɕ9D L|+.iKXh9D4/]tzg@|KY I n7oGπp`Dz r}qa^qٟبZ|UU)m*a$L0!a-ʮm^iˎ<O>o%%AHUL~8@t }dب99:m8EWg@iY;!qC. rW_Ty2-Ճ{@)8]m%]9x9g,k8)DQZo<1i{24wPzڎ=n若!IQlپe^S;˯yl?5qӓ6p}e1Pw]1wu}1@۷ۜQ}esƏ r_ t}~ܐ 3K3ާkZG|:R ;Iv84\=_z58窮 ,DdPK:/_3@E8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(hdd$ޖF۶m9u]fA'GQ_ܼ[IDAT~ۚjժqAx]5&&k3'_wosu^}UO矙={ٜ9shԨSW<=)'yؿ?&L`۶m=?<]twޥϲJ^zسg )) 8vJ1L%ns5kHLLdѢEEֻ2߰0GF"44d.qꤤܛ#Ν9qK.`9sSrQN<ٳ'g>>ԯ_sc.] zcǎqI,Xyt̚5wy/Y۵kǁNGѪU+-BaZlu7jIvڥ}'|ɓ'ٿ?ƍC׻z=fڴiڵkhYYYlݺ\  B/oooz=o=z+W:׏ӧ͵kט>}:?h[;ȑ#Y=/_fQvmZjaXJN<~a0h׮]t᳦Mjk!isF:uJeoXXXAJjjC$xKFO<ɡC̙39qfP(T٥K1ږWTV.]8}57o(nlRSS4h ,Ftڵ=m۶%//5j0k,Kg1aׯ͛]~_\\/&##`-:'tRyM?AAAɮ3?x"GE3{l~BԤI._L5;w.˖-F5""!=g6I &4imQr's璐@ff&[lSN :!|<)WQu[Z5ZjŰaX~5/q'I_%77oKkqIY&[l?gΜ9sȑBӣGRRRz*.]r5Llذӧksȯ*֭+ze8/_NnnntqF~oNƍ4i&Lq͹kv8'|믿+‰'[.3gtX7N:SU^3gҦMl6;v`ԨQ(t{QϦLfС3uTzIXX$sNƎKzz&a-i:j;vG0i$5jDJJ g槟~<+WquQZ5mGÇJ{Ȅ ֭UTٳŋJ/''x6l`رcL8Qsl3ԩV͛73c mB7nt{{{ hd?ѣGoӶm[ 9rgɒ%tԉ1c 2oS%{]dYvض`5kw,Ǐ/Y@Q#{9s&ϟ.f͚L2Gyir&M6m6 :test Rake::TestTask.new(:test) do |test| test.test_files = FileList.new('test/**/*_test.rb') test.libs << 'test' test.verbose = true end # Yard begin require 'yard' YARD::Rake::YardocTask.new rescue LoadError task :yardoc do abort "YARD is not available. In order to run yardoc, you must: sudo gem install yard" end end desc "Alias for `rake yard`" task :doc => :yard # Misc desc "Tag files for vim" task :ctags do dirs = $LOAD_PATH.select {|path| File.directory?(path) } system "ctags -R #{dirs.join(" ")}" end desc "Find whitespace at line ends" task :eol do system "grep -nrE ' +$' *" end desc "Display TODOs" task :todo do `grep -Inr TODO lib test`.each do |line| line.scan(/^(.*?:.*?):\s*#\s*TODO\s*(.*)$/) do |(file, todo)| puts "* #{todo} (#{file})" end end end libnotify-0.9.4/test/0000755000175000017500000000000013663153301014427 5ustar utkarshutkarshlibnotify-0.9.4/test/integration_test.rb0000644000175000017500000000101113663153301020327 0ustar utkarshutkarshrequire 'helper' class IntegrationTest < LibnotifyTestCase test "display notification" do libnotify = Libnotify::API.new(:timeout => 0.5, :icon_path => :"emblem-favorite", :append => true) [ :low, :normal, :critical ].each do |urgency| libnotify.app_name = "test" libnotify.summary = "#{RUBY_VERSION} at #{RUBY_PLATFORM}" libnotify.body = [ urgency, defined?(RUBY_DESCRIPTION) ? RUBY_DESCRIPTION : '?' ].join(" ") libnotify.urgency = urgency libnotify.show! end end end libnotify-0.9.4/test/libnotify/0000755000175000017500000000000013663153301016426 5ustar utkarshutkarshlibnotify-0.9.4/test/libnotify/icon_finder_test.rb0000644000175000017500000000211413663153301022267 0ustar utkarshutkarshrequire 'helper' require 'fileutils' class LibnotifyIconFinderTest < LibnotifyTestCase test "find icon with highest resolution" do dir = fixture_file("/icons/*") assert_icon_path [ dir ], "/icons/128x128/happy.jpg", "happy.jpg" end test "search all provided dirs" do dirs = [ fixture_file("/icons/*"), fixture_file("/emoticons/*") ] assert_icon_path dirs, "/emoticons/128x128/happy.jpg", "happy.jpg" end test "does not find unknown icons" do dir = fixture_file("/icons/*") refute icon_finder([ dir ]).icon_path("unknown.jpg") end test "does not find known icon in unknown dirs" do dir = fixture_file("/unknown/*") refute icon_finder([ dir ]).icon_path("happy.jpg") end test "find icon alphabetically w/o resolution" do dir = fixture_file("/images/*") assert_icon_path [ dir ], "/images/another/happy.jpg", "happy.jpg" end private def icon_finder(*dirs) Libnotify::IconFinder.new(dirs) end def assert_icon_path(dirs, expected, name) assert_equal fixture_file(expected), icon_finder(*dirs).icon_path(name) end end libnotify-0.9.4/test/libnotify/api_test.rb0000644000175000017500000000475613663153301020577 0ustar utkarshutkarshrequire 'helper' class LibnotifyAPITest < LibnotifyTestCase test "instance default values" do assert_equal "Libnotify::API", libnotify.app_name assert_equal " ", libnotify.summary assert_equal " ", libnotify.body assert_equal :normal, libnotify.urgency assert_nil libnotify.timeout assert_nil libnotify.icon_path assert libnotify.append refute libnotify.transient end test "instance with options and block" do libnotify(:summary => "hello", :body => "body", :invalid_option => 23) do |n| n.app_name = "foo" n.body = "overwritten" n.icon_path = "/path/to/icon" n.append = false n.transient = true end assert_equal "foo", libnotify.app_name assert_equal "hello", libnotify.summary assert_equal "overwritten", libnotify.body assert_equal "/path/to/icon", libnotify.icon_path refute libnotify.append assert libnotify.transient end test "timeout=" do assert_timeout 2500, 2.5, "with float" assert_timeout 100, 100, "with fixnum ms" assert_timeout 101, 101, "with fixnum ms" assert_timeout 1000, 1, "with fixnum seconds" assert_timeout 99000, 99, "with fixnum seconds" assert_timeout nil, nil, "with nil" assert_timeout nil, false, "with false" assert_timeout 2, :"2 s", "with to_s.to_i" end test "icon_path=" do Libnotify::API.icon_dirs << File.expand_path("../../fixtures", __FILE__) assert_icon_path "/some/path/image.jpg", "/some/path/image.jpg", "with absolute path" assert_icon_path "some-invalid-path.jpg", "some-invalid-path.jpg", "with non-existant relative path" assert_icon_path %r{^/.*/test/fixtures/libnotify.png}, "libnotify.png", "with relative path" assert_icon_path %r{^/.*/test/fixtures/libnotify.png}, :"libnotify", "with symbol" end test "update" do libnotify(:summary => "hello", :body => "world").show! libnotify.update(:summary => "hell") do |n| n.body = "yeah" end assert_equal "hell", libnotify.summary assert_equal "yeah", libnotify.body libnotify.close end test "raise ArgumentError for unknown urgency" do e = assert_raises ArgumentError do libnotify(:urgency => :unknown).show! end assert_equal "invalid enum value, :unknown", e.message end end libnotify-0.9.4/test/helper.rb0000644000175000017500000000212313663153301016231 0ustar utkarshutkarshrequire 'rubygems' require 'bundler/setup' require 'simplecov' if ENV['COVERAGE'] == '1' require 'minitest/autorun' require 'minitest/libnotify' require 'libnotify' module LibnotifyAssertions def assert_timeout(expected, value, message) assert_value_set :timeout, expected, value, message end def assert_icon_path(expected, value, message) assert_value_set :icon_path, expected, value, message end def assert_value_set(attribute, expected, value, message) libnotify.send("#{attribute}=", value) got = libnotify.send(attribute) case expected when Regexp assert_match expected, got, message else assert_equal expected, got, message end end def fixture_file(path) File.expand_path(File.join(File.dirname(__FILE__), "fixtures", path)) end end class LibnotifyTestCase < MiniTest::Spec include LibnotifyAssertions class << self alias :test :it alias :context :describe alias :setup :before alias :teardown :after end def libnotify(options={}, &block) @libnotify ||= Libnotify::API.new(options, &block) end end libnotify-0.9.4/test/fixtures/0000755000175000017500000000000013663153301016300 5ustar utkarshutkarshlibnotify-0.9.4/test/fixtures/libnotify.png0000644000175000017500000000000013663153301020773 0ustar utkarshutkarshlibnotify-0.9.4/test/fixtures/.keep0000644000175000017500000000000013663153301017213 0ustar utkarshutkarshlibnotify-0.9.4/test/fixtures/icons/0000755000175000017500000000000013663153301017413 5ustar utkarshutkarshlibnotify-0.9.4/test/fixtures/icons/32x32/0000755000175000017500000000000013663153301020174 5ustar utkarshutkarshlibnotify-0.9.4/test/fixtures/icons/32x32/happy.jpg0000644000175000017500000000000013663153301022005 0ustar utkarshutkarshlibnotify-0.9.4/test/fixtures/icons/128x128/0000755000175000017500000000000013663153301020350 5ustar utkarshutkarshlibnotify-0.9.4/test/fixtures/icons/128x128/happy.jpg0000644000175000017500000000000013663153301022161 0ustar utkarshutkarshlibnotify-0.9.4/test/fixtures/icons/16x16/0000755000175000017500000000000013663153301020200 5ustar utkarshutkarshlibnotify-0.9.4/test/fixtures/icons/16x16/happy.jpg0000644000175000017500000000000013663153301022011 0ustar utkarshutkarshlibnotify-0.9.4/test/fixtures/icons/other/0000755000175000017500000000000013663153301020534 5ustar utkarshutkarshlibnotify-0.9.4/test/fixtures/icons/other/happy.jpg0000644000175000017500000000000013663153301022345 0ustar utkarshutkarshlibnotify-0.9.4/test/fixtures/images/0000755000175000017500000000000013663153301017545 5ustar utkarshutkarshlibnotify-0.9.4/test/fixtures/images/another/0000755000175000017500000000000013663153301021205 5ustar utkarshutkarshlibnotify-0.9.4/test/fixtures/images/another/happy.jpg0000644000175000017500000000000013663153301023016 0ustar utkarshutkarshlibnotify-0.9.4/test/fixtures/images/other/0000755000175000017500000000000013663153301020666 5ustar utkarshutkarshlibnotify-0.9.4/test/fixtures/images/other/happy.jpg0000644000175000017500000000000013663153301022477 0ustar utkarshutkarshlibnotify-0.9.4/test/fixtures/emoticons/0000755000175000017500000000000013663153301020300 5ustar utkarshutkarshlibnotify-0.9.4/test/fixtures/emoticons/128x128/0000755000175000017500000000000013663153301021235 5ustar utkarshutkarshlibnotify-0.9.4/test/fixtures/emoticons/128x128/happy.jpg0000644000175000017500000000000013663153301023046 0ustar utkarshutkarshlibnotify-0.9.4/test/libnotify_test.rb0000644000175000017500000000066213663153301020016 0ustar utkarshutkarshrequire 'helper' class LibnotifyTest < LibnotifyTestCase test "responds to new" do assert_respond_to Libnotify, :new end test "responds to show" do assert_respond_to Libnotify, :show end test "has version" do assert defined?(Libnotify::VERSION), "version is defined" assert Libnotify::VERSION end test "delegates icons_dir" do assert_equal Libnotify::API.icon_dirs, Libnotify.icon_dirs end end libnotify-0.9.4/.gitignore0000644000175000017500000000007113663153301015436 0ustar utkarshutkarshdoc coverage pkg tags .yardoc .bundle Gemfile.lock *.rbc libnotify-0.9.4/Gemfile0000644000175000017500000000006213663153301014741 0ustar utkarshutkarshsource "http://rubygems.org" gem 'rake' gemspec libnotify-0.9.4/README.md0000644000175000017500000000742213663153301014734 0ustar utkarshutkarsh# Libnotify [![Build Status](https://img.shields.io/travis/splattael/libnotify.svg?branch=master)](https://travis-ci.org/splattael/libnotify) [![Gem Version](https://img.shields.io/gem/v/libnotify.svg)](https://rubygems.org/gems/libnotify) [![Code Climate](https://img.shields.io/codeclimate/github/splattael/libnotify.svg)](https://codeclimate.com/github/splattael/libnotify) [![Inline docs](http://inch-ci.org/github/splattael/libnotify.svg?branch=master)](http://inch-ci.org/github/splattael/libnotify) Ruby bindings for libnotify using FFI. [Gem](https://rubygems.org/gems/libnotify) | [Source](https://github.com/splattael/libnotify) | [RDoc](http://rubydoc.info/github/splattael/libnotify/master) ![libnotify](https://github.com/splattael/libnotify/raw/master/etc/libnotify-gnome3.png) ![libnotify](https://github.com/splattael/libnotify/raw/master/etc/libnotify-ubuntu.png) ## Usage ### Hash Syntax ```ruby require 'libnotify' Libnotify.show(:body => "hello", :summary => "world", :timeout => 2.5) ``` ### Block Syntax ```ruby 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 ```ruby 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 ```ruby 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 ```ruby # 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 ```bash gem install libnotify ``` You'll need libnotify. On Debian just type: ```bash apt-get install libnotify1 ``` ## Testing ```bash git clone git://github.com/splattael/libnotify.git cd libnotify (gem install bundler) bundle install rake ``` ### Code coverage ```bash 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 * Peter Leitzen (https://github.com/splattael) ## [Contributors](https://github.com/splattael/libnotify/graphs/contributors) * 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) ## License [MIT License](http://www.opensource.org/licenses/MIT) ## TODO * 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` -> prior `0.4`? libnotify-0.9.4/LICENSE0000644000175000017500000000213313663153301014454 0ustar utkarshutkarshCopyright (c) 2011 Peter Suschlik Copyright (c) 2017 Peter Leitzen (Suschlik) MIT License Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. libnotify-0.9.4/libnotify.gemspec0000644000175000017500000000162713663153301017022 0ustar utkarshutkarsh# -*- encoding: utf-8 -*- $:.push File.expand_path("../lib", __FILE__) require "libnotify/version" Gem::Specification.new do |s| s.name = "libnotify" s.version = Libnotify::VERSION s.authors = ["Peter Leitzen"] s.email = ["peter-libnotify@suschlik.de"] s.homepage = "http://rubygems.org/gems/libnotify" s.summary = %q{Ruby bindings for libnotify using FFI} s.license = 'MIT' s.files = `git ls-files`.split("\n") s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n") s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) } s.require_paths = ["lib"] s.add_runtime_dependency 'ffi', '>= 1.0.11' s.add_development_dependency 'yard', '~> 0.9.11' s.add_development_dependency 'minitest', '~> 4.7.4' s.add_development_dependency 'minitest-libnotify', '~> 0.2.2' s.add_development_dependency 'simplecov' end libnotify-0.9.4/.simplecov0000644000175000017500000000004413663153301015450 0ustar utkarshutkarshrequire 'simplecov' SimpleCov.start libnotify-0.9.4/lib/0000755000175000017500000000000013663153301014216 5ustar utkarshutkarshlibnotify-0.9.4/lib/libnotify.rb0000644000175000017500000000531413663153301016545 0ustar utkarshutkarshrequire 'libnotify/version' require 'libnotify/api' # Ruby bindings for libnotify using FFI. # # See README.md for usage examples. # # @see README.md # @see Libnotify.new module Libnotify # Creates a notification. # # @example 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! # # @example Hash syntax # Libnotify.show(:body => "hello", :summary => "world", :timeout => 2.5) # # @example 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 # # @example Mixed syntax # Libnotify.new(options) do |n| # n.timeout = 1.5 # overrides :timeout in options # n.show! # end # # @param [Hash] options options creating a notification # @option options [String] :app_name ('Libnotify::API') name of the application # @option options [String] :summary (' ') summary/title of the notification # @option options [String] :body (' ') the body # @option options [Fixnum, Float, nil, FalseClass, String] :timeout (nil) display duration of the notification. # Use +false+ or +nil+ for no timeout. # @option options [Symbol] :urgency (:normal) the urgency of the notification. # Possible values are: +:low+, +:normal+ and +:critical+ # @option options [String] :icon_path path the an icon displayed. # # @yield [notify] passes the notification object # @yieldparam [API] notify the notification object # # @return [API] the notification object def self.new(options = {}, &block) API.new(options, &block) end # Shows a notification. It takes the same +options+ as Libnotify.new. # # @see Libnotify.new def self.show(options = {}, &block) API.show(options, &block) end # Exposes a list of icon directories to resolve `icon_path`. # # @see Libnotify.show # # @example # Libnotify.icon_dirs << "/usr/share/icons/gnome/*/" # Libnotify.show(:icon_path => "emblem-default.png") # # @return Array list of icon directories def self.icon_dirs API.icon_dirs end end libnotify-0.9.4/lib/libnotify/0000755000175000017500000000000013663153301016215 5ustar utkarshutkarshlibnotify-0.9.4/lib/libnotify/version.rb0000644000175000017500000000005113663153301020223 0ustar utkarshutkarshmodule Libnotify VERSION = "0.9.4" end libnotify-0.9.4/lib/libnotify/tasks/0000755000175000017500000000000013663153301017342 5ustar utkarshutkarshlibnotify-0.9.4/lib/libnotify/tasks/rubies.rake0000644000175000017500000000107213663153301021477 0ustar utkarshutkarshSUPPORTED_RUBIES = %w[ree 1.9.3 2.0.0 jruby rbx] GEMSPEC = Bundler::GemHelper.new(Dir.pwd).gemspec def with_ruby(ruby, command) gemset = GEMSPEC.name command = %{rvm #{ruby}@#{gemset} --create do bash -c '#{command}'} puts "\n" * 3 puts "CMD: #{command}" puts "=" * 40 system command end namespace :rubies do desc "Run tests for following supported platforms #{SUPPORTED_RUBIES.join ", "}" task :test do command = "rm -f Gemfile.lock && bundle install && bundle exec rake" SUPPORTED_RUBIES.each { |ruby| with_ruby(ruby, command) } end end libnotify-0.9.4/lib/libnotify/api.rb0000644000175000017500000000705113663153301017316 0ustar utkarshutkarshrequire 'libnotify/ffi' require 'libnotify/icon_finder' module Libnotify # API for Libnotify # # @see Libnotify class API include FFI attr_reader :timeout, :icon_path attr_accessor :app_name, :summary, :body, :urgency, :append, :transient class << self # List of globs to icons attr_accessor :icon_dirs end self.icon_dirs = [ "/usr/share/icons/gnome/*/emblems", "/usr/share/icons/gnome/*/emotes" ] # Creates a notification object. # # @see Libnotify.new def initialize(options={}, &block) set_defaults apply_options(options, &block) end def apply_options(options={}) options.each { |key, value| send("#{key}=", value) if respond_to?(key) } yield(self) if block_given? end private :apply_options def set_defaults self.app_name = self.class.to_s self.summary = self.body = ' ' self.urgency = :normal self.timeout = nil self.append = true self.transient = false end private :set_defaults # Shows a new notification. # # @see Libnotify.show def show! notify_init(app_name) or raise "notify_init failed" raw_ptr = notify_notification_new(summary, body, icon_path, nil) @notification = ::FFI::AutoPointer.new(raw_ptr, method(:g_object_unref)) show end # Shows an existing notification. def show notify_notification_set_urgency(@notification, urgency) notify_notification_set_timeout(@notification, timeout || -1) set_hints notify_notification_show(@notification, nil) ensure clear_hints end # Updates a previously shown notification or creates a new one. def update(options={}, &block) apply_options(options, &block) if @notification notify_notification_update(@notification, summary, body, icon_path, nil) show else show! end end # Close a previously shown notification. def close notify_notification_close(@notification, nil) if @notification end # @todo Simplify timeout= def timeout=(timeout) @timeout = case timeout when Float (timeout * 1000).to_i when Integer if timeout >= 100 # assume miliseconds timeout else timeout * 1000 end when NilClass, FalseClass nil else timeout.to_s.to_i end end # Sets icon path. # # Path can be absolute, relative (will be resolved) or a symbol. # # @todo document and refactor def icon_path=(path) case path when %r{^/} # absolute @icon_path = path when String @icon_path = icon_for(path) when Symbol self.icon_path = "#{path}.png" else @icon_path = nil end end # Creates and shows a notification. It's a shortcut for +Libnotify.new(options).show!+. # # @see Libnotify.show # @see Libnotify.new def self.show(options={}, &block) new(options, &block).show! end private def set_hints if append notify_notification_set_hint_string(@notification, "x-canonical-append", "") notify_notification_set_hint_string(@notification, "append", "") end if transient notify_notification_set_hint_uint32(@notification, "transient", 1) end end def clear_hints notify_notification_clear_hints(@notification) if (append || transient) end def icon_for(name) IconFinder.new(self.class.icon_dirs).icon_path(name) || name end end end libnotify-0.9.4/lib/libnotify/icon_finder.rb0000644000175000017500000000142313663153301021021 0ustar utkarshutkarshmodule Libnotify class IconFinder def initialize(dirs) @dirs = dirs end def icon_path(name) list = @dirs.map do |dir| glob = File.join(dir, name) Dir[glob].map { |fullpath| Icon.new(fullpath) } end if found = list.flatten.sort.first found.to_s end end class Icon attr_reader :fullpath def initialize(fullpath) @fullpath = fullpath end ICON_REGEX = /(\d+)x\d+/ def resolution @resolution ||= @fullpath[ICON_REGEX, 1].to_i end def to_s fullpath end def <=>(other) result = other.resolution <=> self.resolution result = self.fullpath <=> other.fullpath if result == 0 result end end end end libnotify-0.9.4/lib/libnotify/ffi.rb0000644000175000017500000000476413663153301017321 0ustar utkarshutkarshmodule Libnotify # Raw FFI bindings. module FFI require 'ffi' extend ::FFI::Library enum :urgency, [ :low, :normal, :critical ] # Load libnotify library and attach functions from C to Ruby via FFI. def self.included(_base) load_libs attach_functions! rescue LoadError => e warn e.message end def self.load_libs # :nodoc: libnotify_libs = %w[libnotify libnotify.so.4 libnotify.so.3 libnotify.so.2 libnotify.so.1 libnotify.so] # Workaround for "half-linked" libnotify.so. Does not work on rubinius (no ffi_lib_flags there)! # See: https://bugzilla.redhat.com/show_bug.cgi?id=626852 ffi_lib_flags :lazy, :local, :global if respond_to?(:ffi_lib_flags) ffi_lib libnotify_libs rescue LoadError ffi_lib %w[libgtk-x11-2.0 libgtk-x11-2.0.so.0 libgtk-x11-2.0.so libgtk-3 libgtk-3.so.0 libgtk-3.so], %w[libgtkmm-2.4 libgtkmm-2.4.so.1 libgtkmm-2.4.so libgtkmm-3.0 libgtkmm-3.0.so.1 libgtkmm-3.0.so], libnotify_libs end def self.attach_functions! # :nodoc: attach_function :notify_init, [:string], :bool attach_function :notify_uninit, [], :void attach_function :notify_notification_new, [:string, :string, :string, :pointer], :pointer attach_function :notify_notification_update, [:pointer, :string, :string, :string, :pointer], :pointer attach_function :notify_notification_set_urgency, [:pointer, :urgency], :void attach_function :notify_notification_set_timeout, [:pointer, :long], :void attach_function :notify_notification_set_hint_string, [:pointer, :string, :string], :void attach_function :notify_notification_set_hint_uint32, [:pointer, :string, :int], :void attach_function :notify_notification_clear_hints, [:pointer], :void attach_function :notify_notification_show, [:pointer, :pointer], :bool attach_function :notify_notification_close, [:pointer, :pointer], :bool attach_function :g_object_unref, [:pointer], :void end def method_missing(method, *args, &block) # :nodoc: if method.to_s =~ /^notify_/ warn "libnotify.so not found!" end super end end end