mirror of
https://github.com/kovidgoyal/kitty.git
synced 2026-10-24 22:28:29 +00:00
When using --single-instance allow creating sessions with only background processes
This commit is contained in:
parent
499eb3c3c2
commit
9be6b9c374
2 changed files with 28 additions and 0 deletions
|
|
@ -822,6 +822,15 @@ class Boss:
|
|||
args.directory = os.path.join(data['cwd'], args.directory)
|
||||
focused_os_window = os_window_id = 0
|
||||
for session in create_sessions(opts, args, respect_cwd=True):
|
||||
if not session.has_non_background_processes:
|
||||
# background only do not create and OS Window
|
||||
from .launch import LaunchSpec, launch
|
||||
for tab in session.tabs:
|
||||
for window in tab.windows:
|
||||
if window.is_background_process:
|
||||
assert isinstance(window.launch_spec, LaunchSpec)
|
||||
launch(get_boss(), window.launch_spec.opts, window.launch_spec.args)
|
||||
continue
|
||||
os_window_id = self.add_os_window(
|
||||
session, wclass=args.cls, wname=args.name, opts_for_size=opts, startup_id=startup_id,
|
||||
override_title=args.title or None)
|
||||
|
|
|
|||
|
|
@ -39,6 +39,11 @@ class WindowSpec:
|
|||
def __init__(self, launch_spec: Union['LaunchSpec', 'SpecialWindowInstance']):
|
||||
self.launch_spec = launch_spec
|
||||
self.resize_spec: Optional[ResizeSpec] = None
|
||||
self.is_background_process = False
|
||||
if hasattr(launch_spec, 'opts'): # LaunchSpec
|
||||
from .launch import LaunchSpec
|
||||
assert isinstance(launch_spec, LaunchSpec)
|
||||
self.is_background_process = launch_spec.opts.type == 'background'
|
||||
|
||||
|
||||
class Tab:
|
||||
|
|
@ -53,6 +58,13 @@ class Tab:
|
|||
self.cwd: Optional[str] = None
|
||||
self.next_title: Optional[str] = None
|
||||
|
||||
@property
|
||||
def has_non_background_processes(self) -> bool:
|
||||
for w in self.windows:
|
||||
if not w.is_background_process:
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
class Session:
|
||||
|
||||
|
|
@ -65,6 +77,13 @@ class Session:
|
|||
self.os_window_state: Optional[str] = None
|
||||
self.focus_os_window: bool = False
|
||||
|
||||
@property
|
||||
def has_non_background_processes(self) -> bool:
|
||||
for t in self.tabs:
|
||||
if t.has_non_background_processes:
|
||||
return True
|
||||
return False
|
||||
|
||||
def add_tab(self, opts: Options, name: str = '') -> None:
|
||||
if self.tabs and not self.tabs[-1].windows:
|
||||
del self.tabs[-1]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue