Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'd like to add into my .bashrc a little script that sets the terminal background to transparent iff I don't have any non-minimised, non-terminal windows open and leaves the terminal background as image if there is something open.

I'm using 12.04 with Unity.

I've no problem setting the terminal background, but I've only got a kludge to tell if a program is open, and can't tell if the window is minimised.

My kludge at the moment:

if [ -z "$( ps -e | grep firefox )" ]
        gconftool-2 --type string --set /apps/gnome-terminal/profiles/Default/background_type transparent
        gconftool-2 --type string --set /apps/gnome-terminal/profiles/Default/background_type image

(add inset for each of my most used programs)

I'd be happy with being able to tell at launch of terminal, but if I could turn the terminal transparent upon minimising (or closing) the last open window, that would be amazing. I'd guess something like:

export largewindows=  #number of open, non-minimised windows

if [ $largewindows -eq 0 ]
        gconftool-2 --type string --set /apps/gnome-terminal/profiles/Default/background_type transparent

with (somehow) a little script that runs this upon opening, closing, minimising or un-minimising a program window.

What I don't know:

  • How to count the number of windows (or even running programs) automatically.

  • How to run a script every time I open/close/minimise/un-minimise a window.

Any advice in the right direction would be appreciated - Thanks a lot!

share|improve this question

For finding windows you can use xdotool search like

WID=`xdotool search "Mozilla Firefox" | head -1`

xdotool behave looked like something you can use for second part, but unfortunately no maximize and minimize events there - also it works only with existing windows - but you can check for opened windows from time to time with cron.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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