Xpra: Ticket #1305: native OSX notifications

See wiki/Notifications: replace the existing GTK notifier code with native macos notifications:

Maybe wait for the newer build environment (#840) to make it easier to test?



Tue, 13 Sep 2016 11:44:55 GMT - Antoine Martin: status, milestone changed

I tried a quick test and there are issues with the notification code: NSUserNotificationCenter.defaultUserNotificationCenter() returning None using PyInstaller. The same code works when using the system installed python! So we either have to fix this (not sure how) or use a subprocess... yuk.


Sat, 18 Feb 2017 15:13:04 GMT - Antoine Martin: attachment set

try to use native code for notifications


Sat, 18 Feb 2017 15:55:50 GMT - Antoine Martin:

The notification center API just isn't accessible from our environment - no idea why, changing the CFBundleIdentifier (lowercase or whatever) does not help, neither does signing the app, installing using a PKG, etc..

We can run the exact same code from the system python interpreter though... So the patch above attempted to load the notification center directly and when that fails resorts to running the same code using the system interpreter via exec. And that also fails mysteriously. I even tried calling "osascript -e .." and using applescript via pyobjc. None of these solutions work. I give up.


Tue, 14 Nov 2017 14:09:14 GMT - Antoine Martin:

See #1688


Sun, 26 Nov 2017 14:08:34 GMT - Antoine Martin: milestone changed

Let's try again..


Thu, 28 Dec 2017 08:30:03 GMT - Antoine Martin: status changed; resolution set

Found a partial solution here: https://github.com/jaredks/rumps/issues/9#issuecomment-94320800: I can also get this working by putting an Info.plist file directly into the same bin dir as my virtualenv's python. No idea why we have to copy the Info.plist to yet another location, but that sort of fixes it: r17769. We now have two new notifier helpers (both disabled by default since r17771):

Also, all the notifications use the icon of the main process (xpra's) and we can't override it. The "subprocess" one shows notifications every time, but we cannot cancel them (the process that generated them is short lived) and clicking on the application icon starts up a new xpra launcher... The "native" one sort of works, but Apple decided that when the application already has focus, it will move the notifications directly to the notification center without first appearing on screen at all. (see https://stackoverflow.com/a/25303802/428751) So that makes the notifications completely useless to us, and I don't see any easy workaround for it: spawning a daemon app (one that would never get focus) could lead to all sorts of other problems (hard to implement callbacks, or send focus back to main xpra process, etc) and I'm not even sure we can have notifications in a non-gui app (one that does not have an icon in the dock).

At this point, the only potential solution that I can think of is #1727: "dock icon per forwarded application"

For testing, one can generate notifications without using a specific application on the server:

xpra control :10 send-notification 0001  'notification title' 'notification message' '*'
xpra control :10 close-notification 0001 '*'

Sat, 23 Jan 2021 05:20:38 GMT - migration script:

this ticket has been moved to: https://github.com/Xpra-org/xpra/issues/1305