Hide gui dialog pop-ups from bash script

3

I am running a bash script which executes a command that pops-up an annoying GUI dialog (I execute it multiple times inside the script). This pop-up disrupts whatever I am doing in the UI while running the script in the background.

UI

Is there any way to hide these?

Daniyal Shahrokhian

Posted 2017-03-23T14:23:47.513

Reputation: 61

1Some more details, like which command is executed etc., would help. – dirkt – 2017-03-23T21:53:35.493

It's a c++ binary from this open source project. My bad, I just found a quiet option in the Wiki section for the command line argument.

– Daniyal Shahrokhian – 2017-03-24T11:46:22.453

Answers

2

GUI applications executed from a script try to connect to the X server specified by the DISPLAY variable. If you clear that variable, programs will not be able to open a window, so that should effectively prevent any popups. For example, if you try to run this:

DISPLAY= xterm

You'll get an error like this:

xterm: Xt error: Can't open display:
xterm: DISPLAY is not set

Either you can write DISPLAY= right in front of the command you want to run like I showed with xterm above, or you can write DISPLAY= on its own line somewhere earlier in the script.

However, some programs might not start at all if DISPLAY is not set. If that's the case for the program generating the popup, and if this program does something useful other than the popup, then you won't be able to use this technique. It's worth a shot anyway.

janos

Posted 2017-03-23T14:23:47.513

Reputation: 2 449

Indeed, the program refuses to start in this case. – Daniyal Shahrokhian – 2017-03-24T11:52:58.400