RSS Amplifier

Martin's Blog · Feb 7, 2025

Emacs Notifications on Android

0
Sign in to vote or save

Martin Stemplinger · Martin's Blog

  • Note taken on [2025-04-04 Fri 14:02]
    Small update: include a notification icon

I’m a happy user of the native graphical Emacs on Android since several months now. Last week a Reddit user asked for experience and on particular if they can get notifications for their org agenda items.

My initial reaction was “probably not” but I got curious and looked into it a bit. Turns out I was wrong and in fact it’s quite simple. One more example of why the emacs native android port is so great: you can use almost any existing Emacs extension!

Here is what I found in case it’s useful for others.

The solution uses:

  • the org alert package
  • which internally uses the alert package.
  • Android Emacs notifications support via the android-notifications-notify function.

The alert package includes an easy extension mechanism. All I had to do was to define a new alert-style which uses android-notifications-notify and set that as default.

(use-package alert
  :config
  (when (eq system-type 'android)
    (alert-define-style
     'android-notification-style
     :title "Android Notification style"
     :notifier
     (lambda (info)
       (let ((notif-id (android-notifications-notify :title  (plist-get info :title) :icon "ic_menu_my_calendar" :body (plist-get info :message)))))))
    (setq alert-default-style 'android-notification-style)))

After using it for a while I was slightly disappointed that the notifictions show an alert icon so I tried to figure out how to set a different icon. As per the documentation of android-notifications-notify it has to be an Android drawable resource. I found a list in the R.drawable API reference and tried a few. The calendar seemed the most appropriate and is used in the code above.

The org-alert package didn’t require any specific configuration.

(use-package org-alert
  :config
  (org-alert-enable))

org-alert limits notifications to items that are either marked as scheduled or have a deadline. If you need something else you may need to use one of the other packages. As long as they use alert this approach should work.

Of course keep in mind that you need to keep Emacs running for notifications to fire.

Read the original on mstempl.netlify.app

Comments

Nothing yet. Say the first thing.

    Sign in to join the conversation.