2 # Released under the GPL
3 # LED-Settings, v1.0, written by Michael Mrozek aka EvilDragon 2013.
5 . /usr/pandora/scripts/op_common.sh
7 while mainsel=$(zenity --title="LED-Settings" --width="400" --height="370" --list --column "id" --column "Please select" --hide-column=1 --text="Welcome to the LED-Settings-Dialogue.\n\nWhat do you want to do?\n" "normal" "Set Power LED Brightness (normal mode)" "power" "Set Power LED Brightness (powersave)" "sd1" "Enable / Disable SD1 LED" "sd2" "Enable / Disable SD2 LED" "wifi" "Enable / Disable WiFi LED" "bt" "Enable / Disable Bluetooth LED" --ok-label="Change Setting" --cancel-label="Exit"); do
12 curbright=$(cat /etc/pandora/conf/led.conf | grep HighPowerLED: | awk -F\: '{print $2}')
13 while newbright=$(zenity --scale --text "Set brightness of Power LED (normal mode)" --min-value=0 --max-value=255 --value=$curbright --step 1 --ok-label="Set new brightness" --cancel-label="Save and exit"); do
15 echo $curbright > /sys/class/leds/pandora\:\:power/brightness
17 sed -i "s/.*HighPowerLED.*/HighPowerLED:$curbright/g" /etc/pandora/conf/led.conf
18 zenity --info --title="Power LED Brightness Set" --text "The new power LED Brightness setting has been saved." --timeout 6
22 normbright=$(cat /sys/class/leds/pandora\:\:power/brightness)
23 curbright=$(cat /etc/pandora/conf/led.conf | grep LowPowerLED: | awk -F\: '{print $2}')
24 echo $curbright > /sys/class/leds/pandora\:\:power/brightness
25 while newbright=$(zenity --scale --text "Set brightness of Power LED (Powersave mode)" --min-value=0 --max-value=255 --value=$curbright --step 1 --ok-label="Set new brightness" --cancel-label="Save and exit"); do
27 echo $curbright > /sys/class/leds/pandora\:\:power/brightness
29 sed -i "s/.*LowPowerLED.*/LowPowerLED:$curbright/g" /etc/pandora/conf/led.conf
30 zenity --info --title="Power LED Brightness Set" --text "The new power LED Brightness setting (Powersave mode) has been saved." --timeout 6
31 echo $normbright > /sys/class/leds/pandora\:\:power/brightness
35 if zenity --question --title="Enable / Disable LED?" --text="Do you want to enable or disable the LED for SD Card 1?" --ok-label="Enable it" --cancel-label="Disable it"; then
36 echo mmc0 > /sys/class/leds/pandora\:\:sd1/trigger
37 sed -i "s/.*pandora::sd1.*/pandora::sd1 mmc0/g" /etc/default/leds
39 echo none > /sys/class/leds/pandora\:\:sd1/trigger
40 sed -i "s/.*pandora::sd1.*/pandora::sd1 none/g" /etc/default/leds
45 if zenity --question --title="Enable / Disable LED?" --text="Do you want to enable or disable the LED for SD Card 2?" --ok-label="Enable it" --cancel-label="Disable it"; then
46 echo mmc1 > /sys/class/leds/pandora\:\:sd2/trigger
47 sed -i "s/.*pandora::sd2.*/pandora::sd2 mmc1/g" /etc/default/leds
49 echo none > /sys/class/leds/pandora\:\:sd2/trigger
50 sed -i "s/.*pandora::sd2.*/pandora::sd2 none/g" /etc/default/leds
55 if zenity --question --title="Enable / Disable LED?" --text="Do you want to enable or disable the LED for the Bluetooth LED?" --ok-label="Enable it" --cancel-label="Disable it"; then
56 echo bluetooth > /sys/class/leds/pandora\:\:bluetooth/trigger
57 sed -i "s/.*pandora::bluetooth.*/pandora::bluetooth bluetooth/g" /etc/default/leds
58 if hciconfig "$INTERFACE" | grep UP &>/dev/null
60 echo default-on > /sys/class/leds/pandora\:\:bluetooth/trigger
61 echo 255 > /sys/class/leds/pandora\:\:bluetooth/brightness
64 echo none > /sys/class/leds/pandora\:\:bluetooth/trigger
65 sed -i "s/.*pandora::bluetooth.*/pandora::bluetooth none/g" /etc/default/leds
70 if zenity --question --title="Enable / Disable LED?" --text="Do you want to enable or disable the WiFi LED?" --ok-label="Enable it" --cancel-label="Disable it"; then
71 sed -i "s/.*pandora::wifi.*/pandora::wifi phy0radio/g" /etc/default/leds
72 if [ "`lsmod | grep wl1251`" ]
75 for a in `seq 20` ; do
76 if [ -e /sys/class/net/wlan0 ] ; then
77 phy_idx=$(cat /sys/class/net/wlan0/phy80211/index)
84 # restore phy related LED triggers (they come from mac80211.ko)
85 if [ -e /sys/class/leds/ ] ; then
86 for led in /sys/class/leds/* ; do
87 trigger=$(grep "$(basename $led)" /etc/default/leds | grep phy | \
88 awk '{print $2}' | sed -e 's/.*phy[0-9]*\(.*\)/\1/')
89 if [ "x$trigger" != "x" ] ; then
90 echo "phy${phy_idx}$trigger" > "$led/trigger"
95 zenity --info --title="WiFi LED Set" --text "The WiFi LED has been enabled.\nPlease note: You need to disable and re-enable WiFi before it switches on again." --timeout 6
97 echo none > /sys/class/leds/pandora\:\:wifi/trigger
98 sed -i "s/.*pandora::wifi.*/pandora::wifi none/g" /etc/default/leds