mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-08 21:25:32 +02:00
Clean up previous PR
This commit is contained in:
@@ -3168,15 +3168,15 @@ The possible values are:
|
||||
:code:`always`
|
||||
Always send a notification, regardless of window state.
|
||||
|
||||
Furthermore, you can set two optional arguments:
|
||||
There are two optional arguments:
|
||||
|
||||
1. The minimum duration for what is considered a
|
||||
First, the minimum duration for what is considered a
|
||||
long running command. The default is 5 seconds. Specify a second argument
|
||||
to set the duration. For example: :code:`invisible 15`.
|
||||
Do not set the value too small, otherwise a command that launches a new OS Window
|
||||
and exits will spam a notification.
|
||||
|
||||
2. The action to perform. The default is :code:`notify`. The possible values are:
|
||||
Second, the action to perform. The default is :code:`notify`. The possible values are:
|
||||
|
||||
:code:`notify`
|
||||
Send a desktop notification.
|
||||
@@ -3196,7 +3196,7 @@ Some more examples::
|
||||
# Ring a bell when a command takes more than 10 seconds in a invisible window
|
||||
notify_on_cmd_finish invisible 10.0 bell
|
||||
# Run 'notify-send' when a command takes more than 10 seconds in a invisible window
|
||||
notify_on_cmd_finish invisible 10.0 command notify-send command finished
|
||||
notify_on_cmd_finish invisible 10.0 command notify-send job finished
|
||||
'''
|
||||
)
|
||||
|
||||
|
||||
2
kitty/options/types.py
generated
2
kitty/options/types.py
generated
@@ -549,7 +549,7 @@ class Options:
|
||||
mark3_background: Color = Color(242, 116, 188)
|
||||
mark3_foreground: Color = Color(0, 0, 0)
|
||||
mouse_hide_wait: float = 0.0 if is_macos else 3.0
|
||||
notify_on_cmd_finish: NotifyOnCmdFinish = NotifyOnCmdFinish(when='never', duration=5.0, action='notify', cmdline=[])
|
||||
notify_on_cmd_finish: NotifyOnCmdFinish = NotifyOnCmdFinish(when='never', duration=5.0, action='notify', cmdline=())
|
||||
open_url_with: typing.List[str] = ['default']
|
||||
paste_actions: typing.FrozenSet[str] = frozenset({'confirm', 'quote-urls-at-prompt'})
|
||||
placement_strategy: choices_for_placement_strategy = 'center'
|
||||
|
||||
@@ -706,10 +706,11 @@ class NotifyOnCmdFinish(NamedTuple):
|
||||
when: str
|
||||
duration: float
|
||||
action: str
|
||||
cmdline: List[str]
|
||||
cmdline: Tuple[str, ...]
|
||||
|
||||
|
||||
def notify_on_cmd_finish(x: str) -> NotifyOnCmdFinish:
|
||||
parts = x.split()
|
||||
parts = x.split(maxsplit=3)
|
||||
if parts[0] not in ('never', 'unfocused', 'invisible', 'always'):
|
||||
raise ValueError(f'Unknown notify_on_cmd_finish value: {parts[0]}')
|
||||
when = parts[0]
|
||||
@@ -717,14 +718,14 @@ def notify_on_cmd_finish(x: str) -> NotifyOnCmdFinish:
|
||||
if len(parts) > 1:
|
||||
duration = float(parts[1])
|
||||
action = 'notify'
|
||||
cmdline = []
|
||||
cmdline: Tuple[str, ...] = ()
|
||||
if len(parts) > 2:
|
||||
if parts[2] not in ('notify', 'bell', 'command'):
|
||||
raise ValueError(f'Unknown notify_on_cmd_finish action: {parts[2]}')
|
||||
action = parts[2]
|
||||
if action == 'command':
|
||||
if len(parts) > 3:
|
||||
cmdline = parts[3:]
|
||||
cmdline = tuple(to_cmdline(parts[3]))
|
||||
else:
|
||||
raise ValueError('notify_on_cmd_finish `command` action needs a command line')
|
||||
return NotifyOnCmdFinish(when, duration, action, cmdline)
|
||||
|
||||
Reference in New Issue
Block a user