You are not logged in.

#1 2009-07-19 11:55:20

sm4tik
Member
From: Finland, Jyväskylä
Registered: 2006-11-05
Posts: 248
Website

Dialog based WM chooser

Hi,

I'm currently trying out different window managers and thought I'd share what I came up with. I seached the forum and found a zenity one and another one choosing your wm manually by "xinit yourChoise", but neither was quite what I wanted. My idea was to choose a wm before starting X. So here is my current working version of a dialog menu based wm chooser when logging in from VC/1.

The wmchooser.sh script

#!/bin/sh
#
# A script to choose your WM
#
#------------------------ ----------- - ----  -
# First a few thigs we want to know..
#-------------------------------------- - ---- -- -

# List your WMs here. Use executable names!
LIST=(fvwm musca ion3 scrotwm)

# Window height/width and menu height
# Defaut 0=auto
W_HEIGHT=0
W_WIDTH=0
M_HEIGHT=0

#-------- ---------------------- - - ----    --
# And here goes the script
#-------------------------------   - -

COUNT=0

# Create menu entries
MENU=$(while [ $COUNT -lt ${#LIST[@]} ]; do
    echo -ne "$COUNT ${LIST[$COUNT]} "
    let COUNT=COUNT+1
done)

WM=$(dialog --stdout \
--ok-label "StartX" \
--cancel-label "Logout" \
--menu "Select Window Manager" \
$W_HEIGHT \
$W_WIDTH \
$M_HEIGHT \
$MENU)

# Set WIN_MGR
# choosewm=0, cancel=1, esc=255
case $? in
    0)    clear; WIN_MGR="${LIST[$WM]}" startx;;
    *)    clear; exit 1;;
esac

~/.*sh_profile (currently .zprofile)
When exiting X, I want to run the menu again so I won't have to logout/login each time

# Start X if logging in at VC/1
if [[ -z "$DISPLAY" ]] && [[ $(tty) = /dev/vc/1 ]]; then
    while [ $? -eq 0 ]; do
        /home/sm4tik/.scripts/wmchooser.sh
    done
    logout
fi

And finally ~/.xinitrc

#!/bin/sh

# Set default WM
DEF_WM=fvwm

# ...
# Rest of the xinitrc stuff
# ...

# Execute WIN_MGR of your choise
if [ ! -n "$WIN_MGR" ]; then
    WIN_MGR="$DEF_WM"
fi
exec "$WIN_MGR"

The If startx is run from clean console, the DEF_WM gets executed.
I really don't know much about shell scripting and I'd like this to be any working in any *sh, so any help/suggestions are welcome. Also, if you have suggestions for a more correct/better/easier way of doing this, I'd appreciate it!

Last edited by sm4tik (2009-07-19 11:56:13)

Offline

#2 2009-07-19 12:46:51

moljac024
Member
From: Serbia
Registered: 2008-01-29
Posts: 2,676

Re: Dialog based WM chooser

Nice one smile
I made a similar script for myself but I deleted it after realizing I never used it big_smile


The day Microsoft makes a product that doesn't suck, is the day they make a vacuum cleaner.
--------------------------------------------------------------------------------------------------------------
But if they tell you that I've lost my mind, maybe it's not gone just a little hard to find...

Offline

#3 2009-07-19 14:12:17

u_no_hu
Member
Registered: 2008-06-15
Posts: 453

Re: Dialog based WM chooser

moljac024 wrote:

Nice one smile
I made a similar script for myself but I deleted it after realizing I never used it big_smile

Me too.. I made that zenity one... but got bored of it within days smile


Don't be a HELP VAMPIRE. Please search before you ask.

Subscribe to The Arch Daily News.

Offline

#4 2009-07-19 16:58:17

bernarcher
Forum Fellow
From: Germany
Registered: 2009-02-17
Posts: 2,281

Re: Dialog based WM chooser

I didn't bother. Just defined some simple aliases:

# Some startup and shutdown conveniences
alias _X='startx'
alias _G='xinit /usr/bin/ck-launch-session gnome-session'
alias _K='xinit /usr/bin/ck-launch-session startkde'

Where startx (_X) is set to start IceWM.
A simple /etc/issue prompt is all I need to remind me.


To know or not to know ...
... the questions remain forever.

Offline

Board footer

Powered by FluxBB