The script assumes you are using "startx" and .xinitrc to start your window manager. Modify your .xinitrc so that the last two lines look like this (the xmessage call puts up a little box to tell you which WM you are using; you can delete this if you really want to be surprised):
Code: Select all
xmessage -timeout 5 -center "you are running"$1
exec $1
Code: Select all
#!/bin/bash
# the list of window managers can be read from a file, one line at a time
#alist=(`cat wmlist`)
# or set the list here inside the script. either way the last entry should always be "random"
alist=( ratpoison cwm twm sithwm fluxbox openbox blackbox ctwm alopex monsterwm random )
let num=${#alist[*]}-1 # number of items in the array (minus one to account for zero index)
tmpfile=`mktemp` # make a temp file for dialog return value
# make a list in menu format, with a number first, then the name
for i in `seq 0 $num`; do
blist[i]=`echo $i ${alist[i]}`
done
# display the list in a dialog, save the return value (the index number) in the tmpfile
dialog --no-tags --menu 'choose a window manager' 50 50 10 ${blist[*]} 2>$tmpfile
chosen=$(<$tmpfile) # get the index from the tmpfile
if [ $chosen -eq $num ]; then # last choice is always "random"
let RANGE=$num # set range to zero to number of elements minus one
chosen=$RANDOM # pick a random integer
let chosen%=$RANGE # use modulo operator to make it within range
fi
rm $tmpfile # delete the temp file
# index into the WM array to get the name of the WM, and start it
xinit ${alist[$chosen]}
Then, instead of calling "startx" just call the script from the console after you log in.