As most everyone knows you can start more than one X session with startx. But for those of us who swear by and use Mandrivas Xtart we haven't had that luxury except by using startx once logged into X. Well times have changed and there is a solution. I stumbled upon this nice little script today in fact while trying to fix a startx problem I have. Below is the actual script, a python script at that, and also the persons direct URL that I got the script from.
#!/usr/bin/env python
"""
myXtart: Allows user to start X with choice from a text menu
of available Window Managers. Revision of Linux-Mandrake's Xtart
program, but offers support for multiple X sessions.
Usage: myXtart (that's all, currently!)
"""
__author__ = "Hans Updyke <hansup@dimensional.com>"
__date__ = "$Date: 2003/09/14 01:18:03 $"
__version__ = "$Revision: 0.3 $"
import sys, os, popen2, string
def complain():
print '\nWhat do you expect me to do with that?\n'
def bail():
sys.exit(0)
return
print '\n WELCOME to Sessions Selector\n'
display = ''
displays = [':0', ':1', ':2', ':3', ':4', ':5']
for item in displays:
lockfile = '/tmp/.X' + item[1:] + '-lock'
if os.path.isfile(lockfile):
pass
else:
display = item
break
if len(display) == 0:
print 'No available displays found.'
sys.exit(0)
wmsessiondir = '/etc/X11/wmsession.d'
wmList = os.listdir(wmsessiondir)
Sessions = {}
Sessionkeys = []
for wm in wmList:
primekey = int(wm[0:2])
name = wm[2:]
grepcommand = 'grep EXEC= /etc/X11/wmsession.d/' + wm
execline = os.popen(grepcommand ).read()
wmcommand = execline[5:-1]
Sessions[primekey] = (name, wmcommand)
Sessions[0] = ('xterm (no Window Manager)', '/usr/X11R6/bin/xvt')
Sessions[99] = ('TWM', '/usr/X11R6/bin/twm')
Sessionkeys = Sessions.keys()
Sessionkeys.sort()
for option in Sessionkeys:
if os.system('[ -x '+Sessions[option][1]+' ]') == 0:
print option, Sessions[option][0]
pass
print
sys.stdin.flush()
response = raw_input('Which do you choose? (number) ')
if len(response) == 0:
print "\nI need a number.\n"
bail()
try:
if int(response):
pass
except ValueError:
print "\nOnly numbers please."
complain()
bail()
if len(response) > 2:
print "\nBe Reasonable! That number is too big."
complain()
bail()
wmSelection = int(response)
acceptable = Sessions.has_key(wmSelection)
if acceptable:
print 'Sessions[wmSelection] =', Sessions[wmSelection]
xinitTuple = ("", Sessions[wmSelection][1], "--", display)
print ' '*16, xinitTuple
os.execvp('xinit', xinitTuple)
else:
print '\nAll that work and you mistyped the number.'
print 'Hmph!'
complain()
bail()
Here is the actual URL I found this at:
