Monday, September 2, 2013

Send a message to another computer via ssh

I don't know if everyone else has the same problem as me, but I have two computers in different rooms, and sometimes my wife and I are on each computer. Sometimes I want to tell my wife something or send her a message, but I'm just too lazy to get up and go into the other room to talk to her. One thing I do have is ssh access to all of my computers. After searching a little (there's references to this just about everywhere), I found how to send a message to my wife via ssh.
ssh
export DISPLAY=:0
notify-send "Message"
Now I had a computer before that for some reason or another, the default monitor/display wasn't 0 and it took some searching to find out which was the right one. Although the easiest way would probably be to increment the display number until you find the right one.
notify-send will send a notification to the screen which will time out and can easily be missed if the person on the other computer is not watching. You can also put a message in a text file, then open it up with something like gvim textfile.txt which will open a new window with the text file (gvim can also be replaced with the more common gedit)
Once you export the display in fact, you can open up any graphical program, and it will open up on that computer.
If you open up a program and then want to close after, you can run
killall <program_name>
to close it.

No comments:

Post a Comment