Short: there is not the solution(TM) for what you want.
However, with sufficient knowledge about your setup it may be possible to develop a solution that works for you. I had the same problem once.
The reason why it's so difficult is that the Xserver is precicely not tied to a user. You can confirm that on any major Linux distribution by loging in to the desktop-environment of your choice, opening a terminal and typing in ps faux
. It will show your display manager, with (at least) two child processes: a xserver and the parent process for all processes belonging to your user session. Note that the xserver is started as user root and NOT as the user your session belongs to.
What I did/do to match a certain xserver with a username I do a majority vote: I look at each user process and check to which xserver it is connected. From that knowledge I create a list which tells me for each user the ammount of processes that are connected to a specific xserver. An illustration of this table could look like this:
|xserver :1| xserver :2 | xserver :3 | xserver :4
-------------------------------------------------------------
alice | 17 | 0 | 0 | 0
bob | 0 | 0 | 14 | 0
eve | 0 | 34 | 1 | 0
foo | 1 | 1 | 1 | 8
With this table I perform a simple majority vote which yields the mapping:
- User alice is using, i.e. sitting in front, of xserver :1
- User bob is using xserver :3
- User eve is using xserver :2
- User foo is using xserver :4
This majority vote does not necessarily yield correct mappings however, for all my intents and purposes it's sufficient.
That's all you need. Now you can
DISPLAY=<ip.to.xserver>:1 xmessage -buttons yes,no,maybe -nearmouse "Do you want to go on a date with me?"
ask alice for a date.
The magic is the DISPLAY environmental variable which xapplications use to find out which xserver they should connect to. Most xapplications also accept the option -display
. See the man page on xmessage
and X
.
Of course there are (so) many other ways to replace my majority vote with. Which is the best suited for you, you need to find out yourself ...
wall
for the popup? – lynxlynxlynx Jul 16 '12 at 21:48