JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
remove one item and add snapshot link
[spectrwm.git] / baraction.sh
1 #!/bin/sh
2 # $scrotwm$
3 print_cpu() {
4         echo -n "CPU: ${7}% User  ${8}% Nice  ${9}% Sys  ${10}% Int  ${11}% Idle     "
5 }
6
7 print_apm() {
8         BAT_STATUS=$1
9         BAT_LEVEL=$2
10         AC_STATUS=$3
11
12         if [ $AC_STATUS -ne 255 -o $BAT_STATUS -lt 4 ]; then
13                 if [ $AC_STATUS -eq 0 ]; then
14                         echo -n "on battery (${BAT_LEVEL}%)"
15                 else
16                         case $AC_STATUS in
17                         1)
18                                 AC_STRING="on AC: "
19                                 ;;
20                         2)
21                                 AC_STRING="on backup AC: "
22                                 ;;
23                         *)
24                                 AC_STRING=""
25                                 ;;
26                         esac;
27                         case $BAT_STATUS in
28                         4)
29                                 BAT_STRING="(no battery)"
30                                 ;;
31                         [0-3])
32                                 BAT_STRING="(battery ${BAT_LEVEL}%)"
33                                 ;;
34                         *)
35                                 BAT_STRING="(battery unknown)"
36                                 ;;
37                         esac;
38                 
39                         FULL="${AC_STRING}${BAT_STRING}"
40                         if [ "$FULL" != "" ]; then
41                                 echo -n "$FULL"
42                         fi
43                 fi
44         fi
45 }
46
47 while :; do
48         # you probably want to reduce the sleep below if you enable this
49         #print_cpu `/usr/sbin/iostat -C`
50         print_apm `/usr/sbin/apm -alb`
51         echo ""
52         sleep 59
53 done