Rewrite notify.py
Closed this issue · 8 comments
To enhance cross-platform compatibility and achieve seamless desktop notifications, we suggest transitioning from the current desktop_notifier to the plyer library. This refactoring ensures broader support. This upgrade aims to simplify the notification setup for a smoother and more universally compatible user experience.
Can you assign me this issue, as it's look interesting as part of JWoC'24.
By the way, i need to replace the desktop_notifier module with the plyer library right and that's all.
import asyncio
from plyer import notification
async def notify(title, message, timeout=10):
"""
Show a desktop notification to the user.
Parameters:
title: notification title - required
message: notification message - required
timeout: timeout in seconds to hide the notification. Default value is 10 - optional
"""
notification.notify(
title=title,
message=message,
timeout=timeout
)
await asyncio.sleep(timeout) # Wait for the specified timeout
## test
await notify('test', 'this is a test notification')
@ayushmorbar 1 issue at a time
yeah, i understand that. please do review my pull request as mentioned so I can get on this one quick and submit a pr
Sure
Please, Assign me this issue now!
Can you assign me this issue, as it's look interesting as part of JWoC'24.
By the way, i need to replace the desktop_notifier module with the plyer library right and that's all.
import asyncio from plyer import notification async def notify(title, message, timeout=10): """ Show a desktop notification to the user. Parameters: title: notification title - required message: notification message - required timeout: timeout in seconds to hide the notification. Default value is 10 - optional """ notification.notify( title=title, message=message, timeout=timeout ) await asyncio.sleep(timeout) # Wait for the specified timeout ## test await notify('test', 'this is a test notification')
Does this work with macos?
I haven't tried it myself yet on MacOS, but Plyer is designed to be platform-independent. According to the information provided by some user on Stack Overflow, it seems to work on MacOS 12.3.1.
To ensure proper functionality, make sure you have allowed notifications from`terminal-notifier` in your System Preferences. Navigate to
`System Preferences -> Notifications & Focus -> terminal-notifier`,
and ensure that notifications are allowed.
If you encounter any issues, consider checking your overall notification settings on your Mac, as notifications might be disabled, or you might be in a "focus" mode, which could affect notification display. Adjusting these settings should enable the desktop notifications for the provided code.
Aside from this given the functionality of the notifier function, we can pass more parameters like the app icon, name and stuff.
Great then, You can push the code once you are done