Ubuntu – WINDOWID environment variable missing in gnome-terminal in Ubuntu 18.04

18.04gnome-terminal

In Ubuntu 17.10 (under an Xorg session) I could get the window ID from the WINDOWID environment variable from
gnome-terminal by typing:

$ echo $WINDOWID

in the terminal window. In Ubuntu 18.04, this does not work. However, it seems to work fine with other terminal emulators I have tried, like xterm and konsole.
So the issue seems to be specific to gnome-terminal.

How can I get the window id of the current gnome-terminal window?

Best Answer

I found a workaround. You can use

$ xdotool getactivewindow

This will give the window ID of the GNOME terminal window it is run from.