Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rewrite notify.py #138

Closed
neokd opened this issue Jan 21, 2024 · 8 comments
Closed

Rewrite notify.py #138

neokd opened this issue Jan 21, 2024 · 8 comments
Assignees
Labels
enhancement New feature or request hard JWOC

Comments

@neokd
Copy link
Owner

neokd commented Jan 21, 2024

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.

@neokd neokd added hard JWOC enhancement New feature or request labels Jan 21, 2024
@neokd neokd changed the title Rewrite Desktop Notification Implementation using Plyer Rewrite notify.py Jan 25, 2024
@ayushmorbar
Copy link
Contributor

ayushmorbar commented Feb 1, 2024

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')

@neokd
Copy link
Owner Author

neokd commented Feb 1, 2024

@ayushmorbar 1 issue at a time

@ayushmorbar
Copy link
Contributor

yeah, i understand that. please do review my pull request as mentioned so I can get on this one quick and submit a pr

@neokd
Copy link
Owner Author

neokd commented Feb 1, 2024

Sure

@ayushmorbar
Copy link
Contributor

Please, Assign me this issue now!

@neokd
Copy link
Owner Author

neokd commented Feb 3, 2024

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?

@ayushmorbar
Copy link
Contributor

ayushmorbar commented Feb 3, 2024

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.

@neokd
Copy link
Owner Author

neokd commented Feb 3, 2024

Great then, You can push the code once you are done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request hard JWOC
Projects
None yet
Development

No branches or pull requests

2 participants