Created
October 13, 2023 19:11
-
-
Save rgs1/ad15936ce8b47969b7de643b26959ade to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from pync import Notifier | |
from Foundation import NSUserNotificationCenter, NSObject, NSRunLoop, NSDate | |
class NotificationDelegate(NSObject): | |
def userNotificationCenter_didDeliverNotification_(self, center, notification): | |
title = notification.title() | |
subtitle = notification.subtitle() | |
message = notification.informativeText() | |
print(f"Received notification:\nTitle: {title}\nSubtitle: {subtitle}\nMessage: {message}\n") | |
def main(): | |
delegate = NotificationDelegate.alloc().init() | |
NSUserNotificationCenter.defaultUserNotificationCenter().setDelegate_(delegate) | |
# Run the main event loop to listen for notifications | |
run_loop = NSRunLoop.currentRunLoop() | |
while True: | |
run_loop.runUntilDate_(NSDate.dateWithTimeIntervalSinceNow_(1)) | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment