Last Updated: February 25, 2016
·
550
· tiger-222

How to detect Window Manager

detect() {
    # Mate = Marco
    # Gnome2 = Metacity
    # Gnome3 = Mutter
    # Xfce4 = Xfwm4
    # KDE4  = KWin
    WM_WINDOW=$(xprop -root _NET_SUPPORTING_WM_CHECK);
    WM_WINDOW=${WM_WINDOW##* };
    WM_NAME=$(xprop -id $WM_WINDOW 8s _NET_WM_NAME)
    WM_NAME=${WM_NAME##* };
    echo $WM_NAME | sed 's/"//g'
}

This code will return the codename of the WM.

More informations => https://bobotig.fr/index.php?c=documents/fond-ecran-cli/