Class: LinuxNotifier
- Inherits:
-
Object
- Object
- LinuxNotifier
- Defined in:
- lib/birdy/linux_notifier.rb
Constant Summary collapse
- DISPLAY_TIME_SECONDS =
5
Instance Method Summary collapse
-
#initialize ⇒ LinuxNotifier
constructor
A new instance of LinuxNotifier.
- #show(image_path, name, message) ⇒ Object
- #wrap_links(text) ⇒ Object
Constructor Details
#initialize ⇒ LinuxNotifier
Returns a new instance of LinuxNotifier.
5 6 7 8 |
# File 'lib/birdy/linux_notifier.rb', line 5 def initialize @notify = RBus.session_bus.get_object('org.freedesktop.Notifications', '/org/freedesktop/Notifications') end |
Instance Method Details
#show(image_path, name, message) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/birdy/linux_notifier.rb', line 10 def show(image_path, name, ) app_name = 'birdy' replaces_id = 0 app_icon = image_path summary = name body = wrap_links() actions = [] hints = {} expire_timeout = DISPLAY_TIME_SECONDS * 1000 @notify.Notify(app_name, replaces_id, app_icon, summary, body, actions, hints, expire_timeout) sleep DISPLAY_TIME_SECONDS end |
#wrap_links(text) ⇒ Object
25 26 27 28 29 30 |
# File 'lib/birdy/linux_notifier.rb', line 25 def wrap_links(text) text.gsub(%r{ ( https?:// | www\. ) [^\s<]+ }x) do href = $& "<a href='" + href + "'>" + href + "</a>" end end |