gui.conf / startmmenu: Fixed loading and killing of mmenu
[openpandora.oe.git] / recipes / pandora-system / pandora-scripts / op_gammamanager.sh
1 #!/bin/bash
2
3
4 if selection=$(cat /etc/pandora/conf/gamma.conf | awk -F\; '{print $1 "\n" $2 }' | zenity --width=700 --height=400 --title="Gamma Manager" --list --column "Name" --column "Description" --text "Please select a Gamma Profile" ); then
5 echo $selection
6
7
8 gamma=$(grep "$selection" /etc/pandora/conf/gamma.conf | awk -F\; '{print $3}')
9
10 if [ ${gamma} = "syssyscreatenew" ]; then
11     cat /sys/devices/platform/omap2_mcspi.1/spi1.1/gamma > /tmp/gamma.current
12     op_gammatool
13     if zenity --question --title="Confirm new gamma setting" --text="Do you want to keep the current gamma setting or revert to the previous one?" --ok-label="Keep it" --cancel-label="Revert"; then
14        if zenity --question --title="Save as profile" --text="Do you want to save the new gamma setting as new profile?\n\nNote: You can also test it out first and save it later by restarting the Gamma Manager" --ok-label="Save it now" --cancel-label="Don't save it now"; then    
15          while ! name=$(zenity --title="Save current settings" --entry --text "Please enter a Name for the new profile.") || [ "x$name" = "x" ] ; do
16             zenity --title="Error" --error --text="Please enter a name for the profile.." --timeout 6
17          done
18          curr=$(cat /sys/devices/platform/omap2_mcspi.1/spi1.1/gamma)
19          desc=$(zenity --title="Save current settings" --entry --text "Please enter a description for the new profile.")
20          echo "$name;$desc;$curr" >> /etc/pandora/conf/gamma.conf    
21          zenity --info --title="Profile created" --text "The current gamma settings have been saved as a new profile." --timeout 6
22        fi
23      else
24        cat /tmp/gamma.current > /sys/devices/platform/omap2_mcspi.1/spi1.1/gamma
25      fi
26 elif [ ${gamma} = "syssyssavecurrent" ]; then
27     curr=$(cat /sys/devices/platform/omap2_mcspi.1/spi1.1/gamma)
28     while ! name=$(zenity --title="Save current settings" --entry --text "Please enter a Name for the new profile.") || [ "x$name" = "x" ] ; do
29             zenity --title="Error" --error --text="Please enter a name for the profile.." --timeout 6
30     done
31     desc=$(zenity --title="Save current settings" --entry --text "Please enter a description for the new profile.")
32     echo "$name;$desc;$curr" >> /etc/pandora/conf/gamma.conf    
33     zenity --info --title="Profile created" --text "The current gamma settings have been saved as a new profile." --timeout 6
34 elif [ ${gamma} = "syssysdeleteprofile" ]; then    
35     if selection2=$(cat /etc/pandora/conf/gamma.conf | grep -v syssys | awk -F\; '{print $1 "\n" $2 }' | zenity --width=700 --height=400 --title="Delete gamma profile" --list --column "Name" --column "Description" --text "Please select a Gamma Profile to Delete" ); then
36        if zenity --question --title="Confirm Profile Removal" --text="Are you REALLY sure you want to remove the profile $selection2?\n\nThere will be NO other confirmation and this can NOT be undone!" --ok-label="Yes, remove the profile!" --cancel-label="Don't remove the profile"; then
37           remove=$(grep "$selection2" /etc/pandora/conf/gamma.conf)
38           cat /etc/pandora/conf/gamma.conf | grep -v "$remove" > /tmp/gamma.conf
39           mv /tmp/gamma.conf /etc/pandora/conf/gamma.conf
40           zenity --info --title="Profile deleted" --text "The profile has been deleted." --timeout 6
41        else
42           zenity --info --title="Profile not deleted" --text "The profile has not been deleted." --timeout 6
43        fi
44     fi
45 else
46 echo $gamma > /sys/devices/platform/omap2_mcspi.1/spi1.1/gamma
47 fi
48 fi