tImproved battery notification - scripts - various script and utils
 (HTM) git clone git://z3bra.org/scripts
 (DIR) Log
 (DIR) Files
 (DIR) Refs
       ---
 (DIR) commit f04cecc3a072248cfee17911953e0ab234c16270
 (DIR) parent f9eb8574d39e0cbcb5aff083e8dd1c62570aab02
 (HTM) Author: z3bra <willy@mailoo.org>
       Date:   Tue, 25 Mar 2014 08:22:08 +0100
       
       Improved battery notification
       
       Diffstat:
         M battery.sh                          |      24 +++++++++++-------------
       
       1 file changed, 11 insertions(+), 13 deletions(-)
       ---
 (DIR) diff --git a/battery.sh b/battery.sh
       t@@ -7,10 +7,14 @@ BATC=`cat /sys/class/power_supply/BAT1/capacity`
        BATS=`cat /sys/class/power_supply/BAT1/status`
        
        # Run this if sound is enabled
       -BELL_SOUND="beep -f1000 -l200 -D50"
       +sbell () { 
       +    beep -f 1000 -l 200 -D 50
       +}
        
        # and this in case of no sound enabled
       -BELL_VISUAL="$HOME/bin/popup battery $BATC%"
       +vbell () {
       +    $HOME/bin/popup "\f1battery $BATC%"
       +}
        
        usage () {
            echo "usage: `basename $0` [<low> <critical> <dead>]"
       t@@ -18,14 +22,10 @@ usage () {
        }
        
        level () {
       -    echo $BATC%
       +    echo "$BATC%"
            exit 0
        }
        
       -# check wether speakers are on or not
       -amixer get Master| grep -o '\[on\]'>/dev/null
       -SOUND=$?
       -
        # If no argurments, return battery level
        test "$#" -eq 0 && level
        
       t@@ -35,10 +35,8 @@ test "$#" -lt 3 && usage
        # if battery is charging, do not alert user
        test "$BATS" == "Charging" && exit
        
       -if test $SOUND -eq 0; then
       -    test $BATC -lt $1 && $BELL_SOUND  # one bip for level <low>
       -    test $BATC -lt $2 && $BELL_SOUND  # two bip for level <critical>
       -    test $BATC -lt $3 && $BELL_SOUND  # battery is <dead>, bip 3 times
       -fi
       +test $BATC -lt $1 && sbell  # one bip for level <low>
       +test $BATC -lt $2 && sbell  # two bip for level <critical>
       +test $BATC -lt $3 && sbell  # battery is <dead>, bip 3 times
        
       -test $BATC -lt $1 && $BELL_VISUAL # popup a notification under <low> level
       +test $BATC -lt $1 && vbell # popup a notification under <low> level