7c0c3362cf06d88239360febebecb17a6bf44dca
[openpandora.oe.git] / recipes / hotfix / 2 / op_startupmanager.sh
1 #!/bin/bash
2 # Released under the GPL
3 # Startup-Manager, v1.0, 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 while mainsel=$(zenity --title="Startup manager" --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 auto login" "user" "Select default user" "wifi" "Enable/Disable WiFi on boot"); do
7
8
9 case $mainsel in
10
11 # Change default GUI
12   "gui")
13     user2=$(cat /tmp/currentuser)
14     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" )
15
16     echo $selection
17
18     gui=$(grep $selection /etc/pandora/conf/gui.conf | awk -F\; '{print $3}')
19
20     if [ $gui ]; then 
21       sed -i "s/.*DEFAULT_SESSION=.*/DEFAULT_SESSION=$gui/g" /home/$user2/.xinitrc
22       zenity --info --title="Changed session" --text "The default session has been changed to $selection." --timeout 6
23     fi;;
24
25 # Enable / Disable Autologin 
26    "login")
27       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         
28         sed -i 's/.*auto_login.*/auto_login yes/g' /etc/slim.conf
29         zenity --info --title="Changed auto login" --text "Auto login is now enabled." --timeout 6
30       else
31         sed -i 's/.*auto_login.*/auto_login no/g' /etc/slim.conf
32         zenity --info --title="Changed auto login" --text "Auto login is now disabled." --timeout 6
33       fi;;
34
35 # Select default user
36     "user")
37        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
38          sed -i "s/.*default_user.*/default_user $username/g" /etc/slim.conf
39          zenity --info --title="Changed default user" --text "The default user is now $username." --timeout 6
40        else
41         echo
42         sed -i "s/.*default_user.*/default_user/g" /etc/slim.conf
43         zenity --info --title="Changed default user" --text "The default user disabled" --timeout 6
44        fi;;
45
46 # Enable / Disable WiFi on boot
47      "wifi")
48       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             
49          ln -s ../init.d/wl1251-init /etc/rc5.d/S30wl1251-init
50          ln -s ../init.d/wl1251-init /etc/rc2.d/S30wl1251-init
51          zenity --info --title="Changed WiFi startup" --text "WiFi on boot is now enabled." --timeout 6
52       else
53          rm /etc/rc2.d/S30wl1251-init
54          rm /etc/rc5.d/S30wl1251-init
55          zenity --info --title="Changed WiFi startup" --text "WiFi on boot is now disabled." --timeout 6
56       fi;;
57 esac
58 done