mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-21 16:05:02 +02:00
Use Linux native notifications timeout functionality
Allows behaviors like not expiring notification if user hovers over it, etc.
This commit is contained in:
@@ -451,6 +451,7 @@ class DesktopIntegration:
|
|||||||
supports_buttons: bool = True
|
supports_buttons: bool = True
|
||||||
supports_sound: bool = True
|
supports_sound: bool = True
|
||||||
supports_sound_names: str = 'xdg-names'
|
supports_sound_names: str = 'xdg-names'
|
||||||
|
supports_timeout_natively: bool = True
|
||||||
|
|
||||||
def __init__(self, notification_manager: 'NotificationManager'):
|
def __init__(self, notification_manager: 'NotificationManager'):
|
||||||
self.notification_manager = notification_manager
|
self.notification_manager = notification_manager
|
||||||
@@ -500,6 +501,7 @@ class MacOSIntegration(DesktopIntegration):
|
|||||||
|
|
||||||
supports_close_events: bool = False
|
supports_close_events: bool = False
|
||||||
supports_sound_names: str = ''
|
supports_sound_names: str = ''
|
||||||
|
supports_timeout_natively: bool = False
|
||||||
|
|
||||||
def initialize(self) -> None:
|
def initialize(self) -> None:
|
||||||
from .fast_data_types import cocoa_set_notification_activated_callback
|
from .fast_data_types import cocoa_set_notification_activated_callback
|
||||||
@@ -860,7 +862,7 @@ class NotificationManager:
|
|||||||
def notification_created(self, desktop_notification_id: int) -> Optional[NotificationCommand]:
|
def notification_created(self, desktop_notification_id: int) -> Optional[NotificationCommand]:
|
||||||
if n := self.in_progress_notification_commands.get(desktop_notification_id):
|
if n := self.in_progress_notification_commands.get(desktop_notification_id):
|
||||||
n.created_by_desktop = True
|
n.created_by_desktop = True
|
||||||
if n.timeout > 0:
|
if n.timeout > 0 and not self.desktop_integration.supports_timeout_natively:
|
||||||
add_timer(partial(self.expire_notification, desktop_notification_id, id(n)), n.timeout / 1000, False)
|
add_timer(partial(self.expire_notification, desktop_notification_id, id(n)), n.timeout / 1000, False)
|
||||||
return n
|
return n
|
||||||
return None
|
return None
|
||||||
|
|||||||
Reference in New Issue
Block a user