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 LED_CONF="/etc/pandora/conf/led.conf"
8 grep -q HighPowerLED $LED_CONF || echo "LowPowerLED:16" >> $LED_CONF
9 grep -q LowPowerLED $LED_CONF || echo "HighPowerLED:255" >> $LED_CONF
10 grep -q IdleLED $LED_CONF || echo "IdleLED:48" >> $LED_CONF
12 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" \
13 "normal" "Set Power LED Brightness (normal mode)" \
14 "power" "Set Power LED Brightness (powersave)" \
15 "idle" "Set Power LED Brightness (screen off/idle)" \
16 "sd1" "Enable / Disable SD1 LED" \
17 "sd2" "Enable / Disable SD2 LED" \
18 "wifi" "Enable / Disable WiFi LED" \
19 "bt" "Enable / Disable Bluetooth LED" \
20 --ok-label="Change Setting" --cancel-label="Exit"); do
25 curbright=$(cat $LED_CONF | grep HighPowerLED: | awk -F\: '{print $2}')
26 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
28 echo $curbright > /sys/class/leds/pandora\:\:power/brightness
30 sed -i "s/.*HighPowerLED.*/HighPowerLED:$curbright/g" $LED_CONF
31 zenity --info --title="Power LED Brightness Set" --text "The new power LED Brightness setting has been saved." --timeout 6
35 normbright=$(cat /sys/class/leds/pandora\:\:power/brightness)
36 curbright=$(cat $LED_CONF | grep LowPowerLED: | awk -F\: '{print $2}')
37 echo $curbright > /sys/class/leds/pandora\:\:power/brightness
38 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
40 echo $curbright > /sys/class/leds/pandora\:\:power/brightness
42 sed -i "s/.*LowPowerLED.*/LowPowerLED:$curbright/g" $LED_CONF
43 zenity --info --title="Power LED Brightness Set" --text "The new power LED Brightness setting (Powersave mode) has been saved." --timeout 6
44 echo $normbright > /sys/class/leds/pandora\:\:power/brightness
48 normbright=$(cat /sys/class/leds/pandora\:\:power/brightness)
49 curbright=$(cat $LED_CONF | grep IdleLED: | awk -F\: '{print $2}')
50 echo $curbright > /sys/class/leds/pandora\:\:power/brightness
51 while newbright=$(zenity --scale --text "Set brightness of Power LED (screen off/idle mode)" --min-value=0 --max-value=255 --value=$curbright --step 1 --ok-label="Set new brightness" --cancel-label="Save and exit"); do
53 echo $curbright > /sys/class/leds/pandora\:\:power/brightness
55 sed -i "s/.*IdleLED.*/IdleLED:$curbright/g" $LED_CONF
56 zenity --info --title="Power LED Brightness Set" --text "The new power LED Brightness setting (screen off/idle mode) has been saved." --timeout 6
57 echo $normbright > /sys/class/leds/pandora\:\:power/brightness
61 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
62 echo mmc0 > /sys/class/leds/pandora\:\:sd1/trigger
63 sed -i "s/.*pandora::sd1.*/pandora::sd1 mmc0/g" /etc/default/leds
65 echo none > /sys/class/leds/pandora\:\:sd1/trigger
66 echo 0 > /sys/class/leds/pandora\:\:sd1/brightness
67 sed -i "s/.*pandora::sd1.*/pandora::sd1 none/g" /etc/default/leds
72 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
73 echo mmc1 > /sys/class/leds/pandora\:\:sd2/trigger
74 sed -i "s/.*pandora::sd2.*/pandora::sd2 mmc1/g" /etc/default/leds
76 echo none > /sys/class/leds/pandora\:\:sd2/trigger
77 echo 0 > /sys/class/leds/pandora\:\:sd2/brightness
78 sed -i "s/.*pandora::sd2.*/pandora::sd2 none/g" /etc/default/leds
83 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
84 echo bluetooth > /sys/class/leds/pandora\:\:bluetooth/trigger
85 sed -i "s/.*pandora::bluetooth.*/pandora::bluetooth bluetooth/g" /etc/default/leds
86 if hciconfig "$INTERFACE" | grep UP &>/dev/null
88 echo default-on > /sys/class/leds/pandora\:\:bluetooth/trigger
89 echo 255 > /sys/class/leds/pandora\:\:bluetooth/brightness
92 echo none > /sys/class/leds/pandora\:\:bluetooth/trigger
93 echo 0 > /sys/class/leds/pandora\:\:bluetooth/brightness
94 sed -i "s/.*pandora::bluetooth.*/pandora::bluetooth none/g" /etc/default/leds
99 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
100 sed -i "s/.*pandora::wifi.*/pandora::wifi phy0radio/g" /etc/default/leds
101 if [ "`lsmod | grep wl1251`" ]
104 for a in `seq 20` ; do
105 if [ -e /sys/class/net/wlan0 ] ; then
106 phy_idx=$(cat /sys/class/net/wlan0/phy80211/index)
113 # restore phy related LED triggers (they come from mac80211.ko)
114 if [ -e /sys/class/leds/ ] ; then
115 for led in /sys/class/leds/* ; do
116 trigger=$(grep "$(basename $led)" /etc/default/leds | grep phy | \
117 awk '{print $2}' | sed -e 's/.*phy[0-9]*\(.*\)/\1/')
118 if [ "x$trigger" != "x" ] ; then
119 echo "phy${phy_idx}$trigger" > "$led/trigger"
124 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
126 echo none > /sys/class/leds/pandora\:\:wifi/trigger
127 echo 0 > /sys/class/leds/pandora\:\:wifi/brightness
128 sed -i "s/.*pandora::wifi.*/pandora::wifi none/g" /etc/default/leds