File: monBat

package info (click to toggle)
xfce4-genmon-plugin 4.3.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 932 kB
  • sloc: ansic: 1,273; sh: 314; makefile: 129; perl: 21
file content (63 lines) | stat: -rwxr-xr-x 1,733 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/bin/bash

# An example script for the genmon plugin displaying information on the 2 batteries state

pres0=$(cat /proc/acpi/battery/BAT0/info | grep "present" | sed 's/\ \ */ /g' | cut -f2 -d" ")
if [ $pres0 != "no" ]
then
  max0=$(cat /proc/acpi/battery/BAT0/info | grep "last full capacity" | sed 's/\ \ */ /g' | cut -f4 -d" ")
  cur0=$(cat /proc/acpi/battery/BAT0/state | grep "remaining capacity" | sed 's/\ \ */ /g' | cut -f3 -d" ")
  pour0=$(echo "${cur0}00/${max0}" | bc)
fi

pres1=$(cat /proc/acpi/battery/BAT1/info | grep "present" | sed 's/\ \ */ /g' | cut -f2 -d" ")
if [ $pres1 != "no" ]
then
  max1=$(cat /proc/acpi/battery/BAT1/info | grep "last full capacity" | sed 's/\ \ */ /g' | cut -f4 -d" ")
  cur1=$(cat /proc/acpi/battery/BAT1/state | grep "remaining capacity" | sed 's/\ \ */ /g' | cut -f3 -d" ")
  pour1=$(echo "${cur1}00/${max1}" | bc)
fi

if [ $pres0 == "yes" ]
then
  echo "<tool>Bat0:$pour0%"
else
  echo "<tool>Bat0:-"
fi

if [ $pres1 == "yes" ]
then
  echo "Bat1:$pour1%"
else
  echo "Bat1:-"
fi

echo "AC:$(cat /proc/acpi/ac_adapter/AC/state | grep state | sed 's/\ \ */ /g' | cut -f2 -d" ")</tool>"

if [ $pres0 == "yes" ] && [ $pres1 == "yes" ]
then
  echo "<txt>$pour0%-$pour1%</txt>"
  pour=$(echo "(${cur0}00+${cur1}00)/(${max0}+${max1})" | bc)
elif [ $pres0 == "yes" ] && [ $pres1 == "no" ]
then
  echo "<txt>$pour0%</txt>"
  pour=$pour0
elif [ $pres0 == "no" ] && [ $pres1 == "yes" ]
then
  echo "<txt>$pour1%</txt>"
  pour=$pour1
else
  echo "<txt>-%</txt>"
  pour="0"
fi
#echo "<bar>$pour</bar>"

if [ $pour -le 10 ]
then
  echo "<img>/usr/local/share/icons/Tango/16x16/status/battery-caution.png</img>"
else
  echo "<img>/usr/local/share/icons/Tango/16x16/devices/battery.png</img>"
fi