This solution seems to work great (part of my .xinitrc):

    while true; do
            # Set root title
            sh $HOMEDIR/.xsetroot

            # Check battery level
            BATT=$( acpi -b | sed 's/.*[charging|unknown],
\([0-9]*\)%.*/\1/gi' )
            if [ $BATT -le 5 ]; then
                # Beep
                echo -e "\007" >/dev/tty10 && sleep 0.2
                echo -e "\007" >/dev/tty10 && sleep 0.2
                echo -e "\007" >/dev/tty10 && sleep 0.2
                # Blink
                echo 'on' > /proc/acpi/ibm/light && sleep 1
                echo 'off' > /proc/acpi/ibm/light
            fi

            # Update every 30s
            sleep 30s
    done &


It beeps 3 times and flashes the ThinkLight every 30s, in case the
battery level is below 5%.

--Danilo

Reply via email to