Chris Snow Chris Snow - 9 months ago 18
Linux Question

execute a gui application from the command line and send it to the background

Is there a command line utility that I can use for executing X based applications that will detach my applications from the terminal so they aren't closed if the terminal is closed?

I guess such a app could be called something like

gnome-run
if it existed.

I have tried
dtach
, but it seems that you have to provide a socket file which is a bit clunky to type. I have also tried
nohup
, but found that also to be a bit clunky to type by the time std out and err are redirected to
/dev/null
.

I guess I'm looking for a simple program that will do something similar to this:

#!/bin/bash

nohup $1 > /dev/null 2>&1 &

Answer Source

Yes, there is a way to do it: first you need to run your GUI app and send it to background, then you (probably) want to detach it from Bash task management. For example if I wanted to run gedit this way:

gedit &
disown %1

After that you can close your terminal window and gedit will not be killed. Enjoy!