Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I would like to be able to choose any already-open window and minimize it from the command line. Is this possible?

share|improve this question

4 Answers 4

up vote 9 down vote accepted

In Kubuntu 12.04 I use the following command to minimize the active window:

xdotool windowminimize $(xdotool getactivewindow)

I suspect you may replace the $(xdotool getactivewindow) with a string identifying any window that you need to minimize.

share|improve this answer

You can kind of do this with WMCtrl. It's a tool that allows you to control the window manager from the command line. You can find it in the repositories.

It's compatible with Metacity and KWin (The defaults for Gnome and Kde).

You can use this command to get a list of currently open windows. This will include the window name:

wmctrl -l

Once you have the window name, you can use this command to shade a window:

wmctrl -r "windowname" -b toggle,shaded

I don't think minimization is supported because it's not covered by the EWMH spec, but you can do shading and maximization so it might suit your needs.

share|improve this answer
    
Problem with that: the window is completely hidden and unusable. You can unhide it with the same command though. –  Marc M Aug 15 '13 at 20:42
1  
wmctrl author added a new -Y flag to iconify windows. Commited in github but not released yet. –  Marc M Aug 15 '13 at 20:43

You could use xdotool to simulate the keyboard event Alt-F3 after focusing on the window. It's a hack, but depending on your problem, it might be enough.

share|improve this answer

You use xdotool. Note that the default unity shortcut key for minimizing the active window is Ctrl-Alt-0 BUT that this ONLY means the numeric keypad zero. If you type the regular zero key, the one between the 9 and the -, then it will not work. (Also not when typing it on the keyboard.

Xdotool knows the numeric keypad zero key as 'KP_Insert'.

So to minimize the active window, you first make sure xdotool installed, then use the command:

xdotool key Ctrl+Alt+KP_Insert

(Note that the key Alt-F3 mentioned in another answer will not work

share|improve this answer

Your Answer

 
discard

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.