Determining the user that created a window

Is there any way to determine the user that owns a window? eg: If I open an xterm and su into root and start a new xterm is there any way for FVWM,xprop, etc. to distinguish what user created them?

I want to have all windows spawned with root permissions to have a diffrent decor.


Then you will have to entitle them. You can either do it such that for root’s .bashrc that you set PROMPT such that it changes the title for which you can do:

Style some_known_window_name Colorset 2

Or you set it beforehand:

Exec exec xterm -T some_known_window_name ....

This should not have been posted to Complex Functions – I’m moving it elsewhere.

– Thomas Adam

Ok, I found a round-about way to do it:

window ID -> xprop -> PID -> grep/awk -> user

#!/bin/bash ps -Af | awk '{print $1 " " $2}' | grep `xprop -id $1 | grep '_NET_WM_PID(CARDINAL)' | awk '{print $3}'` | awk '{print $1}'

How it is called with FVWM:

ThisWindow Exec exec $SCRIPT_PATH/ $[]

I plan to use this with FvwmEvent so whenever a window is created it detects if root owns it and gives it a diffrent decor (in my case a red border & title bar)

This does not detect elevated permissions after the window is created. Most common example being open an xterm then su into root. There are ways to detect this, but it varies from window to window. Later I might post a script to detect if the shell inside a terminal has root permissions.

PS: Sorry about the wrong forum

That will tell you who effectively owns the terminal window, but it won’t tell you which user is running inside it. Or is this not a consideration? Because if it is, then the only way you could do it is to set PROMPT.

(hint: Look at actually using awk(1) to do your pattern matching as well, since the overuse of grep is horrible. :P)

– Thomas Adam