#!/bin/sh -e
minwins='/tmp/minimized_windows'
case "$1" in
m*|h*|i*) #minimize/iconify/hide the active window
active_id=$(xdotool getactivewindow)
title=$(xdotool getwindowname "$active_id")
class=$(xdotool getwindowclassname "$active_id")
printf '%s\n' "$active_id $class: $title" >> "$minwins"
xdotool windowunmap "$active_id"
;;
r*) #restore a minimized window
n=$(wc -l < "$minwins")
case "$n" in
0) exit;;
1) map=$(cat "$minwins");;
*) map=$(cat "$minwins" | dmenu -l "$n");;
esac
map_id=${map%% *}
tmp="$(mktemp)"
grep -v -- "^$map_id " "$minwins" > "$tmp" || true
mv "$tmp" "$minwins"
xdotool windowmap "$map_id"
;;
esac
Idea stolen from Reddit: Tiling window manager with native window minimize function.