op_startupmanager: First version done.
[openpandora.oe.git] / recipes / pandora-system / pandora-scripts / op_startupmanager.sh
1 #!/bin/bash
2 # Main GUI
3
4 while mainsel=$(zenity --title="Startupmanager" --width="400" --height="250" --list --column "id" --column "Please select" --hide-column=1 --text="What do you want to do?" "gui" "Change Default GUI for current user" "login" "Enable/Disable Autologin" "user" "Select default user" "wifi" "Enable/Disable WiFi on Boot"); do
5
6 case $mainsel in
7
8 # Change default GUI
9   "gui")
10     user2=$(cat /tmp/currentuser)
11     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" )
12     echo $selection
13
14     gui=$(grep $selection /etc/pandora/conf/gui.conf | awk -F\; '{print $3}')
15
16     if [ $gui ]; then 
17       sed -i "s/.*DEFAULT_SESSION=.*/DEFAULT_SESSION=$gui/g" /home/$user2/.xinitrc
18       zenity --info --title="Changed session" --text "The default session has been changed to $selection." --timeout 6
19     fi;;
20
21 # Enable / Disable Autologin 
22    "login")
23       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         
24         sed -i 's/.*auto_login.*/auto_login yes/g' /etc/slim.conf
25         zenity --info --title="Changed Autologin" --text "Autologin is now enabled." --timeout 6
26       else
27         sed -i 's/.*auto_login.*/auto_login no/g' /etc/slim.conf
28         zenity --info --title="Changed Autologin" --text "Autologin is now disabled." --timeout 6
29       fi;;
30
31 # Select default user
32     "user")
33        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
34          sed -i "s/.*default_user.*/default_user $username/g" /etc/slim.conf
35          zenity --info --title="Changed Default User" --text "The default user is now $username." --timeout 6
36        else
37         echo
38         sed -i "s/.*default_user.*/default_user/g" /etc/slim.conf
39         zenity --info --title="Changed Default User" --text "The default user disabeled" --timeout 6
40        fi;;
41
42 # Enable / Disable WiFi on boot
43      "wifi")
44       if zenity --question --title="Start WiFi on Bootup" --text="Do you wish to automatically start the WiFi driver on bootup?" --ok-label="Yes" --cancel-label="No"; then             
45          ln -s ../init.d/wl1251-init /etc/rc5.d/S30wl1251-init
46          ln -s ../init.d/wl1251-init /etc/rc2.d/S30wl1251-init
47          zenity --info --title="Changed WiFi startup" --text "WiFi on boot is now enabled." --timeout 6
48       else
49          rm /etc/rc2.d/S30wl1251-init
50          rm /etc/rc5.d/S30wl1251-init
51          zenity --info --title="Changed WiFi startup" --text "WiFi on boot is now disabled." --timeout 6
52       fi;;
53 esac
54 done