-1

How do I run a program in the background from a shell, with the ability to close the shell while leaving the program running which should not disturb the window i am working on? Lets say my UI is having problems or for some reason, I need to boot up a program from the terminal window.

The program should not disturb my window in which i am working on but it should be opened from the command line and i should be able to get access to it using the normal shortcut ALT+TAB.

Even the command line should exit during this process.

I tried this ....

"gedit file-name & exit"

this is working fine but the gedit file is opening in the foreground i.e it is focused.

(let i be working on some application like mozilla. After running the command ..... gedit file is bieng focused rather than mozilla which should not happen)

It is fine if the answer also comes in a script.

Jasser
  • 206
  • 2
  • 14
  • 2
    This is not a duplicate as this is about opening windows in the background from the terminal, not running background jobs. – muru Aug 25 '14 at 15:37
  • Hey the focus is bieng changed to gedit from mozilla but this should not happen and the answer is not there in the link http://askubuntu.com/questions/106351/running-programs-in-the-background-from-terminal(Running programs in the background from terminal). – Jasser Aug 25 '14 at 15:49

1 Answers1

0

It sounds like what you want is something to prevent window focus. Window focus settings and commands might depend on whether your using Unity, Gnome, etc. I have only ever done something like this with an xfce based Linux.

I don't have an Ubuntu box on hand to try this out, but this might get you on the right path: https://superuser.com/questions/142945/bash-command-to-focus-a-specific-window

  • Please add in essential parts of the linked post to the answer. Link-only answer can become useless if the link goes dead. – muru Aug 25 '14 at 15:36
  • Yes the question is about fixing the focus to the "present running application which i am working on" or "presently focused window" but your link doesn't do that. After executing the command gedit file-name & wmctrl -a firefox the focus changes to mozilla from the terminal but after that gedit opens and it is bieng focussed not mozilla. – Jasser Aug 25 '14 at 16:00
  • Or is there a command to delay a command to certain time. So that i will first execute (gedit file-name &) and then delay this for two seconds till the gedit application opens and then execute the wmctrl -a firefox so that it focuses on my present working application i.e., firefox(but how to know about what window is presently focused). I know this takes some time but I might have to do a long process other than opening a file with gedit so this might work. Can we do this?? – Jasser Aug 25 '14 at 16:02
  • You can also provide the answer in a script – Jasser Aug 25 '14 at 16:09