Anubhabchak
Anubhabchak

Reputation: 73

Hiding a window when opening it from bash script

I am trying to make a bash script to run another bash script in a new terminal window.

I used the command:

sudo gnome-terminal -e "bash file_name.sh"

This works as I want it to. But I want to hide the second terminal window that opens. I have tried running in background using & but it does not work like I want it to. I want the terminal window to be hidden.

Is there any way I could set the terminal window to not show up?

Upvotes: 4

Views: 12829

Answers (3)

twp
twp

Reputation: 1

A way I resolved minimising any application with a distinguishable window header was using xdotool

xdotool search --name "Name of the Window To Hide" | xargs -I{} xdotool windowminimize {}

Upvotes: 0

harryIT
harryIT

Reputation: 45

Well for what i have understood about Linux and the "&" optional command, it's already that what you call hidden. You may miss "disown" command so you can run the code in background while being able to close the shell.

start it in the background:

command &

then run:

disown

and close the terminal.

You can stop a foregrounded application with Ctrl+z, then start it in the background (foreground) with the bg (fg) command.

You can read the source here on a Ubuntu Forum: "How to hide terminal window?"

Upvotes: 2

Thomas Raffelsieper
Thomas Raffelsieper

Reputation: 574

You could use nohup to run the process in background:

$ sudo nohup ./file_name.sh &

There will be a new process to execute file_name.sh, output will be written to nohup.out.

Upvotes: 1

Related Questions