Score:1

How to find window(gnome-terminal) by process id which run in it?

ca flag

gnome-terminal can open many windows, and in one window may have several tabs.

I want to active one gnome-terminal window which has a bash run in one of its tabs, for the CWD of that bash preventing my portable disk from ejecting properly.

I found the bash pid is 25938 by lsof.

In my example, I found there's 5 windows, 8 tabs. The issue is how to figure out 25938 in which window, by cmd of course.

$ echo $$
24674
$ ps --ppid $(pgrep gnome-terminal) 
  PID TTY          TIME CMD
 6080 pts/0    00:00:00 bash
 6742 pts/1    00:00:00 bash
20340 pts/5    00:00:00 bash
23354 pts/7    00:00:00 bash
24674 pts/8    00:00:00 bash
25938 pts/9    00:00:00 bash
30028 pts/12   00:00:00 bash
30492 pts/13   00:00:00 bash
$ wmctrl -lp | grep "$(pidof gnome-terminal-server)"
0x02800006  0 6070   bill me@bill: ~/m
0x0281016b  0 6070   bill me@bill: ~/c
0x02824e87  0 6070   bill me@bill: /c
0x02827a5d  0 6070   bill me@bill: ~/b
0x0282bc75  0 6070   bill me@bill: ~/a
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.