marcinkoziej/org-pomodoro

No sounds or notifications/alerts in Windows

mirenbz opened this issue · 3 comments

Hi,

First of all, sorry if this question is too basic, but I'm quite a beginner with Emacs/Org Mode and can't figure it out.

I'm using Windows (10) and have set almost all org-pomodoro sound-related variables to 'on', and checked that paths to sound files are all good. I even tried setting wmplayer as "Audio player" as suggested in #41, but can't make sounds play in Windows.

Also, I don't get any alerts/notifications...

Could you please point me in some direction to get this to work?

Thanks in advance!

Just as an update, I followed this post about getting native notifications on Windows for agenda events as an attempt, but didn't work either.

However sounds DO work after installing sound-wav-play as seen on #58 👏

To get notifications working in Windows, I have the following bits under a windows conditional:

(setq alert-default-style 'toaster)
             (setq alert-toaster-command (expand-file-name "~/build/toaster/toast/bin/Release/toast.exe"))
             (setq alert-toaster-default-icon (expand-file-name "~/opt/emacs-26.2-x86_64/share/icons/hicolor/128x128/apps/emacs.png"))

This is likely related to issue #47 in the alert.el library.

Until that's working again, here's a workaround.

  1. Either clone toaster from https://github.com/nels-o/toaster or download the zip and unzip it. This is the simplest way to manually create notifications on Windows that I know of.

image

  1. Make sure that the toaster directory is on your PATH. (To check if it is, do Win + R cmd then type toast -m "Hello, world!". If a notification pops up, toaster is on your PATH. Note that the package is called "toaster" and the executable is called "toast").

  2. After loading org-pomodoro, run the following code by placing your cursor after the last parenthesis and pressing C-x C-e:

(defun org-pomodoro-notify (title message)
  "Temporary replacement for function of the same name which uses
the buggy alert.el package.  TITLE is the title of the MESSAGE."
  (let*
      ((toast "toast")
       (t-title (concat " -t \"" title))
       (t-message (concat "\" -m \"" message "\""))
       (t-image (concat " -p \"C:\\Program Files\\emacs\\share\\icons\\hicolor\\128x128\\apps\\emacs.png\""))
       (my-command (concat toast t-title t-message t-image)))
    (call-process-shell-command my-command)))

This will replace the function of the same name provided in org-pomodoro. You will likely need to replace the string for ...\\emacs.png. Make sure you're careful to keep the escaped quotes. There should be a \" on each side of your path. For example, \"C:\\path\\to\\your\\image.png\". All the command does is take in title and message and smoosh them into a well formatted string which is sent to a shell process. For example, calling (org-pomodoro "My Title" "My Message!") issues a shell command of

toast -t "My Title" -m "My Message!" -p "C:\\Program Files\\emacs\\share\\icons\\hicolor\\128x128\\apps\\emacs.png"