Cagnulein <cagnulein <at> cagnulein.com> writes: > > Scenario: > - 1 monitor > - 2 XOrg session (one for user 'a' and another one for user 'b') > > With CTRL-ALT-F7 and CTRL-ALT-F8 I can switch between these 2 virtual > sessions. > But how can I know which session is on the screen? (and so which one is > on background?) > > I need this information inside a little daemon running as user 'c' > outside XOrg sessions > > Thanks > Roberto Viola > _______________________________________________ > xorg <at> lists.freedesktop.org: X.Org support > Archives: http://lists.freedesktop.org/archives/xorg > Info: http://lists.freedesktop.org/mailman/listinfo/xorg > Your subscription address: gcfx-xorg-2 <at> m.gmane.org > >
I've had My self in similar situation and wasn't able to find any solution on net, so I've tried to think of "What exactly I want to know?" and came up with answer: By which of X DISPLAY's physically attached keyboard/mouse is used and just tried lsof of /dev/input/event* and to my surprise I've hit the spot. So you can use this string: ps --no-heading -p `lsof -c /^X$/ 2>&1 | grep event | awk '{ print $2 }' | uniq` -o command|awk -F: '{ print $2 }'|awk '{ print $1 }' It is by no means the most elegant solution but it work. I've made a little demon out of it which update /tmp/CurrentX.DISPLAY, /tmp/CurrentX.pid and /tmp/CurrentX.tty files accordingly. _______________________________________________ xorg@lists.freedesktop.org: X.Org support Archives: http://lists.freedesktop.org/archives/xorg Info: http://lists.freedesktop.org/mailman/listinfo/xorg Your subscription address: arch...@mail-archive.com