running gui apps on the background (invisible)

9 01 2008

here i will show how to execute an app that requires GUI (X window) to run on the background. i mean you wont be able to see the screen.

you may wonder why someone would want this since without the GUI you cant interact with the app. the test suite for the application that i am working on requires running some javascript test on firefox. i managed to write a script that automatically starts firefox run the tests and than kills the firefox process. but the problem is that while i run the tests i would like to keep working on another stuff but the windows keep popping up and bugging me.

this problem is simple to solve. i used a vncserver. a vnc (virtual networking computing) server will create a virtual X server. so you actually doesnt need to have a real display. usually, vncserver is used to display an application on a different machine. a remote machine would connect to the vncserver using a vncviewer…

you will need to install a vncserver. on ubuntu i am using the package vnc4server.

after installing, the first step is to create a password using ‘vncpasswd’. this password will be used to authenticate any vncviewer trying to connect to this server. we wont setup any viewer but vncserver requires this password anyway. so just type:

$ vncpasswd

now start the server

$ vncserver

if you dont specify a display number it will get one for you. it will probably be ‘:1’

our vncserver is up and running. to use it you need to change the env variable DISPLAY to ‘:1’ (or whatever display number you got).

now any process started on this shell will use this display. since it is a virtual display you wont see anything. just what we were looking for.

some applications also have a ‘display’ parameter, so you dont need to set the env variable.

$ firefox –display=:1

thats all.


Actions

Information

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s




%d bloggers like this: