omap3-pandora-kernel2: update
[openpandora.oe.git] / recipes / pandora-system / pandora-scripts / op_startupmanager.sh
1 #!/bin/bash
2 # Released under the GPL
3 # Startup-Manager, v1.1, written by Michael Mrozek aka EvilDragon 2010 with some help by vimacs.
4 # This scripts allows you to change various settings of the Pandora startup process.
5
6 . /usr/pandora/scripts/op_common.sh
7 user2=$(get_user)
8 user2_home=$(get_user_home)
9
10 while mainsel=$(zenity --title="Startup manager" --width="400" --height="310" --list --column "id" --column "Please select" --hide-column=1 --text="Welcome to the Startup Settings\n\nHere you can change the default boot-up behaviour of your Pandora.\n\nWhat do you want to do?\n" "gui" "Change Default GUI for current user" "login" "Enable/Disable auto login" "user" "Select default user" "service" "Enable/Disable services on boot" --ok-label="Change Setting" --cancel-label="Exit"); do
11
12
13 case $mainsel in
14
15 # Change default GUI
16   "gui")
17     selection=$(cat /etc/pandora/conf/gui.conf | awk -F\; '{print $1 "\n" $2 }' | zenity ---width=500 --height=300 --title="Change the default GUI" --list --column "Name" --column "Description" --text "Please select the GUI you want to run as default startup" )
18
19     echo $selection
20
21     gui=$(grep $selection /etc/pandora/conf/gui.conf | awk -F\; '{print $3}')
22
23     if [ $gui ]; then 
24       sed -i "s/.*DEFAULT_SESSION=.*/DEFAULT_SESSION=$gui/g" $user2_home/.xinitrc
25       zenity --info --title="Changed session" --text "The default session has been changed to $selection." --timeout 6
26     fi;;
27
28 # Enable / Disable Autologin 
29    "login")
30       if zenity --question --title="Autologin" --text="Do you wish to automatically login at startup?\n\nSecurity warning: This skips the password check on startup" --ok-label="Yes" --cancel-label="No"; then         
31         sed -i 's/.*auto_login.*/auto_login yes/g' /etc/slim.conf
32         zenity --info --title="Changed auto login" --text "Auto login is now enabled." --timeout 6
33       else
34         sed -i 's/.*auto_login.*/auto_login no/g' /etc/slim.conf
35         zenity --info --title="Changed auto login" --text "Auto login is now disabled." --timeout 6
36       fi;;
37
38 # Select default user
39     "user")
40        if username=$(cat /etc/passwd | grep /home/ | grep -v root | awk -F\: '{print $1 }' | zenity --width=100 --height=200 --title="Select the default user" --list  --column "Username"  --text "Please select the default user\nor press Cancel to disable a default user.") ; then
41          sed -i "s/.*default_user.*/default_user $username/g" /etc/slim.conf
42          zenity --info --title="Changed default user" --text "The default user is now $username." --timeout 6
43        else
44         echo
45         sed -i "s/.*default_user.*/default_user/g" /etc/slim.conf
46         zenity --info --title="Changed default user" --text "The default user disabled" --timeout 6
47        fi;;
48
49 # Enable / Disable services on boot
50       
51      "service")
52         while servsel=$((
53                 cat /etc/pandora/conf/service.conf|awk -F\# '{
54                 if (system("test -f "$1))
55                     print "FALSE"
56                 else
57                     print "TRUE";print NR;print $2
58                 }'
59                 )|
60                 zenity --title='Service Manager' --width=500 --height=300 --list --checklist --hide-column=2 --column Enabled --column line --column 'Please select'  --text='Enable / Disable Service:' --separator='#'); do
61
62         cat /etc/pandora/conf/service.conf|awk -F\# -v pat="$servsel" '{
63         if (match(pat,NR))
64             system ($4)
65         else
66             system ($3)
67         }'
68         zenity --info --title="Done" --text "The startup services have been changed." --timeout 6
69         done
70 ;;
71 esac
72 done