You are not logged in.

#1 2011-04-16 18:11:20

ans5685
Member
From: Kolkata/India
Registered: 2008-07-02
Posts: 14

Start X at console login with WM selection menu

I was using CDM and wanted to, optionally,  start X at console login like CDM does but as a non root user, so I wrote a tiny script to do it:

#!/bin/bash
#xstarter.sh
WM_LIST=( ' '  'Openbox'  'Antico'  'XFCE'  'Awesome'  'WMFS'  'I3'  'Subtle' 'Tinywm' 'Console')
TOTAL_WMS=9
#need to assign the $TERM comparison to a variable
#same goes for the console comparison

if  [  $TERM == 'linux' ]; then
    echo  'Please select one:'
    for ((i=1; i<=$TOTAL_WMS;  i++))
    do
        echo  "$i. ${WM_LIST[$i]}"
    done
    echo  ' '
    read -n 1 choice
    echo " "
    echo "Your choice: ${WM_LIST[$choice]}"
    if  [ "${WM_LIST[$choice]}" != "Console" ]; then
        xinit  ${WM_LIST[$choice]} 
    fi
fi
exit 0

Just put it somewhere in your $PATH, make it executable and put the executable name in your .bash_profile like this:

[user@desktop ~]$ cat .bash_profile 
. $HOME/.bashrc
PATH=$PATH:/home/user/bin
fortune |cowsay
xstarter.sh

It would then start automatically when you log in to a tty. and display a rudimentary selection menu like:

 _______________________________________ 
/ Memory fault --                       \
| core...uh...um...core... Oh dammit, I |
\ forget!                               /
 --------------------------------------- 
        \   ^__^
         \  (oo)\_______
            (__)\       )\/\
                ||----w |
                ||     ||

Please select one:
1. Openbox
2. Antico
3. XFCE
4. Awesome
5. WMFS
6. I3
7. Subtle
8. Tinywm
9. Console
 
9 
Your choice: Console
[user@desktop ~]$

of course you would also need to  update your .xinitrc to handel the arguments correctly:

#!/bin/sh
#
# ~/.xinitrc
#
# Executed by startx (run your window manager from here)
# exec gnome-session
# exec startkde
# exec startxfce4
# ...or the Window Manager of your choice
#exec openbox-session
#export DE=gnome
DEFAULT_SESSION=openbox-session

numlockx 
xrdb load .Xdefaults &
xsetroot -cursor_name left_ptr &
nitrogen --restore &
startserving.sh &
mpd ~/.mpd/config
mpnotify.sh &
fittstool &


case $1 in

XFCE)
    exec startxfce4
    ;;
Openbox)
    exec ck-launch-session openbox-session
    ;;
Antico)
    exec /usr/bin/antico-deluxe
    ;;
WMFS)
    exec /usr/bin/wmfs
    ;;
Awesome)
    exec awesome
    ;; 
I3)
    exec i3
    ;;
Subtle)
    exec subtle 
    ;;
Tinywm)
        lxpanel &
        xcompmgr -cC &
        exec /usr/bin/tinywm
    ;;
*)
    exec $DEFAULT_SESSION
    ;;
esac

of course it may be totally useless to everybody but me :) But I still thought I'd share it.

Offline

#2 2011-04-18 08:09:07

gorilla
Member
From: Berlin
Registered: 2010-06-15
Posts: 72

Re: Start X at console login with WM selection menu

Hmm, why doesn't cdm support login as a non-root user for you?

Offline

#3 2011-04-24 17:56:35

ans5685
Member
From: Kolkata/India
Registered: 2008-07-02
Posts: 14

Re: Start X at console login with WM selection menu

I can login as a non root user but the X session starts with root privileges. Maybe it is designed to do so. I may take a look into it later.

Offline

Board footer

Powered by FluxBB