Running an XWindow program from a terminal

Suppose you want to to start an XWindow program from a terminal with its input, output, and error output redirected to null (/dev/null). Moreover you want the started program not to be hit with SIGHUP signal and exited when you close the terminal window from which you’ve started it:

x glxgears

It can be done with the following script:

#!/bin/bash

cmd="$1"
if ! { which "$cmd" > /dev/null; }; then
    echo "x: $cmd not found."
else
    "$@" >/dev/null 2>&1 &
    disown
fi

Well, somebody make Debian and .rpm packages with this short script.

Advertisements
This entry was posted in Linux/Unix and tagged . Bookmark the permalink.

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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s