Send a command from the console to a running X server

6,250

I'm exactly sure about what you are looking for. But to launch a new application inside a running X server you can use for example:

DISPLAY=":0" mplayer -fs video.ogg

You can choose the id of the X server, and you may add an optional screen identifier like :0.1 to launch the application in screen number 1.

Share:
6,250

Related videos on Youtube

Emanuel Berg
Author by

Emanuel Berg

Emanuel Berg Hire me! Programmer, Swedish university degree in Computer Science. computer projects (includes CV, letters, code, screenshots) internet activity (where to find me) Check out some of my Unix & Linux tech writing.

Updated on September 18, 2022

Comments

  • Emanuel Berg
    Emanuel Berg almost 2 years

    Is it possible to send a command from the console, say tty1, to the terminal currently occupied with X (in my case tty7 as I use Debian), to tell for example mplayer to play a movie?

    Edit - made a shorthand function with the commands I learned in the answer below:

    function movie () {
      ORIG_TTY=`fgconsole`
      chvt 7
      DISPLAY=":0" mplayer -fs $1 > /dev/null 2> /dev/null
      chvt $ORIG_TTY
    }
    
  • Emanuel Berg
    Emanuel Berg almost 12 years
    Yes, that's the thing I looked for. Do you also happen to know how to incorporate the focus shift into that command (i.e., to emulate the Alt-F7 keypress to get the X display)? But your answer is correct.
  • Stéphane Gimenez
    Stéphane Gimenez almost 12 years
    Try with chvt. (It was hard to remember the name of this command, I don't use it everyday…)
  • Emanuel Berg
    Emanuel Berg almost 12 years
    Yes, chvt 7 does it.