mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-21 16:05:02 +02:00
Add support for OSC 777 based desktop notifications
Might as well, since we also support OSC 9, so why not yet another poorly designed legacy scheme.
This commit is contained in:
@@ -67,6 +67,9 @@ class NotificationCommand:
|
||||
body: str = ''
|
||||
actions: str = ''
|
||||
|
||||
def __repr__(self) -> str:
|
||||
return f'NotificationCommand(identifier={self.identifier!r}, title={self.title!r}, body={self.body!r}, actions={self.actions!r}, done={self.done!r})'
|
||||
|
||||
|
||||
def parse_osc_9(raw: str) -> NotificationCommand:
|
||||
ans = NotificationCommand()
|
||||
@@ -74,6 +77,15 @@ def parse_osc_9(raw: str) -> NotificationCommand:
|
||||
return ans
|
||||
|
||||
|
||||
def parse_osc_777(raw: str) -> NotificationCommand:
|
||||
parts = raw.split(';', 1)
|
||||
ans = NotificationCommand()
|
||||
ans.title = parts[0]
|
||||
if len(parts) > 1:
|
||||
ans.body = parts[1]
|
||||
return ans
|
||||
|
||||
|
||||
def parse_osc_99(raw: str) -> NotificationCommand:
|
||||
cmd = NotificationCommand()
|
||||
metadata, payload = raw.partition(';')[::2]
|
||||
@@ -201,3 +213,8 @@ def handle_notification_cmd(
|
||||
if osc_code == 9:
|
||||
cmd = parse_osc_9(raw_data)
|
||||
notify_with_command(cmd, window_id, notify_implementation)
|
||||
return cmd
|
||||
if osc_code == 777:
|
||||
cmd = parse_osc_777(raw_data)
|
||||
notify_with_command(cmd, window_id, notify_implementation)
|
||||
return cmd
|
||||
|
||||
Reference in New Issue
Block a user