-
Notifications
You must be signed in to change notification settings - Fork 0
/
client-test.rb
executable file
·54 lines (41 loc) · 1.45 KB
/
client-test.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/usr/bin/env ruby
$LOAD_PATH << "/home/feitel/notification/ruby-dbus/lib/"
require 'dbus'
require 'pp'
bus = DBus::SessionBus.instance
service = bus.service("org.freedesktop.Notifications")
notify = service.object("/org/freedesktop/Notifications")
notify.default_iface = "org.freedesktop.Notifications"
puts "---------- service xml ----------"
puts notify.introspect
puts
iface = notify["org.freedesktop.Notifications"]
puts "---------- methods ----------"
pp iface.methods
puts
iface.on_signal(bus, "ActionInvoked") do |*params|
puts "ActionInvoked #{params.inspect}"
end
iface.on_signal(bus, "NotificationClosed") do |*params|
puts "NotificationClosed #{params.inspect}"
end
puts "---------- capabilities ----------"
puts iface.GetCapabilities.inspect
puts
puts "---------- server informations ----------"
puts iface.GetServerInformation.inspect
puts
# app_name, id, icon, summary, body, actions, hints, timeout
notification = ["client-test", 0, "info", "subject", "B<b>od</b>Y", ["button1", "button1", "button2", "button2"], {"urgency" => [DBus::Type::Type.new(DBus::Type::BYTE), 1 ]}, -1]
sleep 1
id = iface.Notify *notification
puts "send notification id=#{id}"
sleep 4
id = iface.Notify *notification
puts "send notification id=#{id}"
sleep 1
puts "try to close notification"
iface.CloseNotification id.first
main = DBus::Main.new
main << bus
main.run