diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 3b317a607..a279d1cd8 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -45,6 +45,8 @@ version 0.6.0 [future] - Add an option to control the underline style for URL highlighting on hover +- X11: Set the WINDOWID environment variable + version 0.5.1 [2017-12-01] --------------------------- diff --git a/kitty/child.py b/kitty/child.py index a55e5e8ee..9dbe61e79 100644 --- a/kitty/child.py +++ b/kitty/child.py @@ -20,11 +20,12 @@ class Child: child_fd = pid = None forked = False - def __init__(self, argv, cwd, opts, stdin=None): + def __init__(self, argv, cwd, opts, stdin=None, env=None): self.argv = argv self.cwd = os.path.abspath(os.path.expandvars(os.path.expanduser(cwd or os.getcwd()))) self.opts = opts self.stdin = stdin + self.env = env or {} def fork(self): if self.forked: @@ -37,6 +38,7 @@ class Child: if stdin is not None: stdin_read_fd, stdin_write_fd = os.pipe() remove_cloexec(stdin_read_fd) + env = self.env pid = os.fork() if pid == 0: # child try: @@ -54,6 +56,7 @@ class Child: os.closerange(3, 200) # Establish the controlling terminal (see man 7 credentials) os.close(os.open(os.ttyname(1), os.O_RDWR)) + os.environ.update(env) os.environ['TERM'] = self.opts.term os.environ['COLORTERM'] = 'truecolor' if os.path.isdir(terminfo_dir): diff --git a/kitty/tabs.py b/kitty/tabs.py index bc884e667..881455e19 100644 --- a/kitty/tabs.py +++ b/kitty/tabs.py @@ -9,11 +9,13 @@ from functools import partial from .borders import Borders from .child import Child from .config import build_ansi_color_table -from .constants import WindowGeometry, appname, get_boss, shell_path +from .constants import ( + WindowGeometry, appname, get_boss, is_macos, is_wayland, shell_path +) from .fast_data_types import ( DECAWM, Screen, add_tab, glfw_post_empty_event, remove_tab, remove_window, set_active_tab, set_active_window, set_tab_bar_render_data, swap_tabs, - swap_windows, viewport_for_window + swap_windows, viewport_for_window, x11_window_id ) from .layout import Rect, all_layouts from .utils import color_as_int @@ -113,7 +115,14 @@ class Tab: # {{{ cmd = [shell_path] else: cmd = self.args.args or [shell_path] - ans = Child(cmd, self.cwd, self.opts, stdin) + env = {} + if not is_macos and not is_wayland: + try: + env['WINDOWID'] = str(x11_window_id(self.os_window_id)) + except Exception: + import traceback + traceback.print_exc() + ans = Child(cmd, self.cwd, self.opts, stdin, env) ans.fork() return ans