Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How would one can send a message to the logged in user's desktop through ssh? I sometimes connect my friend's computer to help him out, but i need to the a message to his desktop rather than using talk or ytalk.

There are options like notify-send, gmessage, xmessage. But since I'm connected with SSH I cannot connect to their desktop.

Setting environment variable DISPLAY does not work as well.

How do I that?

share|improve this question
up vote 3 down vote accepted

Just setting $DISPLAY is not enough for xmessage since you don't have the needed authentication data for connecting to another user's X11 server – you would need to copy $XAUTHORITY as well. For notify-send, only $DBUS_SESSION_BUS_ADDRESS is required, but you will likely be denied access by the DBus policy.

Use this script to copy environment variables easily, and use sudo to run the command under your friend's account. For example:

pid=$(pgrep -x -u jon gnome-session)
sudo -u jon ./envcp $pid notify-send 'Hi'

(Instead of gnome-session any other process of that user can be used.)

share|improve this answer
seems a bit long way to use, i'll try to make a bash script for that – Umur Kontacı Aug 31 '11 at 12:41

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .