Map "Super+ArrowDown" to minimize a window while the window is focused & the window is not in fullscreen

You can add the following Bash script to the Super+Down shortcut.

#!/bin/bash
active_window_id=$(printf 0x%x "$(xdotool getactivewindow)")
window_state=$(xprop -id "$active_window_id" | grep "_NET_WM_STATE(ATOM)")

if [[ "$window_state" == *"MAXIMIZED"* ]]; then
    wmctrl -ir "$active_window_id" -b remove,maximized_vert,maximized_horz
else
    xdotool windowminimize "$active_window_id"
fi

The script uses xdotool, wmctrl and xprop. Make sure they are installed in your computer by running:

sudo apt install xdotool wmctrl x11-utils

To save the script and make it executable:

  1. Open the text editor of your choice and copy/paste the content of the script.

  2. Save the script somewhere on your computer with a name of your choice, for example as /home/user/path/to/script.sh.

  3. Give execution rights to the script you saved by running:

    chmod u+x /home/user/path/to/script.sh
    

To add the script to a shortcut (in GNOME):

  1. Open SettingsDevicesKeyboard.

  2. Find the Restore window shortcut, click on it and set it to another shortcut, for example Super+B, and press Set. This has to be done or else you won't be able to use the Super+Down for the script.
    Note: If you wish Super+Down to have the default behavior and set the script to another shortcut, skip this step and add the shortcut of your choice following the next steps.

  3. At the bottom of the keyboard shortcuts window click on the "+" icon to add a new shortcut.

  4. Give the shortcut a name of your choice, for example "Minimize alternative", add the full path to the script (/home/user/path/to/script.sh) in the Command field, click Set Shortcut... to add Super+Down as the shortcut and close the shortcut window (see screenshot below).

    Shortcut setting

Super+Down should now have the behavior you want!


To change only that, you probably would need to write your own extension. However, there is an extension that behaves like you want, besides doing some other things. It is the Gnome Shell extension WinTile: Windows 10 window tiling for GNOME by Fmstrat.

It does exacty what you want, where Super+Down will take the window out of maximized mode, and a subsequent press will minimize it.

It does extra things, but them, you might like these. You can tile left and right as in standard Ubuntu with the Super+Left/Right keys. In addition, using Super+Up/Down on a half tiled window will quarter tile it.