Make the kitty window id available as the environment variable KITTY_WINDOW_ID

Fixes #532
This commit is contained in:
Kovid Goyal 2018-05-10 08:52:28 +05:30
parent 87ab0d7b18
commit dec1203ea8
No known key found for this signature in database
GPG key ID: 06BC317B515ACE7C
2 changed files with 8 additions and 2 deletions

View file

@ -328,6 +328,10 @@ set_special_keys(PyObject *dict) {
}}
}
PYWRAP0(next_window_id) {
return PyLong_FromUnsignedLongLong(global_state.window_id_counter + 1);
}
PYWRAP1(handle_for_window_id) {
id_type os_window_id;
PA("K", &os_window_id);
@ -600,6 +604,7 @@ KK5I(add_borders_rect)
static PyMethodDef module_methods[] = {
MW(current_os_window, METH_NOARGS),
MW(next_window_id, METH_NOARGS),
MW(set_options, METH_VARARGS),
MW(set_in_sequence_mode, METH_O),
MW(resolve_key_mods, METH_VARARGS),

View file

@ -12,8 +12,8 @@ from .config import build_ansi_color_table
from .constants import WindowGeometry, appname, get_boss, is_macos, is_wayland
from .fast_data_types import (
DECAWM, Screen, add_tab, glfw_post_empty_event, mark_tab_bar_dirty,
remove_tab, remove_window, set_active_tab, set_tab_bar_render_data,
swap_tabs, viewport_for_window, x11_window_id
next_window_id, remove_tab, remove_window, set_active_tab,
set_tab_bar_render_data, swap_tabs, viewport_for_window, x11_window_id
)
from .layout import Rect, all_layouts
from .session import resolved_shell
@ -167,6 +167,7 @@ class Tab: # {{{
fenv = {}
if env:
fenv.update(env)
fenv['KITTY_WINDOW_ID'] = str(next_window_id())
if not is_macos and not is_wayland:
try:
fenv['WINDOWID'] = str(x11_window_id(self.os_window_id))