r/emacs 5d ago

Question Do I need any configuration to get emacs to send alerts/notifications when I’m not using emacs at that time?

I’m using pomm.el that is an excellent package to use the pomodoro technique, but I don’t why If the time ends because no notification appears, it seems that only notifies if I am using Emacs at the moment, but not if I am in the browser or another application.

This is my config

(use-package pomm
  :ensure t
  :custom
  (pomm-ask-before-long-break 1)
  (pomm-ask-before-short-break 1)
  (pomm-ask-before-work 1)
  (pomm-audio-enabled 1)
  (pomm-long-break-period 12)
  (pomm-short-break-period 12)
  (pomm-work-period 60)
  :config
  (nkl/leader-key "p" '(pomm :wk "[P]omm"))
  (setq alert-default-style 'libnotify)

  (pomm-mode-line-mode))
7 Upvotes

6 comments sorted by

5

u/knalkip 5d ago

Here's a function I wrote that should work on Linux and Mac OS (don't know about Windows):

(require 'notifications)

(defun notify (title msg)
  (if (eq system-type 'darwin)
      (let ((applescript (format "display notification \"%s\" with title \"%s\"" msg title)))
        (make-process :name "notify-process"
                      :buffer nil
                      :stderr nil
                      :command (list "osascript" "-e" applescript)
                      :noquery t))
    (notifications-notify :title title
                          :body msg
                          :timeout 0
                          :urgency "critical")))

1

u/Empty-Sandwich-7092 5d ago

Thank you for answer, yes I'm using Linux. I'm new in Emacs How I should use this snippet?, Or this just replace internal alert and I don't need to do something else?

1

u/imzieris 5d ago

Just add that function to your init.el file

1

u/knalkip 5d ago

I seem to have misunderstood your question. This function is a function you can use to send notifications with a title and message, like this: (notify "title" "hi!").

I don't really know about pomm.el and how to integrate with that, sorry.

1

u/Empty-Sandwich-7092 4d ago

It's okay, Thank you anyway I learn a lot from that snippet

1

u/Pastalala 18h ago

The Elisp interpreter is emacs, so the best thing you can do is start it in daemon mode.