#!/bin/bash
#  Script to change the windowmanger used when starting the frontend.
#  If a style is given, it will change  which & how programs will start.
#
#
windowmanager="$1"
style="$2"


function outmsg(){
    echo
    echo "Changing windowmanger to $1"
    }

function stylemsg(){
    echo "Startup path will use $1 style"
    }

if [ x$windowmanager = x ]
then
    echo
    echo "Usage: "
    echo "    set_windowmanager.sh  WINDOWMANAGER STARTUP_STYLE"
    echo
    echo "Valid WINDOWMANAGER options are:"
    echo "      default"
    echo "      enlightenment"
    echo "      fluxbox"
    echo "      windowmaker"
    echo "      place_custom_startup_here"
    echo
    echo "Valid STARTUP_STYLE options are:"
    echo "      default"
    echo "      mythvantage"
    echo
    echo "If STARTUP_STYLE is not given, then the default will be used."
    echo
    echo "Example:    "
    echo "    set_windowmanager.sh  enlightenment mythvantage"
    echo
    echo " "
    echo "if using enlightenment or windowmaker, please ensure that the alt_wm group is installed"
    echo "pacman -Sy alt_wm"

    exit 0
fi


case ${windowmanager} in

    default)
        outmsg "default/fluxbox"
        outline="fluxbox"
        echo "" > /etc/X11/WINDOWMANAGER
        exit 0
        ;;

    enlightenment)
        outmsg "enlightenment"
        outline="e16 -P /data/e16_config_dir/"
        ;;

    windowmaker)
        outmsg "window maker"
	outline_2="export GNUSTEP_USER_ROOT=/data/GNUstep"

        outline="wmaker"
        ;;

    *)
        outline=$windowmanager
        outmsg "$outline"
        ;;

esac



case ${style} in

    mythvantage)

        STYLE="mythvantage"
        stylemsg MythVantage
        ;;
    *)
        STYLE="$style"
        stylemsg "Default"
        ;;

esac


echo WM=\"${outline}\" > /etc/X11/WINDOWMANAGER
echo "STARTUP_STYLE=$STYLE" >>  /etc/X11/WINDOWMANAGER
echo ${outline_2}  >>  /etc/X11/WINDOWMANAGER