summaryrefslogtreecommitdiff
blob: d8f5e7192928653e4a05675c4a603979749a12ed (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#!/usr/bin/env python
# dsx is Mandrakesoft's Xtart modified to work with a Gentoo Linux system.
# Gentoo doesn't use a wmsession.d directory, so we're going to accept the
# /etc/X11/Sessions executables as our menu and our command parameters.
# I also tried to increase the robustness of the entry checking and make the
# error messages less condescending.
# The 0 option for "no wm" was removed.  I altered it to run option 1 instead.

### Original copyright / license message from Xtart... ###
#  This is an official linux-mandrake extension of the X windowing system for
#  the benefit of Declan Moriarty  Copyright 2001 by civileme@mandrakesoft all
#  rights reserved.  Use is hereby granted under the GNU General Publoic
#  License version 2 or any future version of said license at the user's option
#
#  No Warranty of course.
#  This program is designed for those who want to work in concole and   
#  occasionally boot into window managers or who want to avoid theme
#  persistence from one WM to another.
################
import sys
import os
import popen2
import string
import math
def complain():
    print 'X initiation aborted on invalid selection.'
    sys.exit(0)
    return
print
print 'Welcome to the Desktop Selector for X'
print
fspc=os.path.expanduser('~')+'/'
io=popen2.Popen3('ls /etc/X11/Sessions',1)
L=io.fromchild.readlines()
Sessions={}
Sessionkeys=[]
primekey=0
for k in L:
    primekey+=1
    name=k[:-1]
    command='/etc/X11/Sessions/'+k[:-1]
    Sessions[primekey]=(name, command)
Sessionkeys=Sessions.keys()
Sessionkeys.sort()
for j in Sessionkeys:
    if os.system('[ -x '+Sessions[j][1]+' ]') == 0:
        print j, Sessions[j][0]
    pass
print
sys.stdin.flush()
s=raw_input('Enter the number of your desired desktop environment [1]: ')
if len(s)==0:
    s='1'
if s=='0':
    s='1'
for j in range(len(s)):
    if string.find(string.digits,s[j]) == -1:
        print "'" + s[j] + "' isn't a digit."
	complain()
if len(s)>int(math.log10(primekey))+1:
    print "That number is too big."
    complain()
well=int(s)
wellformed=Sessions.has_key(well)
if wellformed:
    os.execvp('xinit',Sessions[well])
else:
    print
    print 'Your selection was invalid.'
    print
    complain()