7

Possible Duplicate:
Open a window on a remote X display (why “Cannot open display”)?

I have a computer running debian, connected to my TV, running an xorg session. What I want to do is ssh into that machine and start an application that will also display on that machine. For example, I want to be able to ssh to it from my laptop and start mplayer on the host, playing a file on the host and showing it on the TV. Is this possible? I have a feeling it should be (relatively) trivial, but I just can't seem to figure it out.

Just to clarify, simply running

$ ssh -X host
$ mplayer movie.avi &

won't cut it, because it will start displaying on my laptop's display.

vlsd
  • 245

2 Answers2

6

If you know what $DISPLAY your ssh host's X server is using, e.g. :0.0, the following works for me:

ssh host
export DISPLAY=:0.0

Now you can run any graphical app of your choice on your host. You won't be able to see or control the graphical aspects on/from your laptop, of course.

jw013
  • 51,212
  • 1
    To find the corresponding DISPLAY, ssh to the host and invoke the command w which will show the users logged in and what they are doing. – erik Mar 22 '15 at 12:16
  • @erik: How would the output of w tell you what's the right DISPLAY? – einpoklum Jan 29 '16 at 18:23
  • @einpoklum: If I run the w command, I get the following output: 21:31:00 up 23:13, 1 user, load average: 0,50, 0,51, 0,50 USER TTY LOGIN@ IDLE JCPU PCPU WHAT erik :0 Fr22 ?xdm? 12:39 0.65s gdm-session-worker [pam/gdm-password], where TTY displays my current display (:0) and the USER the current user who started that X-server (erik). – erik Jan 30 '16 at 21:33
2

Another tip to place the program in background and detached from the ssh session:

ssh host '(DISPLAY=:0.0 mplayer movie.avi >/dev/null </dev/null 2>&1  &)'
erik
  • 17,269
w coder
  • 21