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

7 Answers 7


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.

  • 1
    $ xdotool getactivewindow windowminimize (works in Ubuntu 15.04) Jul 12, 2016 at 22:56
  • 1
    I added a more complex example that demonstrates command chaining of xdotool. Apr 14, 2017 at 2:40
  • wmctrl -r "windowname" -b toggle,hidden Can work with wmctrl! askubuntu.com/questions/4876/… The answer below! Oct 14, 2022 at 6:12
  • Whether wmctrl -r "windowname" -b toggle,hidden works or not depends on your window manager. I'm using Marco and that seems to do nothing. Nov 2, 2022 at 9:28
  • xdotool getactivewindow gives XGetWindowProperty[_NET_ACTIVE_WINDOW] failed (code=1) xdo_get_active_window reported an error. What are the alternatives? (Ubuntu 22.04.2 LTS default install)
    – Tino
    Jul 13, 2023 at 5:31

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.


In 2022, there are option for this :

wmctrl -r "windowname" -b toggle,hidden

See @dgo.a answer Can I minimize a window from the command line?

  • Problem with that: the window is completely hidden and unusable. You can unhide it with the same command though.
    – Marc M
    Aug 15, 2013 at 20:42
  • 2
    wmctrl author added a new -Y flag to iconify windows. Commited in github but not released yet.
    – Marc M
    Aug 15, 2013 at 20:43
  • 1
    I'm using wmctrl 1.07 (its now July 2016) and still no -Y flag. Jul 12, 2016 at 22:28
  • 2
    Have you tried: wmctrl -r "windowname" -b toggle,hidden ?
    – dgo.a
    Jan 19, 2017 at 21:30
  • @dgo.a Thanks for sharing! Oct 14, 2022 at 6:11

to minimize the active window

xdotool getactivewindow windowminimize

works on gnome3.24 shell extension such as custom hot corner, "xdotool windowminimize $(xdotool getactivewindow)" won't.

  • Thanks, works like a charm.To install the package: sudo apt install xdotool > I'm on zorin os May 10, 2021 at 10:42

Another xdotool example:

xdotool search --onlyvisible --classname --sync Navigator windowminimize

This searches (and waits, due to --sync) for a visible Navigator window, and then minimizes it.

See xdotool(1) section COMMAND CHAINING:

xdotool supports running multiple commands on a single invocation. Generally, you'll start with a search command (see "WINDOW STACK") and then perform a set of actions on those results.


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.


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


You can minimise an application window regardless of its current state using wmctrl as follows:

wmctrl -r "application-name" -b add,hidden

To maximise:

wmctrl -r "application-name" -b remove,hidden

"application-name" can be any substring in the application name, and is case insensitive (use the -F option if this is not what you want). "hidden" is wmctrl's word for minimise.

For example:

wmctrl -r firefox -b add,hidden

minimises the first window that contains the string "firefox", in any mixture of upper and lowercase letters.

To see the list of windows, type:

wmctrl -l

dgo.a's comment above is great if you just want to toggle between maximised and minimised states.

This site is temporarily in read-only mode and not accepting new answers.

Not the answer you're looking for? Browse other questions tagged .