ASUS Laptop 上的 LED

我這台 ASUS 的 Laptop M24NE C5PDR 上面有四個 LED 燈,分別代表了 power, battery, email, wireless ,在使用 windows driver 時會自動控制這幾個燈 號,很幸運的,從 Linux 下面也可以透過 asus_acpi 控制這幾個燈號,例如要 讓 email 燈亮,只要 echo 1 > /proc/acpi/asus/mled 就可以,所以我分 別設定了有新郵件時,讓 mled 亮,搜尋到 AP 時,讓 wled 亮,非常的方便 ;-)

底下是 wifi led 設定 script:

#!/bin/sh
#set -x
WIFI_STATE=off
TOGGLE=false
trap 'leave' INT QUIT TERM

leave()
{
    echo 0 > /proc/acpi/asus/wled
    echo "Wifi Led Monitor: off"
    exit 0
}
while true
do
    if [ `cat /proc/net/wireless |sed '1,2d'|awk '{print $4}'|bc` -gt 0 ]
    then
        if [ $WIFI_STATE = off ]
        then
            WIFI_STATE=on
            TOGGLE=true
        else
            TOGGLE=false
        fi
    elif [ $WIFI_STATE = on ]
    then
        WIFI_STATE=off
        TOGGLE=true
    fi

    if [ $TOGGLE = true ]
    then
        if [ $WIFI_STATE = on ]
        then
            echo 1 > /proc/acpi/asus/wled
        else
            echo 0 > /proc/acpi/asus/wled
        fi
    fi
    sleep 1
done