neokd / NeoGPT

Chat effortlessly, execute commands, and interpret code with Llama3, Phi3, and more - your local AI assistant. Enjoy seamless interaction while ensuring ultimate privacy
https://neogpt.dev
MIT License
68 stars 60 forks source link

Rewrite notify.py #138

Closed neokd closed 5 months ago

neokd commented 5 months ago

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.

ayushmorbar commented 5 months ago

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 commented 5 months ago

@ayushmorbar 1 issue at a time

ayushmorbar commented 5 months ago

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 commented 5 months ago

Sure

ayushmorbar commented 5 months ago

Please, Assign me this issue now!

neokd commented 5 months ago

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 commented 5 months ago

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 commented 5 months ago

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