op_lcdsettings.sh: Combined brightness and gamma settings into one script.
authorMichael Mrozek <EvilDragon@openpandora.de>
Mon, 26 Apr 2010 01:41:27 +0000 (03:41 +0200)
committerMichael Mrozek <EvilDragon@openpandora.de>
Mon, 26 Apr 2010 01:41:27 +0000 (03:41 +0200)
Also updated the sudoers-file for this.

recipes/pandora-system/pandora-scripts/op_gammamanager.desktop [deleted file]
recipes/pandora-system/pandora-scripts/op_gammamanager.sh [deleted file]
recipes/pandora-system/pandora-scripts/op_lcdsettings.desktop [new file with mode: 0644]
recipes/pandora-system/pandora-scripts/op_lcdsettings.sh [new file with mode: 0755]
recipes/pandora-system/pandora-scripts/pandorascripts.pnd
recipes/pandora-system/pandora-sudoers/50_openpandora

diff --git a/recipes/pandora-system/pandora-scripts/op_gammamanager.desktop b/recipes/pandora-system/pandora-scripts/op_gammamanager.desktop
deleted file mode 100644 (file)
index 6ca93eb..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-[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
deleted file mode 100755 (executable)
index 7a7c0d2..0000000
+++ /dev/null
@@ -1,48 +0,0 @@
-#!/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
diff --git a/recipes/pandora-system/pandora-scripts/op_lcdsettings.desktop b/recipes/pandora-system/pandora-scripts/op_lcdsettings.desktop
new file mode 100644 (file)
index 0000000..5e22175
--- /dev/null
@@ -0,0 +1,9 @@
+[Desktop Entry]
+Name=LCD Settings
+Comment=Manage LCD Gamma and Brightness.
+StartupNotify=false
+Exec=sudo /usr/pandora/scripts/op_lcdsettings.sh
+Icon=package_graphics
+Terminal=false
+Type=Application
+Categories=Settings;
diff --git a/recipes/pandora-system/pandora-scripts/op_lcdsettings.sh b/recipes/pandora-system/pandora-scripts/op_lcdsettings.sh
new file mode 100755 (executable)
index 0000000..e289111
--- /dev/null
@@ -0,0 +1,69 @@
+#!/bin/bash
+
+while mainsel=$(zenity --title="LCD-Settings" --width="300" --height="180" --list --column "id" --column "Please select" --hide-column=1 --text="What do you want to do?" "bright" "Change LCD Brightness" "gamma" "Manage LCD Gamma"); do
+
+case $mainsel in
+
+  "bright")
+    minbright=3
+    maxbright=$(cat /sys/devices/platform/twl4030-pwm0-bl/backlight/twl4030-pwm0-bl/max_brightness)
+    curbright=$(cat /sys/devices/platform/twl4030-pwm0-bl/backlight/twl4030-pwm0-bl/brightness)
+    device=/sys/devices/platform/twl4030-pwm0-bl/backlight/twl4030-pwm0-bl/brightness
+    if [ ! $1 ]; then
+      newbright=$(zenity --scale --text "set brightness" --min-value=$minbright --max-value=$maxbright --value=$curbright --step 1)
+    else
+      newbright=$1
+    fi
+    if [ $newbright ]; then
+        if [ $newbright -le $minbright ]; then newbright=$minbright; fi
+        if [ $newbright -ge $maxbright ]; then newbright=$maxbright; fi
+         echo $newbright > $device
+    fi;;
+
+   "gamma")
+    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;;
+esac
+done
\ No newline at end of file
index 898c0da..653c744 100644 (file)
Binary files a/recipes/pandora-system/pandora-scripts/pandorascripts.pnd and b/recipes/pandora-system/pandora-scripts/pandorascripts.pnd differ
index 458e3dd..c35a4c5 100755 (executable)
@@ -18,5 +18,5 @@
 %wheel ALL=(ALL) NOPASSWD: /usr/pandora/scripts/op_calibrate.sh
 %wheel ALL=(ALL) NOPASSWD: /usr/pandora/scripts/op_datetime.sh
 %wheel ALL=(ALL) NOPASSWD: /usr/pandora/scripts/op_wifi.sh
-%wheel ALL=(ALL) NOPASSWD: /usr/pandora/scripts/op_gammamanager.sh
+%wheel ALL=(ALL) NOPASSWD: /usr/pandora/scripts/op_lcdsettings.sh