Add os_window_title to sessions

This commit is contained in:
Kovid Goyal 2025-09-01 19:30:50 +05:30
parent ab4e86dfec
commit e1d8565fb6
No known key found for this signature in database
GPG key ID: 06BC317B515ACE7C
3 changed files with 12 additions and 1 deletions

View file

@ -135,6 +135,8 @@ all the major keywords you can use in kitty session files:
new_os_window
# Set new window size to 80x24 cells
os_window_size 80c 24c
# Set the --title for the new OS window
os_window_title my fancy os window
# Set the --class for the new OS window
os_window_class mywindow
# Set the --name for the new OS window
@ -291,6 +293,11 @@ documentation for them.
Create a new tab with the specified title. If no title is specified, the
title behaves just as for a regular tab in kitty.
``os_window_title``
Set the title for the current OS Window. The OS Window will then always
have this title, it will not change based on the title of the currently active
window inside the OS Window.
``os_window_class``
Set the class part of WM_CLASS or Wayland Application Id for the current OS Window

View file

@ -456,7 +456,7 @@ class Boss:
size_data = get_os_window_sizing_data(opts_for_size or get_options(), startup_session)
wclass = wclass or getattr(startup_session, 'os_window_class', None) or self.args.cls or appname
wname = wname or getattr(startup_session, 'os_window_name', None) or self.args.name or wclass
wtitle = override_title or self.args.title
wtitle = override_title or getattr(startup_session, 'os_window_title', None) or self.args.title
window_state = window_state or getattr(startup_session, 'os_window_state', None)
wstate = parse_os_window_state(window_state) if window_state is not None else None
with startup_notification_handler(do_notify=startup_id is not None, startup_id=startup_id) as pre_show_callback:

View file

@ -92,6 +92,7 @@ class Session:
self.os_window_class: str | None = None
self.os_window_name: str | None = None
self.os_window_state: str | None = None
self.os_window_title: str | None = None
self.focus_os_window: bool = False
@property
@ -263,6 +264,8 @@ def parse_session(
ans.os_window_class = rest
elif cmd == 'os_window_name':
ans.os_window_name = rest
elif cmd == 'os_window_title':
ans.os_window_title = rest
elif cmd == 'os_window_state':
ans.os_window_state = rest
elif cmd == 'resize_window':
@ -339,6 +342,7 @@ def create_sessions(
if args is not None:
ans.os_window_class = args.cls
ans.os_window_name = args.name
ans.os_window_title = args.title
if special_window is None:
cmd = args.args if args and args.args else resolved_shell(opts)
from kitty.tabs import SpecialWindow