summaryrefslogtreecommitdiff
path: root/jabber-libnotify.el
blob: 73db5ff91473b0d0d6b29459d4d2b74e80b7559a (plain)
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
55
56
57
58
59
60
61
62
63
;; jabber-libnotify.el - emacs-jabber interface to libnotify

;; Copyright (C) 2007 - Rodrigo Lazo - rlazo.paz@gmail.com

;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 2 of the License, or
;; (at your option) any later version.

;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;; GNU General Public License for more details.

;; You should have received a copy of the GNU General Public License
;; along with this program; if not, write to the Free Software
;; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

(eval-when-compile (require 'jabber-alert))

(defcustom jabber-libnotify-icon ""
  "Icon to be used on the notification pop-up. Default is empty"
  :type '(file :must-match t)
  :group 'jabber-alerts)


(defcustom jabber-libnotify-timeout 2500
  "Specifies the timeout of the pop up window in millisecond"
  :type 'integer
  :group 'jabber-alerts)

(defcustom jabber-libnotify-message-header "Jabber message"
  "Defines the header of the pop up."
  :type 'string
  :group 'jabber-alerts)

(defcustom jabber-libnotify-urgency "low"
  "Urgency of libnotify message"
  :type '(choice (const :tag "Low" "low")
                 (const :tag "Normal" "normal")
                 (const :tag "Critical" "critical"))
  :group 'jabber-alerts)

(defun jabber-libnotify-message (msg)
  "Show MSG using libnotify"
  ;; Possible errors include not finding the notify-send binary.
  (condition-case e
      (let ((process-connection-type nil))
    (start-process "notification" nil "notify-send"
		   "-t" (format "%s" jabber-libnotify-timeout)
		   "-i" (or jabber-libnotify-icon "\"\"")
                   "-u" jabber-libnotify-urgency
		   (or jabber-libnotify-message-header " ") msg))
    (error nil)))


(define-jabber-alert libnotify "Show a message through the libnotify interface"
  'jabber-libnotify-message)
(define-personal-jabber-alert jabber-muc-libnotify)

(provide 'jabber-libnotify)

;; arch-tag: e9c4c210-8245-11dd-bddf-000a95c2fcd0