From 313fb877e741b692b4bfee1f1e8d32951c190563 Mon Sep 17 00:00:00 2001 From: Avtandil Kikabidze Date: Wed, 21 Oct 2026 09:39:16 +0400 Subject: [PATCH] client: export PTYXIS_TAB_UUID to the child environment External tools can already bring a tab to the front through the application's focus-tab-by-uuid action, but a process running in a tab has no way to learn which tab it is in. Export the tab's UUID to the child environment the same way PTYXIS_PROFILE is exported, so a tool can map a process to its tab. Also document PTYXIS_VERSION, PTYXIS_PROFILE and PTYXIS_TAB_UUID in a new ENVIRONMENT section of the man page. Fixes: #599 --- man/meson.build | 2 ++ man/ptyxis.1.in | 32 +++++++++++++++++++++++++++++++- src/ptyxis-application.c | 5 +++++ src/ptyxis-application.h | 1 + src/ptyxis-client.c | 3 +++ src/ptyxis-client.h | 1 + src/ptyxis-tab.c | 1 + 7 files changed, 44 insertions(+), 1 deletion(-) diff --git a/man/meson.build b/man/meson.build index ba194b1..447d9a4 100644 --- a/man/meson.build +++ b/man/meson.build @@ -1,5 +1,7 @@ man_config = configuration_data() man_config.set('app_id', app_id) +# The D-Bus object path GApplication derives from the application ID +man_config.set('app_path', '/' + app_id.replace('.', '/').replace('-', '_')) man_page = configure_file( input: 'ptyxis.1.in', output: 'ptyxis.1', diff --git a/man/ptyxis.1.in b/man/ptyxis.1.in index 58ac874..fd8a1fb 100644 --- a/man/ptyxis.1.in +++ b/man/ptyxis.1.in @@ -2,7 +2,7 @@ .\" First parameter, NAME, should be all caps .\" Second parameter, SECTION, should be 1-8, maybe w/ subsection .\" other parameters are allowed: see man(7), man(1) -.TH Ptyxis 1 "16 January 2026" +.TH Ptyxis 1 "21 October 2026" .\" Please adjust this date whenever revising the manpage. .\" .\" Some roff macros, for reference: @@ -322,6 +322,36 @@ Color14=#00ffff Color15=#ffffff .fi +.SH ENVIRONMENT +Ptyxis sets the following variables in the environment of the +command it runs in each tab. + +.TP +.B PTYXIS_VERSION +The version of Ptyxis that started the command. + +.TP +.B PTYXIS_PROFILE +The +.B UUID +of the profile used by the tab. + +.TP +.B PTYXIS_TAB_UUID +The +.B UUID +of the tab. It is the argument of the application's +.B \%focus\-tab\-by\-uuid +action, which selects the tab and presents its window, and which +can be activated over D-Bus with: + +.nf +gdbus call \-\-session \-\-dest @app_id@ \e + \-\-object\-path @app_path@ \e + \-\-method org.gtk.Actions.Activate \e + focus\-tab\-by\-uuid \(aq[<"\fIUUID\fR">]\(aq \(aq{}\(aq +.fi + .SH SEE ALSO For further information, visit the website https://gitlab.gnome.org/chergert/ptyxis/ diff --git a/src/ptyxis-application.c b/src/ptyxis-application.c index 4530f96..b89c8ea 100644 --- a/src/ptyxis-application.c +++ b/src/ptyxis-application.c @@ -1739,6 +1739,7 @@ typedef struct _Spawn { PtyxisIpcContainer *container; PtyxisProfile *profile; + char *tab_uuid; char *last_working_directory_uri; VtePty *pty; char **argv; @@ -1752,6 +1753,7 @@ spawn_free (gpointer data) g_clear_object (&spawn->container); g_clear_object (&spawn->profile); g_clear_object (&spawn->pty); + g_clear_pointer (&spawn->tab_uuid, g_free); g_clear_pointer (&spawn->last_working_directory_uri, g_free); g_clear_pointer (&spawn->argv, g_strfreev); g_free (spawn); @@ -1813,6 +1815,7 @@ ptyxis_application_check_shell_cb (GObject *object, ptyxis_client_spawn_async (self->client, spawn->container, spawn->profile, + spawn->tab_uuid, default_shell_path, spawn->last_working_directory_uri, spawn->pty, @@ -1867,6 +1870,7 @@ void ptyxis_application_spawn_async (PtyxisApplication *self, PtyxisIpcContainer *container, PtyxisProfile *profile, + const char *tab_uuid, const char *last_working_directory_uri, VtePty *pty, const char * const *argv, @@ -1891,6 +1895,7 @@ ptyxis_application_spawn_async (PtyxisApplication *self, g_set_object (&spawn->container, container); g_set_object (&spawn->profile, profile); g_set_object (&spawn->pty, pty); + g_set_str (&spawn->tab_uuid, tab_uuid); g_set_str (&spawn->last_working_directory_uri, last_working_directory_uri); spawn->argv = g_strdupv ((char **)argv); g_task_set_task_data (task, spawn, spawn_free); diff --git a/src/ptyxis-application.h b/src/ptyxis-application.h index 1af2b6d..eabf2cf 100644 --- a/src/ptyxis-application.h +++ b/src/ptyxis-application.h @@ -65,6 +65,7 @@ VtePty *ptyxis_application_create_pty (PtyxisApplica void ptyxis_application_spawn_async (PtyxisApplication *self, PtyxisIpcContainer *container, PtyxisProfile *profile, + const char *tab_uuid, const char *last_working_directory_uri, VtePty *pty, const char * const *argv, diff --git a/src/ptyxis-client.c b/src/ptyxis-client.c index 433842d..cdf4c41 100644 --- a/src/ptyxis-client.c +++ b/src/ptyxis-client.c @@ -599,6 +599,7 @@ void ptyxis_client_spawn_async (PtyxisClient *self, PtyxisIpcContainer *container, PtyxisProfile *profile, + const char *tab_uuid, const char *default_shell, const char *last_working_directory_uri, VtePty *pty, @@ -665,6 +666,8 @@ ptyxis_client_spawn_async (PtyxisClient *self, env = ptyxis_client_discover_proxy_environment (self, NULL, NULL); env = g_environ_setenv (env, "PTYXIS_PROFILE", ptyxis_profile_get_uuid (profile), TRUE); + if (tab_uuid != NULL) + env = g_environ_setenv (env, "PTYXIS_TAB_UUID", tab_uuid, TRUE); env = g_environ_setenv (env, "PTYXIS_VERSION", PACKAGE_VERSION, TRUE); env = g_environ_setenv (env, "COLORTERM", "truecolor", TRUE); env = g_environ_setenv (env, "TERM", "xterm-256color", TRUE); diff --git a/src/ptyxis-client.h b/src/ptyxis-client.h index 929abf4..c3b9740 100644 --- a/src/ptyxis-client.h +++ b/src/ptyxis-client.h @@ -55,6 +55,7 @@ char *ptyxis_client_discover_shell_finish (PtyxisClient void ptyxis_client_spawn_async (PtyxisClient *self, PtyxisIpcContainer *container, PtyxisProfile *profile, + const char *tab_uuid, const char *default_shell, const char *last_working_directory_uri, VtePty *pty, diff --git a/src/ptyxis-tab.c b/src/ptyxis-tab.c index 6f2f6e5..8b264e5 100644 --- a/src/ptyxis-tab.c +++ b/src/ptyxis-tab.c @@ -600,6 +600,7 @@ ptyxis_tab_respawn (PtyxisTab *self) ptyxis_application_spawn_async (PTYXIS_APPLICATION_DEFAULT, container, self->profile, + ptyxis_tab_get_uuid (self), cwd_uri, pty, (const char * const *)self->command, -- GitLab