File: functions.Xsession

package info (click to toggle)
sdm 0.4.1-4
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 204 kB
  • ctags: 13
  • sloc: sh: 86; makefile: 17
file content (71 lines) | stat: -rw-r--r-- 2,278 bytes parent folder | download
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
# Copyright 2003-2007 Vagrant Cascadian <vagrant@freegeek.org>.
# Licensed under the terms of the GNU General Public License,
# version 2 or any later version.

checkMacAddress() {
    # checks to see if the user is logged in as a student/generic account, 
    # and if that login matches up to the lessdisks terminal they're using.
    if echo $USER | egrep "student"; then    
        MAC=`/usr/sbin/arp $(echo $SSH_CLIENT | awk '{print $1}') | awk '{if(NR==2){print $3}}'`
        TERMINAL=`egrep $MAC /etc/lessdisks/terminals.config | awk '{print $1}'`
        if [ "$TERMINAL" != "$USER" ]; then
            xmessage -center -timeout 30 "You are at the wrong terminal $USER...
                Try logging in as $TERMINAL, or your own account if you have one."
            exit 1    
        fi                                                                                                                                    
        # TODO rsync user directory structure ??
    fi
}

updateWmanagerrc() {
    if [ $(which wmanagerrc-update) -a ! -e ~/.wmanagerrc ]; then
        wmanagerrc-update
        if [ -r /etc/sdm/windowmanagers ]; then
            egrep -v ^# /etc/sdm/windowmanagers >> ~/.wmanagerrc
        fi
        if [ "0" != "$?" ]; then
            xmessage "generating config file for $windowmanager failed, setting to defaults"
            windowmanager=
        fi
    fi
}

updateSelectwmrc() {
    if [ $(which wmanagerrc-update) -a ! -e ~/.selectwmrc ]; then
        updateWmanagerrc
        cp ~/.wmanagerrc ~/.selectwmrc
        echo "delay:0.000000" >> ~/.selectwmrc
    fi
}

chooseWindowManager() {
    if [ -x /usr/bin/sdm-wm ]; then
        . /usr/bin/sdm-wm
    elif [ $(which wmanager) ]; then
        windowmanager=wmanager

    elif [ $(which selectwm) ]; then
        windowmanager=selectwm
    fi
    case "$windowmanager" in
        selectwm) updateSelectwmrc ;;
        wmanager) updateWmanagerrc 
            windowmanager=$(wmanager) ;;
    esac
}

setWindowManager() {
    if [ -z "$windowmanager" ]; then
        chooseWindowManager    
    fi
}

checkWindowManager() {
    if [ ! -x $(which $windowmanager) ]; then
        windowmanager=
    fi
}

if [ -r /etc/sdm/Xsession.functions ]; then
    . /etc/sdm/Xsession.functions
fi