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 sed -i "s/.*pandora::sd1.*/pandora::sd1 none/g" /etc/default/leds
71 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
72 echo mmc1 > /sys/class/leds/pandora\:\:sd2/trigger
73 sed -i "s/.*pandora::sd2.*/pandora::sd2 mmc1/g" /etc/default/leds
75 echo none > /sys/class/leds/pandora\:\:sd2/trigger
76 sed -i "s/.*pandora::sd2.*/pandora::sd2 none/g" /etc/default/leds
81 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
82 echo bluetooth > /sys/class/leds/pandora\:\:bluetooth/trigger
83 sed -i "s/.*pandora::bluetooth.*/pandora::bluetooth bluetooth/g" /etc/default/leds
84 if hciconfig "$INTERFACE" | grep UP &>/dev/null
86 echo default-on > /sys/class/leds/pandora\:\:bluetooth/trigger
87 echo 255 > /sys/class/leds/pandora\:\:bluetooth/brightness
90 echo none > /sys/class/leds/pandora\:\:bluetooth/trigger
91 sed -i "s/.*pandora::bluetooth.*/pandora::bluetooth none/g" /etc/default/leds
96 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
97 sed -i "s/.*pandora::wifi.*/pandora::wifi phy0radio/g" /etc/default/leds
98 if [ "`lsmod | grep wl1251`" ]
101 for a in `seq 20` ; do
102 if [ -e /sys/class/net/wlan0 ] ; then
103 phy_idx=$(cat /sys/class/net/wlan0/phy80211/index)
110 # restore phy related LED triggers (they come from mac80211.ko)
111 if [ -e /sys/class/leds/ ] ; then
112 for led in /sys/class/leds/* ; do
113 trigger=$(grep "$(basename $led)" /etc/default/leds | grep phy | \
114 awk '{print $2}' | sed -e 's/.*phy[0-9]*\(.*\)/\1/')
115 if [ "x$trigger" != "x" ] ; then
116 echo "phy${phy_idx}$trigger" > "$led/trigger"
121 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
123 echo none > /sys/class/leds/pandora\:\:wifi/trigger
124 sed -i "s/.*pandora::wifi.*/pandora::wifi none/g" /etc/default/leds