New Script: op_gammamanager.sh - Lets the user load, create and save LCD gamma profiles
authorMichael Mrozek <EvilDragon@openpandora.org>
Tue, 13 Apr 2010 02:47:32 +0000 (04:47 +0200)
committerMichael Mrozek <EvilDragon@openpandora.org>
Tue, 13 Apr 2010 02:47:32 +0000 (04:47 +0200)
recipes/pandora-system/pandora-scripts.bb
recipes/pandora-system/pandora-scripts/op_gammamanager.desktop [new file with mode: 0644]
recipes/pandora-system/pandora-scripts/op_gammamanager.sh [new file with mode: 0755]

index c0f5def..5ae5f4a 100644 (file)
@@ -6,7 +6,7 @@ COMPATIBLE_MACHINE = "omap3-pandora"
 DEPENDS = "zenity dbus"
 RDEPENDS = "zenity dbus"
 
-PR = "r12"
+PR = "r13"
 
 SRC_URI = " \
           file://op_bright.sh \
@@ -29,7 +29,10 @@ SRC_URI = " \
           file://op_datetime.desktop \
          file://op_usermanager.sh \
           file://op_usermanager.desktop \
+          file://op_gammamanager.sh \
+          file://op_gammamanager.desktop \
           file://gui.conf \
+          file://gamma.conf \
 "
 
 do_install() {
@@ -43,6 +46,7 @@ do_install() {
           install -m 0755 ${WORKDIR}/op_calibrate.sh ${D}${prefix}/pandora/scripts/
           install -m 0755 ${WORKDIR}/op_datetime.sh ${D}${prefix}/pandora/scripts/
          install -m 0755 ${WORKDIR}/op_usermanager.sh ${D}${prefix}/pandora/scripts/
+          install -m 0755 ${WORKDIR}/op_gammamanager.sh ${D}${prefix}/pandora/scripts/
           
           install -d ${D}${datadir}/applications/
           install -m 0644 ${WORKDIR}/op_cpuspeed.desktop ${D}${datadir}/applications/
@@ -53,12 +57,14 @@ do_install() {
           install -m 0644 ${WORKDIR}/op_calibrate.desktop ${D}${datadir}/applications/
           install -m 0644 ${WORKDIR}/op_datetime.desktop ${D}${datadir}/applications/
          install -m 0644 ${WORKDIR}/op_usermanager.desktop ${D}${datadir}/applications/
+          install -m 0644 ${WORKDIR}/op_gammamanager.desktop ${D}${datadir}/applications/
           
           install -d ${D}${sysconfdir}/xdg/autostart/
           install -m 0644 ${WORKDIR}/op_bluetooth-check.desktop ${D}${sysconfdir}/xdg/autostart/op_bluetooth-check.desktop
 
           install -d ${D}${sysconfdir}/pandora/conf/
           install -m 0644 ${WORKDIR}/gui.conf ${D}${sysconfdir}/pandora/conf/gui.conf
+          install -m 0644 ${WORKDIR}/gamma.conf ${D}${sysconfdir}/pandora/conf/gamma.conf
 
           install -d ${D}${bindir}/
           install -m 0755 ${WORKDIR}/startnetbooklauncher ${D}${bindir}/
diff --git a/recipes/pandora-system/pandora-scripts/op_gammamanager.desktop b/recipes/pandora-system/pandora-scripts/op_gammamanager.desktop
new file mode 100644 (file)
index 0000000..6ca93eb
--- /dev/null
@@ -0,0 +1,9 @@
+[Desktop Entry]
+Name=LCD Gamma Manager
+Comment=Load, create and save LCD Gamma profiles.
+StartupNotify=false
+Exec=sudo /usr/pandora/scripts/op_gammamanager.sh
+Icon=package_graphics
+Terminal=false
+Type=Application
+Categories=Settings;
diff --git a/recipes/pandora-system/pandora-scripts/op_gammamanager.sh b/recipes/pandora-system/pandora-scripts/op_gammamanager.sh
new file mode 100755 (executable)
index 0000000..7a7c0d2
--- /dev/null
@@ -0,0 +1,48 @@
+#!/bin/bash
+
+
+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
+echo $selection
+
+
+gamma=$(grep "$selection" /etc/pandora/conf/gamma.conf | awk -F\; '{print $3}')
+
+if [ ${gamma} = "syssyscreatenew" ]; then
+    cat /sys/devices/platform/omap2_mcspi.1/spi1.1/gamma > /tmp/gamma.current
+    op_gammatool
+    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
+       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    
+         while ! name=$(zenity --title="Save current settings" --entry --text "Please enter a Name for the new profile.") || [ "x$name" = "x" ] ; do
+           zenity --title="Error" --error --text="Please enter a name for the profile.." --timeout 6
+         done
+         curr=$(cat /sys/devices/platform/omap2_mcspi.1/spi1.1/gamma)
+         desc=$(zenity --title="Save current settings" --entry --text "Please enter a description for the new profile.")
+         echo "$name;$desc;$curr" >> /etc/pandora/conf/gamma.conf    
+         zenity --info --title="Profile created" --text "The current gamma settings have been saved as a new profile." --timeout 6
+       fi
+     else
+       cat /tmp/gamma.current > /sys/devices/platform/omap2_mcspi.1/spi1.1/gamma
+     fi
+elif [ ${gamma} = "syssyssavecurrent" ]; then
+    curr=$(cat /sys/devices/platform/omap2_mcspi.1/spi1.1/gamma)
+    while ! name=$(zenity --title="Save current settings" --entry --text "Please enter a Name for the new profile.") || [ "x$name" = "x" ] ; do
+           zenity --title="Error" --error --text="Please enter a name for the profile.." --timeout 6
+    done
+    desc=$(zenity --title="Save current settings" --entry --text "Please enter a description for the new profile.")
+    echo "$name;$desc;$curr" >> /etc/pandora/conf/gamma.conf    
+    zenity --info --title="Profile created" --text "The current gamma settings have been saved as a new profile." --timeout 6
+elif [ ${gamma} = "syssysdeleteprofile" ]; then    
+    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
+       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
+         remove=$(grep "$selection2" /etc/pandora/conf/gamma.conf)
+          cat /etc/pandora/conf/gamma.conf | grep -v "$remove" > /tmp/gamma.conf
+         mv /tmp/gamma.conf /etc/pandora/conf/gamma.conf
+         zenity --info --title="Profile deleted" --text "The profile has been deleted." --timeout 6
+       else
+          zenity --info --title="Profile not deleted" --text "The profile has not been deleted." --timeout 6
+       fi
+    fi
+else
+echo $gamma > /sys/devices/platform/omap2_mcspi.1/spi1.1/gamma
+fi
+fi
\ No newline at end of file