pandora-skel: .xinitrc fixes
[openpandora.oe.git] / recipes / pandora-system / pandora-skel / .xinitrc
1 # This script sets up a few XDG vairables for the OpenPandora (to find the Xfce defaults etc.)
2 # and then launches the chosen user session (mainly Xfce or PMenu)
3
4 # The makes sure that /etc/xdg/op is added to the vairables to get the defaults for the OP.
5 if test "x$XDG_CONFIG_DIRS" = "x"
6 then
7   XDG_CONFIG_DIRS="/etc/xdg/op:/etc/xdg"
8 else
9   XDG_CONFIG_DIRS="/etc/xdg/op:$XDG_CONFIG_DIRS:/etc/xdg"
10 fi
11 export XDG_CONFIG_DIRS
12
13 if test "x$XDG_DATA_DIRS" = "x"
14 then
15   XDG_DATA_DIRS="/usr/local/share:/usr/share:@_datadir_@"
16   XDG_DATA_DIRS="/etc/xdg/op:/usr/local/share:/usr/share:@_datadir_@"
17 else
18   XDG_DATA_DIRS="$XDG_DATA_DIRS:@_datadir_@"
19   XDG_DATA_DIRS="/etc/xdg/op:$XDG_DATA_DIRS:@_datadir_@"
20 fi
21 export XDG_DATA_DIRS
22
23 # Use FreeDesktop XDG dir vars to put user data in non hidden dirs to make
24 # maintaince easier for users.
25 # These really should be set somewhere better but for now this will work.
26 export XDG_DATA_HOME=$HOME/Applications/Data
27 export XDG_CONFIG_HOME=$HOME/Applications/Settings
28 export XDG_CACHE_HOME=$HOME/Applications/Cache
29
30 #HACK: Run Xsession.d from here :-o
31 #Wrong, wrong, wrong but it works and sorting out OE's X server chain is not going to happen right now.
32
33 if [ -d /etc/X11/Xsession.d ]; then
34     for i in `ls /etc/X11/Xsession.d/` ; do
35         if [ -r "/etc/X11/Xsession.d/$i" ] && expr "$i" : '^[[:alnum:]_-]\+$' > /dev/null; then
36             . "/etc/X11/Xsession.d/$i"
37         fi
38     done
39 fi
40
41 #Load up the proper keymap for X
42 xmodmap ~/.pndXmodmap
43
44 #Write the current user into /tmp/currentuser for any scripts or programs who want to make use of it
45 whoami > /tmp/currentuser
46 id -u > /tmp/currentuid
47 chmod +r /tmp/currentuser
48 chmod +r /tmp/currentuid
49
50 # HUP pndnotifyd to make sure it picks up the users home.
51 # -- nope, we are not root and can't do it
52 # killall -1 pndnotifyd &
53
54 # The following variable defines the session which is started if the user
55 # doesn't explicitely select a session in SLiM.
56
57 DEFAULT_SESSION=startxfce4
58 STOP_SESSION="xfce4-session-logout --logout"
59
60 # Write the default session into a temporary file.
61 # This way, we can easily add new sessions in the future by just
62 # setting the DEFAULT_SESSION to the executable or script.
63
64 echo $DEFAULT_SESSION > /tmp/gui.load
65
66 # If SLiM does pass a variable, use that. Otherwise use our DEFAULT_SESSION.
67
68 SESSION=$1
69
70 if [ "$SESSION" == "" ]; then
71         SESSION=$(cat /tmp/gui.load)
72 fi
73
74 STOP_SESSION=$(grep $SESSION /etc/pandora/conf/gui.conf | awk -F\; '{print $4}')
75 echo $STOP_SESSION > /tmp/gui.stop
76 chmod +x /tmp/gui.stop
77
78 # Disable screen blanking if uncommented
79 # DISPLAY=:0 xset s off
80
81 # Starts our session and checks if a new session should be loaded
82 # after the old one is quit by simply executing the command that's in /tmp/gui.load
83
84 # This way, we can easily do a quick switch from any session to the next one by simply
85 # echo'ing the new session executable into /tmp/gui.load and exiting.    
86
87 nocleanwarn=$(cat /tmp/nocleanwarn 2> /dev/null)
88
89 if [ "$nocleanwarn" = "Yes" ]; then
90
91   pnd_version=$(cat /tmp/pnd_version)
92   if [ "$pnd_version" = "OMAP3630" ]; then
93       safespeed="1000"
94   else
95       safespeed="600"
96   fi
97
98     defmhz="$(cat /etc/pandora/conf/cpu.conf | grep default | awk -F\: '{print $2}')"
99       if [ $defmhz -gt $safespeed ]; then
100           if zenity --question --title="Unclean Shutdown" --text="Warning!\n\nThe system has not been shutdown properly last time.\n\nAs you overclocked the CPU as default speed, this might be the reason for that.\nTherefore CPU speed has been currently set to the standard CPU speed of your SoC.\n\nShould it be set to your default speed ($defmhz MHz) or shall we keep safe setting for this session?" --ok-label="Set it to $defmhz MHz" --cancel-label="Leave it safe..."; then
101             sudo /usr/pandora/scripts/op_cpuspeed.sh $defmhz
102           fi
103       fi
104   echo "No" > /tmp/nocleanwarn
105 fi
106
107 while true
108 do
109         rm /tmp/gui.load
110
111         if [ "$SESSION" == "" ]
112         then
113                 # wait for all Xfce processes to exit cleanly
114                 wait
115
116                 # report success to slim
117                 exit 0
118         fi
119
120         $SESSION
121         
122         # lame hack
123         killall configbutton 2> /dev/null
124
125         SESSION=$(cat /tmp/gui.load 2> /dev/null)
126         STOP_SESSION=$(grep $SESSION /etc/pandora/conf/gui.conf | awk -F\; '{print $4}')
127         echo $STOP_SESSION > /tmp/gui.stop
128         chmod +x /tmp/gui.stop
129 done