There are two important tools to manipulate windows from
wmctrl. Both tools overlap each other in functionality, but the most important commands referring to your question:
In an (no doubt incomplete) overview, listing the commands I use most:
Closing a window
wmctrl -ic <window_id>
Minimizing a window
xdotool windowminimize <window_id>
Un- minimizing a window
effectively un- minimizing is done by:
wmctrl -ia <window_id>
I mention effectively, since the command moves to the corresponding desktop, unminimizes and raises the window, but the command also does that on windows which are not minimized.
Maximizing a window
xdotool windowsize <window_id> 100% 100%
wmctrl -ir <window_id> -b add,maximized_vert,maximized_horz
Un- maximizing a window:
wmctrl -ir <window_id> -b remove,maximized_vert,maximized_horz
wmctrl are not on your system by default:
sudo apt-get install xdotool wmctrl
To run any of the commands on the currently active window:
wmctrl commands, remove the
-i option, replace
xdotool commands: replace
In many cases, commands can be run by using either the window id or the window name. The
-i option in
wmctrl to use the window id. I'd suggest not using the window's name as an identifier, to prevent name clashes. It happens more easily then you'd expect.
- From my own experience, using maximizing in a script;
wmctrl to maximize / unmaximize can be a bit buggy on both
Gnome, while the
xdotool option works more robust in my experience.
In most scripts, I end up in using a mix of both
More info on man wmctrl and man xdotool (mainly the section: WINDOW COMMANDS).