#!/bin/bash
desktop() {
for n in $(wmctrl -l | awk -v d="$1" '$2 == d {print $1}')
do
    wmctrl -i -c $n;
done
}
all() {
for n in $(wmctrl -l | awk $2 '!/-1/ {print $1}')
do
    wmctrl -i -c $n;
done
    
}

case "$1" in
    all) all;;
    *) desktop "$1";;
esac