HOME about

Solve Emacs Not Compiled With Dbus Support issue

The error

When use the org-pomodora mode, emacs runs into following error:

dbus-call-method: peculiar error: "Emacs not compiled with dbus support"

My emacs’s version is 24.5.1 and runs on Mac OS 10.11. The error is caused by no default dbus support on Mac OS. It may be solved by installing dbus on Mac OS. I have not tried it. Because after take a look at the call-stack of this error, it turns out that it could be fixed by customize our own ‘org-show-notification’.

Debugger entered--Lisp error: (dbus-error "Emacs not compiled with dbus support")
  signal(dbus-error ("Emacs not compiled with dbus support"))
  dbus-call-method(:session "org.freedesktop.Notifications" "/org/freedesktop/Notifications" "org.freedesktop.Notifications" "Notify" :string "Emacs" :uint32 0 :string "/Applications/Emacs.app/Contents/Resources/etc/images/icons/hicolor/scalable/apps/emacs.svg" :string "Org-mode message" :string "Task 'Network exercise R23-R26' should be finished by now. (2)" (:array) ((:dict-entry "urgency" (:variant :byte 0))) :int32 -1)
  byte-code("..." [params id y x transient resident plist-get :bus :session :title :body :app-name :replaces-id :app-icon :actions :timeout nil :urgency :category :desktop-entry :image-data :image-path :action-items :sound-file :sound-name :suppress-sound :resident :transient :x :y :dict-entry "urgency" :variant :byte low 0 critical 2 1 append "category" :string "desktop-entry" "image-data" :struct "image-path" "action-items" :boolean "sound-file" "sound-name" ...] 25)
  notifications-notify(:title "Org-mode message" :body "Task 'Network exercise R23-R26' should be finished by now. (2)" :urgency low)
  org-show-notification("Task 'Test org-pomodoro' should be finished by now. (2)")
  org-notify("Task 'Network exercise R23-R26' should be finished by now. (2)" nil)
  org-clock-notify-once-if-expired()
  org-clock-update-mode-line()
  byte-code("..." [org-clock-resolving-clocks-due-to-idleness org-clock-resolving-clocks org-clock-leftover-time leftover org--msg-extra target-pos org-clocking-p nil "" t org-resolve-clocks (64) org-clock-in (4) org-clock-select-task "Clock-in on task: " copy-marker error "Abort" (16) org-clock-mark-default-task org-back-to-heading marker-buffer marker-position 4 org-heading-components message "Clock continues in \"%s\"" throw abort org-clock-out org-at-heading-p point-at-bol 0 org-base-buffer run-hooks org-clock-in-prepare-hook org-clock-history-push functionp looking-at match-string 2 org-todo "[    ]*" "\\>" replace-regexp-in-string "\\[\\[.*?\\]\\[\\(.*?\\)\\]\\]" "\\1" match-string-no-properties "???" ...] 8)
  org-clock-in(nil)
  call-interactively(org-clock-in)
  (cond ((equal arg (quote (4))) (let ((current-prefix-arg (quote (4)))) (call-interactively (quote org-clock-in)))) ((equal arg (quote (16))) (call-interactively (quote org-clock-in-last))) ((eq major-mode (quote org-mode)) (call-interactively (quote org-clock-in))) ((eq major-mode (quote org-agenda-mode)) (let ((--mpom (org-get-at-bol (quote org-hd-marker)))) (save-excursion (if (markerp --mpom) (set-buffer (marker-buffer --mpom))) (save-excursion (save-restriction (widen) (goto-char (or --mpom ...)) (call-interactively (quote org-clock-in))))))) (t (let ((current-prefix-arg (quote (4)))) (call-interactively (quote org-clock-in)))))
  (if (org-pomodoro-active-p) (if (or (not org-pomodoro-ask-upon-killing) (y-or-n-p "There is already a running timer.  Would you like to stop it? ")) (org-pomodoro-kill) (message "Alright, keep up the good work!")) (cond ((equal arg (quote (4))) (let ((current-prefix-arg (quote (4)))) (call-interactively (quote org-clock-in)))) ((equal arg (quote (16))) (call-interactively (quote org-clock-in-last))) ((eq major-mode (quote org-mode)) (call-interactively (quote org-clock-in))) ((eq major-mode (quote org-agenda-mode)) (let ((--mpom (org-get-at-bol (quote org-hd-marker)))) (save-excursion (if (markerp --mpom) (set-buffer (marker-buffer --mpom))) (save-excursion (save-restriction (widen) (goto-char ...) (call-interactively ...)))))) (t (let ((current-prefix-arg (quote (4)))) (call-interactively (quote org-clock-in))))) (org-pomodoro-start :pomodoro))
  org-pomodoro(nil)
  call-interactively(org-pomodoro nil nil)
  command-execute(org-pomodoro)    

A solution

Here are the steps:

  1. install terminal-notifier

    brew install terminal-notifier
    
  2. add terminal-notifier interface to your emacs (refer):

    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;; Terminal notifier 
    ;; requires 'brew install terminal-notifier'
    ;; stolen from erc-notifier
    
    (defvar terminal-notifier-command (executable-find "terminal-notifier") "The path to terminal-notifier.")
    
    ; (terminal-notifier-notify "Emacs notification" "Something amusing happened")
    
    (defun terminal-notifier-notify (title message)
      "Show a message with 
    terminal-notifier-command
    ."
      (start-process "terminal-notifier"
                     "terminal-notifier"
                     terminal-notifier-command
                     "-title" title
                     "-message" message
                     "-activate" "org.gnu.Emacs"))
    
    (defun timed-notification (time msg)
      (interactive "sNotification when (e.g: 2 minutes, 60 seconds, 3 days): \nsMessage: ")
      (run-at-time time nil (lambda (msg) (terminal-notifier-notify "Emacs" msg)) msg))
    
    
  3. customize your org-show-notification-handler

    (setq org-show-notification-handler
          (lambda (msg) (timed-notification nil msg)))
    

Done.

Date: 2016-02-03 Wed 00:00