Mistakenly started a screensaver on my Chromoting session. Needless to say, a real pain when you have to unlock your local workstation AND the remote end after a minute of inactivity.
Of course, now you have duplicate screensavers running, and it’s not apparent in the process listing which one belongs to which X server. I certainly don’t want to kill the real screensaver on :0, leaving my local console unlocked!
$ ps ax|grep screensave
6166 ? S 16:30 xautolock -time 1 -locker xscreensaver-command -lock -detectsleep -corners -+00 -cornerdelay 1
17200 ? S 9:25 xscreensaver -nosplash
25747 ? S 7:13 xautolock -time 1 -locker xscreensaver-command -lock -detectsleep -corners -+00 -cornerdelay 1
56143 pts/17 SN+ 0:00 grep –color=auto screensave
140723 ? S 0:07 xscreensaver -nosplash
Seeing as the DISPLAY var is a part of the environment where the X application was invoked, it should be in:
/proc/
cat /proc/
The awk command was borrowed from elsewhere on the Internet. It basically says, break things apart using ‘=’ as a field separator (FS) and \0 as a return separator (RS). I tried investigating this further, seeing as ‘\0’ is the null return used in some GNU utils including xargs, went down the following path:
This seemed like the most straightforward way to break it out:
/bin/echo -e $(cat /proc/137572/environ)
However the output was still not broken into lines. Oh well.
Note the use of /bin/echo as echo is usually a shell built-in.
Anyway, let’s use awk like I mentioned before, by substituting the PIDs I found above.
Now I can quickly tell which processe below to which DISPLAY.