mirror of
https://github.com/kovidgoyal/kitty.git
synced 2026-11-21 07:35:08 +00:00
Fix #10603
This commit is contained in:
parent
83e5692817
commit
033674afea
7 changed files with 104 additions and 8 deletions
|
|
@ -206,6 +206,15 @@ Detailed list of changes
|
|||
status bars, file trees, etc. Create them with :code:`launch --type=window-dock`
|
||||
or :code:`launch --type=tab-dock`, see :ref:`docks`
|
||||
|
||||
- quick-access-terminal kitten: A new :option:`kitty +kitten quick_access_terminal --if-running`
|
||||
option to run a program in a new tab or window of an already running quick
|
||||
access terminal and a new :option:`kitty +kitten quick_access_terminal --listen-on` option
|
||||
to specify a fixed remote control socket address. Also a new
|
||||
:option:`kitty +kitten quick_access_terminal --hold` option to keep the
|
||||
terminal open after the program exits (:iss:`10603`)
|
||||
|
||||
- quick-access-terminal kitten: Fix :option:`kitty +kitten quick_access_terminal --detached-log` not working
|
||||
|
||||
- Wayland: Support touchscreens. A tap is a click, a finger that moves scrolls
|
||||
with momentum, and a finger held still before it moves selects text
|
||||
(:iss:`5432`, :pull:`10551`)
|
||||
|
|
|
|||
|
|
@ -65,9 +65,20 @@ various kitty settings, just for the quick access window.
|
|||
This kitten uses the :doc:`panel kitten </kittens/panel>` under the
|
||||
hood. You can use the :ref:`techniques described there <remote_control_panel>`
|
||||
for remote controlling the quick access window, remember to add
|
||||
``kitty_override allow_remote_control=socket-only`` and ``kitty_override
|
||||
listen_on=unix:/tmp/whatever`` to
|
||||
:file:`quick-access-terminal.conf`.
|
||||
``kitty_override allow_remote_control=socket-only`` to
|
||||
:file:`quick-access-terminal.conf` and run the kitten with
|
||||
:option:`--listen-on <kitty +kitten quick_access_terminal --listen-on>`:code:`=unix:/tmp/whatever`
|
||||
to get a fixed socket address.
|
||||
|
||||
.. tip::
|
||||
|
||||
To run programs in the already running quick access terminal, use
|
||||
:option:`--if-running <kitty +kitten quick_access_terminal --if-running>`, for example::
|
||||
|
||||
kitten quick-access-terminal --if-running=new-tab htop
|
||||
|
||||
This will open :program:`htop` in a new tab and show the quick access
|
||||
terminal if it is hidden.
|
||||
|
||||
See below for the supported configuration directives:
|
||||
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ from kitty.fast_data_types import (
|
|||
GLFW_LAYER_SHELL_OVERLAY,
|
||||
GLFW_LAYER_SHELL_PANEL,
|
||||
GLFW_LAYER_SHELL_TOP,
|
||||
current_focused_os_window_id,
|
||||
layer_shell_config_for_os_window,
|
||||
set_layer_shell_config,
|
||||
toggle_os_window_visibility,
|
||||
|
|
@ -162,7 +163,22 @@ def have_config_files_been_updated(config_files: Iterable[str]) -> bool:
|
|||
return ans
|
||||
|
||||
|
||||
def handle_single_instance_command(boss: BossType, sys_args: Sequence[str], environ: Mapping[str, str], notify_on_os_window_death: str | None = '') -> None:
|
||||
def run_in_existing_panel(boss: BossType, cmd: list[str], environ: Mapping[str, str], cwd: str) -> None:
|
||||
from kitty.tabs import SpecialWindow
|
||||
|
||||
tm = boss.os_window_map.get(current_focused_os_window_id()) or next(iter(boss.os_window_map.values()))
|
||||
sw = SpecialWindow(cmd=cmd, env=dict(environ), cwd=cwd or None, hold=args.hold)
|
||||
tab = tm.active_tab
|
||||
if args.if_running == 'new-window' and tab is not None:
|
||||
tab.new_special_window(sw)
|
||||
else:
|
||||
tm.new_tab(sw)
|
||||
boss.focus_os_window(tm.os_window_id)
|
||||
|
||||
|
||||
def handle_single_instance_command(
|
||||
boss: BossType, sys_args: Sequence[str], environ: Mapping[str, str], notify_on_os_window_death: str | None = '', cwd: str = ''
|
||||
) -> None:
|
||||
global args
|
||||
from kitty.cli import parse_override
|
||||
from kitty.tabs import SpecialWindow
|
||||
|
|
@ -178,19 +194,25 @@ def handle_single_instance_command(boss: BossType, sys_args: Sequence[str], envi
|
|||
if config_changed:
|
||||
boss.load_config_file(*args.config, overrides=tuple(map(parse_override, new_args.override)))
|
||||
if args.toggle_visibility and boss.os_window_map:
|
||||
run_in_existing = bool(items) and args.if_running != 'ignore'
|
||||
for os_window_id in boss.os_window_map:
|
||||
existing = layer_shell_config_for_os_window(os_window_id)
|
||||
layer_shell_config_changed = not existing or any(f for f in lsc._fields if getattr(lsc, f) != existing.get(f))
|
||||
toggle_os_window_visibility(os_window_id, move_to_active_screen=args.move_to_active_monitor)
|
||||
if run_in_existing:
|
||||
toggle_os_window_visibility(os_window_id, visible=True, move_to_active_screen=args.move_to_active_monitor)
|
||||
else:
|
||||
toggle_os_window_visibility(os_window_id, move_to_active_screen=args.move_to_active_monitor)
|
||||
if layer_shell_config_changed:
|
||||
set_layer_shell_config(os_window_id, lsc)
|
||||
if run_in_existing:
|
||||
run_in_existing_panel(boss, items, environ, cwd)
|
||||
return
|
||||
items = items or [kitten_exe(), 'run-shell']
|
||||
os_window_id = boss.add_os_panel(lsc, args.cls, args.name)
|
||||
if notify_on_os_window_death:
|
||||
boss.os_window_death_actions[os_window_id] = partial(boss.notify_on_os_window_death, notify_on_os_window_death)
|
||||
tm = boss.os_window_map[os_window_id]
|
||||
tm.new_tab(SpecialWindow(cmd=items, env=dict(environ)))
|
||||
tm.new_tab(SpecialWindow(cmd=items, env=dict(environ), hold=args.hold))
|
||||
|
||||
|
||||
def main(sys_args: list[str]) -> None:
|
||||
|
|
@ -234,6 +256,8 @@ def actual_main(sys_args: list[str]) -> None:
|
|||
sys.argv.append(f'--instance-group={args.instance_group}')
|
||||
if args.listen_on:
|
||||
sys.argv.append(f'--listen-on={args.listen_on}')
|
||||
if args.hold:
|
||||
sys.argv.append('--hold')
|
||||
|
||||
sys.argv.extend(items)
|
||||
from kitty.main import main as real_main
|
||||
|
|
|
|||
|
|
@ -99,12 +99,21 @@ func main(cmd *cli.Command, opts *Options, args []string) (rc int, err error) {
|
|||
if dl, err := filepath.Abs(opts.DetachedLog); err != nil {
|
||||
return 1, err
|
||||
} else {
|
||||
argv = append(argv, dl)
|
||||
argv = append(argv, fmt.Sprintf("--detached-log=%s", dl))
|
||||
}
|
||||
}
|
||||
if opts.InstanceGroup != "" {
|
||||
argv = append(argv, fmt.Sprintf("--instance-group=%s", opts.InstanceGroup))
|
||||
}
|
||||
if opts.IfRunning != "" && opts.IfRunning != "ignore" {
|
||||
argv = append(argv, fmt.Sprintf("--if-running=%s", opts.IfRunning))
|
||||
}
|
||||
if opts.Hold {
|
||||
argv = append(argv, `--hold`)
|
||||
}
|
||||
if opts.ListenOn != "" {
|
||||
argv = append(argv, fmt.Sprintf("--listen-on=%s", opts.ListenOn))
|
||||
}
|
||||
|
||||
argv = append(argv, args...)
|
||||
err = unix.Exec(kitty_exe, argv, os.Environ())
|
||||
|
|
|
|||
|
|
@ -146,6 +146,33 @@ default=quick-access
|
|||
The unique name of this quick access terminal Use a different name if you want multiple such terminals.
|
||||
|
||||
|
||||
--if-running
|
||||
choices=ignore,new-tab,new-window
|
||||
default=ignore
|
||||
What to do when a program to run is specified on the command line and the
|
||||
quick access terminal is already running. The default, :code:`ignore`,
|
||||
ignores the program and just toggles the visibility of the quick access terminal.
|
||||
:code:`new-tab` runs the program in a new tab and :code:`new-window` runs it in a
|
||||
new window in the active tab. In both these cases, the quick access terminal is
|
||||
made visible, if hidden.
|
||||
|
||||
|
||||
--hold
|
||||
type=bool-set
|
||||
Remain open, at a shell prompt, after the program run in the quick access
|
||||
terminal exits, instead of closing the tab or window.
|
||||
|
||||
|
||||
--listen-on
|
||||
completion=type:special group:complete_kitty_listen_on
|
||||
Listen on the specified socket address for remote control messages. For example,
|
||||
:code:`unix:@quick-access` or :code:`unix:/tmp/quick-access`. Unlike the
|
||||
:opt:`listen_on` option in :file:`kitty.conf`, the process id of kitty
|
||||
is not appended to the address. Note that this will be ignored unless
|
||||
:opt:`allow_remote_control` is enabled, which you can do via
|
||||
:opt:`kitty_override <kitten-quick_access_terminal.kitty_override>`.
|
||||
|
||||
|
||||
--debug-rendering
|
||||
type=bool-set
|
||||
For debugging interactions with the compositor/window manager.
|
||||
|
|
|
|||
|
|
@ -1023,7 +1023,7 @@ class Boss:
|
|||
if data['args'][0] == 'panel':
|
||||
from kittens.panel.main import handle_single_instance_command
|
||||
|
||||
handle_single_instance_command(self, data['args'], data['environ'], data.get('notify_on_os_window_death', ''))
|
||||
handle_single_instance_command(self, data['args'], data['environ'], data.get('notify_on_os_window_death', ''), data.get('cwd', ''))
|
||||
return None
|
||||
from .cli_stub import CLIOptions
|
||||
|
||||
|
|
|
|||
|
|
@ -771,6 +771,22 @@ When set and using :option:`--single-instance` will toggle the visibility of the
|
|||
existing panel rather than creating a new one.
|
||||
|
||||
|
||||
--if-running
|
||||
choices=ignore,new-tab,new-window
|
||||
default=ignore
|
||||
When using :option:`--toggle-visibility` and a program to run is specified
|
||||
on the command line, controls what happens if the panel is already running.
|
||||
The default, :code:`ignore`, ignores the program and just toggles the visibility of the panel.
|
||||
:code:`new-tab` runs the program in a new tab in the existing panel and
|
||||
:code:`new-window` runs it in a new window in the active tab of the existing panel.
|
||||
In both these cases, the panel is made visible, if hidden.
|
||||
|
||||
|
||||
--hold
|
||||
type=bool-set
|
||||
Remain open, at a shell prompt, after the program run in the panel exits.
|
||||
|
||||
|
||||
--move-to-active-monitor
|
||||
type=bool-set
|
||||
default=false
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue