Get window_ID of gnome-terminal window by tab name (may not be active tab) - gnome

I'm running gnome-terminal in SLES-11. I work on several debug and support issues running in parallel (EDA related) and have as many 15 desktops with a gnome terminal window in each one (one gnome-terminal process with multiple windows across all desktops).
The gnome terminal window in each desktop has several named tabs, eg Ticket_number, VIEW, LIB, RUN debug, etc.
Here's what I'm trying to find:
Given a name string, find the window_ID of the gnome terminal window containing that a tab with that name. The named tab may not be the active tab (will not be in WM_NAME)
What I've tried so far:
searching environment of gnome-terminal process: no tab name info at all
Searching window xprops: only shows info for current active tab
I don't have root access and don't have any choice to change OS, gnome version or terminal app.
Are there any other ideas I could pursue?
Given a name string, find the X window ID of the gnome-terminal window(s) containing that named tab, even if the named tab is not the active tab.
Thanks and Best Regards,

You can use "xdotool search" to get the windowID. Insert between quotes the terminal title:
xdotool search --name "text_to_search"
To install "xdotool" type:
sudo apt-get install xdotool

Related

Linux terminal SCREEN command

I want to open a new terminal to execute a script file again. I need to open a new terminal and execute one more script.
I give a try with SCREEN command but it does work for only the first terminal.
You shouldn't open a new screen inside a screen. If you need another terminal inside the screen press "CTRL+a" and then "c".
This should open a new terminal. You can swap between terminals by "CTRL+a" followed by "a".
If you open more than two terminals inside the screen you can open an overview with "CTRL+a and then SHIFT+2"
If your done detatch the screen by pressing "CTRL+a then d". Reopen a screen with "screen -x (+ screen-id if you have multiple screens detatched)"

running x11 on cygwin, all terminals stuck at one corner

I am trying to run x11 on cygwin, mainly to run xfig utility, and I am facing a problem.
When I run xinit to start x11, I get a big popup window with one terminal open. But I am unable to open any other terminals in it. To be more specific, when I run "xterm &" in it, a new terminal opens up but it sits on top of the old terminal, and there is no way I can move this window, so the old terminal is as good as useless to me, till I kill the new terminal.
I also tried running "xwin". There a big window popped up, but it does not contain any terminal, and I cant open any terminal, whether by left or right clicking.
I also tried running "startx". A big window opens up but gets killed automatically after a few seconds.
How can I use x11 effectively on cygwin? As of now, I can use with "xinit", but with only one terminal.
The proper mode to start the Xserver on cygwin is to use starxwin.
From its manual:
The startxwin script is a front end to xinit(1) that provides a
some what nicer user interface for running a single session of the X Window
System in multiwindow mode. It is often run with no arguments.
To move windows around, you need to have a window manager running. You can start this either from the xterm, by passing the name of the window manager as an argument to startx, or by starting it from your X11 startup configuration (memory says that would be ".xinitrc" in your home directory on most unix boxes, but I am not sure if that's true on Windows using Cygwin). The .xinitrc file is "just" a shell-script, with the end of the script indicating "X should shut the server down now" (see example at the end).
There are many possible window managers, including fvwm2 (which according to your comment, you managed to find on your own). A full list of X11 window managers is probably too long to fit in this answer (there are many, there are new ones popping up, and old ones going out of maintenance on an ongoing basis). Some of the not entirely uncommon ones are fvwm2 (already mentioned), cinnamon, twm, ctwm, ratpoison, ... For a more up-to-date list, ask your favourite search engine for "list of X11 window managers".
Example .xinitrc file:
# This is an example .xinitrc file, starting first an xterm,
# then a window manager. As the X server terminates when this script
# does, we start the X terminal in the background, but the window
# manager in the foreground, so that "WM exists" signals "X server shuts down"
xterm &
fvwm2

Select(mark) & right click paste feature (like on cisco's IOS) on linux (bash)

Is it possible to make/enable/config bash on linux to be able to copy content from terminal by just selecting it and to paste by right click (like when you connect to switch/router with ssh)?
Yep it is in fact it's on by default in most terminals see below for example. Ctrl-Shift-C & Ctrl-Shift-V are also very helpful in this regard. I'm using konsole in KDE but gnome-terminal and nearly every other terminal has this ability.
Without X/Gnome/KDE: if you install gpm you can use your mouse for copy/mark and paste on console.

How to remember multiple tabs' session in terminal? (Alike FF session manager)

how does one "undo close-tab" in terminal? And quite related to it, is it possible to remember a session of tabs in terminal?
I mean (alike Firefox) if I close all tabs in a particular terminal window, how do I open with same the next day?
Its really useful to remember the terminal session for people like me who use multiple tabs a lot, and do not wish to start the next day with remembering what (and whereall) one was working, when one left the desk the day before.
In mouse right-click menu of gnome-terminal, one could easily (and I have) mistakenly click close tab instead of 'Copy'and lost track of what and where one was before selecting the text selected. In this case, undo closed-tab will serve a great purpose (available in Firefox already)
Thanks!
--V
For the gnome terminal, you can use
gnome-terminal --profile=〈your profile〉 --save-config=〈file〉
I launch it as a background task to save the terminal state periodically.
"termit" can save sessions and is scriptable in lua: https://github.com/nonstop/termit/wiki
I don't know about an "undo close tab" feature, though.
For reference, my termit lua config can be found here: https://github.com/thet/dotfiles-termit
On Linux, gnome-terminal is able to load multiple tabs with different working directories. Like termit (which is much more flexible due to it's lua scripting interface), it doesn't have a "undo close tab" feature.
Open Gnome terminal with multiple tabs, each one in another working directory: gnome-terminal --tab --working-directory=/home --tab --working-directory=~ --tab --working-directory=/opt.
Open Gnome terminal with multiple tabs and one base working directory: gnome-terminal --working-directory=/home --tab --tab --tab.
For more options do: gnome-terminal --help-all.
The gnome terminal doesn't have such features, but if you're open to change you could try konsole, it has some nice 'save session' options you could find helpful, though nothing about re-opening accidentally closed tabs, as far as I know.
The other thing, if you're particular about your desktop, is that KDE's konsole might not fit all too well within Gnome.

Switch GNOME Terminal Profile from the command line

If I'm running gnome-terminal with multiple tabs open, is it possible to switch the profile of a given tab at the bash prompt, with instant effect, and without altering the profile of the other tabs?
I understand how to use gconftool or gconftool-2 to change elements of a profile (such as the background), but I don't know how to actually switch the profile for a specific tab or window.
Any advice is appreciated.
It does not answer your question in particular, but since it might help others, I leave it here regardless.
If there was a way to change the current profile, you could have different profiles for each tab.
You can list all existing profiles using:
gconftool-2 --all-dirs /apps/gnome-terminal/profiles
You can get the current profile using:
gconftool-2 --get /apps/gnome-terminal/global/default_profile
And you can set a new default profile (solarized-light in this case) using:
gconftool-2 --set --type string /apps/gnome-terminal/global/default_profile solarized-light
I think you can do this through gconf-editor which maintains the settings for everything in gnome. See the gconf-editor manual and section on gnome-terminal.
From the terminal, you can make changes with gconftool-2
I'm working on something similar, I think it could help you
to use gnome-terminal --help
which will show you some commands you can use to open terminal with certain profiles
you will need to figure out how to write the line at prompt to open with the tabs and profiles you want ....once you have the hard part figured out you can add the line to your
bashrc
Run nano ~/.bashrc to open up the bash configuration file, which gets run every time you open a terminal. Then add the line to the bottom save and close.
Even though the question is about GNOME Terminal and the command line, it's worth knowing that MATE Terminal (a GNOME Terminal fork) allows profile switching via a simple keyboard shortcut.

Resources