Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Scripting WM selection
View unanswered posts
View posts from last 24 hours
View posts from last 7 days

 
Reply to topic    Gentoo Forums Forum Index Desktop Environments
View previous topic :: View next topic  
Author Message
GetCool
Guru
Guru


Joined: 23 Nov 2003
Posts: 324
Location: Madison, Wisconsin

PostPosted: Fri Feb 17, 2006 1:19 am    Post subject: Scripting WM selection Reply with quote

I need a good way to allow a user to select from a multitude of window managers after running 'startx' (or a custom script). I'd like it to be a scripted solution (i.e. no xdm/gdm/etc.), and I'd rather not mess with the actual /usr/bin/startx script itself. So I'm thinking along the lines of a custom script sitting in the user's home directory. Here's a quick hack I through together, though it's definitely not ideal and I'm a scripting ignoramus, so I'm searching for a more elegant solution:

Code:
#!/bin/bash

loop=1

echo "Available window managers:"
echo
echo "    1 - ratpoison"
echo "    2 - icewm"
echo "    3 - evilwm"
echo

while [ $loop = 1 ]; do
        echo -n "Select a window manager [enter 0 to exit]: "
        read wm
        if [[ $wm == 0 || $wm == exit ]]; then
                loop=0
        elif [[ $wm == 1 || $wm == ratpoison ]]; then
                ln -sf ~/.xinitrc-ratpoison ~/.xinitrc
                loop=0
                startx &
        elif [[ $wm == 2 || $wm == icewm ]]; then
                ln -sf ~/.xinitrc-icewm ~/.xinitrc
                loop=0
                startx &
        elif [[ $wm == 3 || $wm == evilwm ]]; then
                ln -sf ~/.xinitrc-evilwm ~/.xinitrc
                loop=0
                startx &
        fi
done


I then have an individual .xinitrc file for each WM (.xinitrc-icewm, .xinitrc-ratpoison, etc.), and a symbolic link is created at .xinitrc that points to one of these other files. Kind of hokey, I know. Ideally it wouldn't involve calling /usr/bin/startx and just having everything in this one script, but I'm unsure of everything I need to include from /usr/bin/startx to make things run properly.

So, if anyone can offer any suggestions for improving this, I'd really appreciate it. Thanks.
Back to top
View user's profile Send private message
yabbadabbadont
Advocate
Advocate


Joined: 14 Mar 2003
Posts: 4791
Location: 2 exits past crazy

PostPosted: Fri Feb 17, 2006 5:11 am    Post subject: Reply with quote

Just export the XSESSION environment variable with the value the user has selected. That should override what is set in /etc/rc.conf and start the correct session when the user runs startx.


e.g. export XSESSION=fluxbox
Back to top
View user's profile Send private message
GetCool
Guru
Guru


Joined: 23 Nov 2003
Posts: 324
Location: Madison, Wisconsin

PostPosted: Fri Feb 17, 2006 5:49 am    Post subject: Reply with quote

yabbadabbadont wrote:
Just export the XSESSION environment variable with the value the user has selected. That should override what is set in /etc/rc.conf and start the correct session when the user runs startx.

e.g. export XSESSION=fluxbox


Okay, that's good to know. I was wondering how to make use of the /etc/X11/Sessions without using xdm/kdm/gdm. Thanks for the tip.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Desktop Environments All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum