Battery 451 B

123456789101112131415161718192021222324252627282930
  1. #!/bin/rc
  2. if(! test -f /mnt/apm/battery){
  3. echo no apm >[1=2]
  4. exit 'no apm'
  5. }
  6. cd /mnt/acme/new
  7. echo name /dev/apm >ctl
  8. echo dump Battery >ctl
  9. awkscript='
  10. NR==1 {
  11. if($3 != -1)
  12. printf("%d%% %d:%02d %s", $2, $3/3600, ($3/60)%60, $1);
  13. else
  14. printf("%d%% %s", $2, $1);
  15. }
  16. '
  17. fn chk {
  18. what=`{awk $awkscript /mnt/apm/battery}
  19. echo cleartag >ctl || exit die
  20. echo clean >ctl || exit die
  21. echo ' '^$"what >tag || exit die
  22. }
  23. chk
  24. while(sleep 60)
  25. chk