Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

Is there an easy way of having tea-time display messages via gnome's native notification system?

The current "notification function" in tea-time.el is:

(defun show-notification (notification)
  "Show notification. Use mumbles."
 (if (program-exists "mumbles-send")
    (start-process "tea-time-mumble-notification" nil "mumbles-send" notification)
  (message notification)
 ))

I tried editing this to use notify-send instead, without any success: specifically using something like (shell-command (concat "notify-send " notification)) in place of (start-process "tea-time-mumble-notification" nil "mumbles-send" notification) doesn't seem to work (I got rid of the if-statement as well, of course).

Suggestions?

share|improve this question

4 Answers 4

Yes, just call notify-send command from the alert hook (if there is one, otherwise you might need to patch tea-time to have that.)

share|improve this answer
1  
Thanks. I added more info in my original question: suggestions on how to call notify-send? –  emacsomancer Jun 6 '11 at 16:26
    
No idea. Care to ask/search on some Emacs forum or search through emacswiki.org? –  alex Jun 6 '11 at 16:37
    
@BeSlayed :perhaps, redefine the cited function to use the suggested notify-send (instead of that mumbles-send)? –  imz -- Ivan Zakharyaschev Jun 6 '11 at 17:46
    
@imz: yes, I have tried (defun show-notification (notification) (shell-command (concat "notify-send " notification) )) (which seems like what you're suggesting), but I get a "Invalid number of options" error. –  emacsomancer Jun 7 '11 at 2:01
up vote 1 down vote accepted

By trial and error I figured out that the following redefinition works:

(defun show-notification (notification)
"Show notification. Use notify-send."
(start-process "tea-time-notify-notification" nil "notify-send" notification)
)

Fancier stuff can be done as well: using

(start-process "tea-time-notify-notification" nil "notify-send" "-i" (expand-file-name "~/path/to/your/icon/YourIconName.png") "Emacs Tea Timer" notification)

tells the notification daemon to use an icon (this one is suitable) in the notification pop-up and uses a emboldened 'summary' text ("Emacs Tea Timer").

share|improve this answer

With the latest tea-time.el, you have a hook you can use for that.
Add to your Emacs initialization:

(add-hook 'tea-time-notification-hook 
  (function (lambda() 
    (start-process "tea-timer-notification" nil "notify-send" "Time is up!"))))
share|improve this answer

In Emacs 24, you can use notifications.el to send D-Bus notifications directly from elisp code. Rewriting @yhager's hook, above:

(add-hook 'tea-time-notification-hook
  (lambda ()
    (notifications-notify :title "Time is up!"
                          :body "I know you're busy, but it's TEA TIME!!"
                          :app-name "Tea Time"
                          :sound-name "alarm-clock-elapsed)))

There are more useful args described on the Notifications page of the Emacs Lisp Reference Manual (including the :sound-file option, instead of :sound-name, which requires an XDG sound theme implementation).

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.