battery level from command line

Steve Siegfried sos at zjod.net
Fri Mar 14 21:41:42 UTC 2008


Mike -- EMAIL IGNORED wrote:
> 
> On my FC8 laptop, is there a way to determine
> the battery level from the command line, without
> a GUI?
> 
> Thanks,
> Mike.

Yeah, there is.  See attached shar file.  -S



#!/bin/sh
# This is a shell archive (produced by GNU sharutils 4.6.1).
# To extract the files from this archive, save it to some FILE, remove
# everything before the `#!/bin/sh' line above, then type `sh FILE'.
#
lock_dir=_sh01572
# Made on 2008-03-14 16:38 CDT by <root at sos>.
# Source directory was `/spare/SOSLT/home/n12691'.
#
# Existing files will *not* be overwritten, unless `-c' is specified.
#
# This shar contains:
# length mode       name
# ------ ---------- ------------------------------------------
#    915 -rwx------ bin/watchbattery
#
MD5SUM=${MD5SUM-md5sum}
f=`${MD5SUM} --version | egrep '^md5sum .*(core|text)utils'`
test -n "${f}" && md5check=true || md5check=false
${md5check} || \
  echo 'Note: not verifying md5sums.  Consider installing GNU coreutils.'
save_IFS="${IFS}"
IFS="${IFS}:"
gettext_dir=FAILED
locale_dir=FAILED
first_param="$1"
for dir in $PATH
do
  if test "$gettext_dir" = FAILED && test -f $dir/gettext \
     && ($dir/gettext --version >/dev/null 2>&1)
  then
    case `$dir/gettext --version 2>&1 | sed 1q` in
      *GNU*) gettext_dir=$dir ;;
    esac
  fi
  if test "$locale_dir" = FAILED && test -f $dir/shar \
     && ($dir/shar --print-text-domain-dir >/dev/null 2>&1)
  then
    locale_dir=`$dir/shar --print-text-domain-dir`
  fi
done
IFS="$save_IFS"
if test "$locale_dir" = FAILED || test "$gettext_dir" = FAILED
then
  echo=echo
else
  TEXTDOMAINDIR=$locale_dir
  export TEXTDOMAINDIR
  TEXTDOMAIN=sharutils
  export TEXTDOMAIN
  echo="$gettext_dir/gettext -s"
fi
if (echo "testing\c"; echo 1,2,3) | grep c >/dev/null
then if (echo -n test; echo 1,2,3) | grep n >/dev/null
     then shar_n= shar_c='
'
     else shar_n=-n shar_c= ; fi
else shar_n= shar_c='\c' ; fi
f=shar-touch.$$
st1=200112312359.59
st2=123123592001.59
st2tr=123123592001.5 # old SysV 14-char limit
st3=1231235901

if touch -am -t ${st1} ${f} >/dev/null 2>&1 && \
   test ! -f ${st1} && test -f ${f}; then
  shar_touch='touch -am -t $1$2$3$4$5$6.$7 "$8"'

elif touch -am ${st2} ${f} >/dev/null 2>&1 && \
   test ! -f ${st2} && test ! -f ${st2tr} && test -f ${f}; then
  shar_touch='touch -am $3$4$5$6$1$2.$7 "$8"'

elif touch -am ${st3} ${f} >/dev/null 2>&1 && \
   test ! -f ${st3} && test -f ${f}; then
  shar_touch='touch -am $3$4$5$6$2 "$8"'

else
  shar_touch=:
  echo
  ${echo} 'WARNING: not restoring timestamps.  Consider getting and'
  ${echo} 'installing GNU `touch'\'', distributed in GNU File Utilities...'
  echo
fi
rm -f ${st1} ${st2} ${st2tr} ${st3} ${f}
#
if test ! -d ${lock_dir}
then : ; else ${echo} 'lock directory '${lock_dir}' exists'
  exit 1
fi
if mkdir ${lock_dir}
then ${echo} 'x - created lock directory `'${lock_dir}\''.'
else ${echo} 'x - failed to create lock directory `'${lock_dir}\''.'
  exit 1
fi
# ============= bin/watchbattery ==============
if test ! -d 'bin'; then
  mkdir 'bin'
if test $? -eq 0
then ${echo} 'x - created directory `bin'\''.'
else ${echo} 'x - failed to create directory `bin'\''.'
  exit 1
