Shell script for android battery notifications

\#!/bin/bash

while [ 1 ]; 

do 

if [ "`/usr/bin/lsusb | grep 'High'`" != "" ]; then

    notify-send "Droid Info" "Battery`~/dev/android-sdk-linux_x86/platform-tools/adb shell dumpsys battery | grep 'level'`"  

fi

 sleep 10m  

done

you'll need the android sdk

HTC shows up as High Tech Computer Corp. in the lsusb results. So I just grep 'High'

2 comments · 75% upvoted · other discussions

comments

tytdfn

Just curious what do you use this for? Doesn't the battery charge while the phone is plugged into the computer?

Master_Rux [OP]

It's just a shell script that uses adb from the Android sdk to get the battery info every ten minutes from the Droid when it is plugged into the computer.