In Lubuntu 18.04, I have many background GUI jobs running in a bash shell. Among them, I have a evince process running in background:

$ jobs | grep evince
[29]   Running                 evince CurrentDBs.pdf & 

I would like to bring its window to the front of my desktop (in front of my current lxterminal window which runs the bash shell), but fg 29 doesn't do so.

Why is that? Is it because job control of a shell has nothing to do with which window is in the front or not in the desktop environment (or X window system)?

How can I bring a background GUI job to the front of my desktop? Can xdotool be used to raise the window of a given process id to the front, even if the process runs a Windows program under Wine?



Yes, xdotool will work

Here is how you can raise all evince windows to the front:

xdotool search --onlyvisible --class evince windowactivate %@

I see no reason that it would not also works with Wine programs. Of course, you'll need to find the right name to call them. The command xprop may help.


The evince is running in the backgroud in a subshell (pay your attention to trailing ampersand in the process executed). But since it's GUI app its window should be visible to you, since window close button pressing should terminate whole subshell process. If you don't see evince window while subshell backgroud process exists, it means a bug probably. There are two possibilities:

  1. Try to find the hidden window somewhere (second desktop or press Alt+Tab or Alt+Shift+Tab to switch windows).
  2. Kill the process manually with kill or just close shell which invoked subshell with evince to send SIGHUP to the subshell.
  • Closing the shell you started a program from and backgrounded with & will not close the program. I start programs from terminals with program & exit all the time without the program closing automagically with the shell.
    – Mio Rin
    Jul 28 '18 at 0:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.