fi
fi
if test -f 'bin/watchbattery' && test "$first_param" != -c; then
  ${echo} 'x -SKIPPING bin/watchbattery (file already exists)'
else
${echo} 'x - extracting bin/watchbattery (binary)'
  sed 's/^X//' << 'SHAR_EOF' | uudecode &&
begin 600 bin/watchbattery
M(R$O8FEN+VMS:`H*=VAI;&4@=')U90ID;PH@(&-L96%R"B`@9&%T90H@(&5C
M:&\*("!!0SU at 8V%T("]P<F]C+V%C<&DO86-?861A<'1E<B]!0R]S=&%T92!\
M(&=R97`@(G-T871E.B(@?"!A=VL@)WL@<')I;G0@)#(@?2=@"B`@:68 at 6R`B
M6"1!0R(@/2`B6&]F9BUL:6YE(B!="B`@=&AE;B!C870 at +W!R;V,O86-P:2]B
M871T97)Y+T)!5#`O<W1A=&4*("`@("`@(&9L;V%T(%)!5$4]8&-A="`O<')O
M8R]A8W!I+V)A='1E<GDO0D%4,"]S=&%T92!\(&=R97`@(EYP<F5S96YT(')A
M=&4Z(B!\(&%W:R`G>R!P<FEN="`D,R!])V`*("`@("`@(&9L;V%T(%)%34%)
M3CU at 8V%T("]P<F]C+V%C<&DO8F%T=&5R>2]"050P+W-T871E('P at 9W)E<"`B
M7G)E;6%I;FEN9R!C87!A8VET>3HB('P at 87=K("=[('!R:6YT("0S('TG8`H@
M("`@("`@:6YT96=E<B!(3U524STD4D5-04E.+R12051%"B`@("`@("!F;&]A
M="!&34E./21214U!24XM*"@D2$]54E,J)%)!5$4I*0H@("`@("`@:6YT96=E
M<B!-24X])$9-24XJ-C`*("`@("`@(&EN=&5G97(@34E./21-24XO)%)!5$4*
M("`@("`@(&EF(%L@)$U)3B`M;'0@,3`@70H@("`@("`@=&AE;B!E8VAO("(;
M73`[0F%T=#H@)$A/55)3.C`D34E.!T)A='1E<GD@;&5F=#H@)$A/55)3.C`D
M34E.(@H@("`@("`@96QS92!E8VAO("(;73`[0F%T=#H@)$A/55)3.B1-24X'
M0F%T=&5R>2!L969T.B`D2$]54E,Z)$U)3B(*("`@("`@(&9I"B`@96QS92!C
M870 at +W!R;V,O86-P:2]B871T97)Y+T)!5#`O<W1A=&4*("`@("`@($-(05)'
M13U at 8V%T("]P<F]C+V%C<&DO8F%T=&5R>2]"050P+W-T871E('P at 9W)E<"`B
M7F-H87)G:6YG('-T871E(B!\(&%W:R`G>R!P<FEN="`D,R!])V`*("`@("`@
M(&5C:&\@(AM=,#M!+T,'3VX at 02]#('!O=V5R("@D0TA!4D=%*2(*("!F:0H@
/('-L965P(#,P"F1O;F4*
`
end
SHAR_EOF
  (set 20 07 04 14 00 29 41 'bin/watchbattery'; eval "$shar_touch") &&
  chmod 0700 'bin/watchbattery'
if test $? -ne 0
then ${echo} 'restore of bin/watchbattery failed'
fi
  if ${md5check}
  then (
       ${MD5SUM} -c >/dev/null 2>&1 || ${echo} 'bin/watchbattery: MD5 check failed'
       ) << SHAR_EOF
2691bd49f6d917f2c92a9ea8f3735f86  bin/watchbattery
SHAR_EOF
  else
test `LC_ALL=C wc -c < 'bin/watchbattery'` -ne 915 && \
  ${echo} 'restoration warning:  size of bin/watchbattery is not 915'
  fi
fi
if rm -fr ${lock_dir}
then ${echo} 'x - removed lock directory `'${lock_dir}\''.'
else ${echo} 'x - failed to remove lock directory `'${lock_dir}\''.'
  exit 1
fi
exit 0




More information about the users mailing list