Does anyone know how to get the PID of the top active window and then how to get the properties of the window using the PID? I mean properties like process name, program nam
I am voting up Michel Kogan’s answer, and adding this concise summary of it:
ps -o pid,comm,args $(xprop -id $(xprop -root -f _NET_ACTIVE_WINDOW 0x " \$0\\n" _NET_ACTIVE_WINDOW | awk "{print \$2}") -f _NET_WM_PID 0c " \$0\\n" _NET_WM_PID | awk "{print \$2}")
The above will show the following for the currently active window: PID, command name (only the executable name), command with all its arguments.