Add a TODO item - track energy usage rate
[khatus.git] / src / awk / exe / parse_upower.awk
1 # When parsing 'upower --dump'
2 /^Device:[ \t]+/ {
3 device["path"] = $2
4 next
5 }
6
7 # When parsing 'upower --monitor-detail'
8 /^\[[0-9]+:[0-9]+:[0-9]+\.[0-9]+\][ \t]+device changed:[ \t]+/ {
9 device["path"] = $4
10 next
11 }
12
13 # BEGIN battery
14 / battery/ && device["path"] {
15 device["is_battery"] = 1
16 next
17 }
18
19 / state:/ && device["is_battery"] {
20 device["battery_state"] = $2
21 next
22 }
23
24 / percentage:/ && device["is_battery"] {
25 device["battery_percentage"] = $2
26 sub("%$", "", device["battery_percentage"])
27 next
28 }
29
30 /^$/ && device["is_battery"] {
31 print("battery_state" , device["battery_state"])
32 print("battery_percentage", device["battery_percentage"])
33 }
34 # END battery
35
36 # BEGIN line-power
37 / line-power/ && device["path"] {
38 device["is_line_power"] = 1
39 next
40 }
41
42 / online:/ && device["is_line_power"] {
43 device["line_power_online"] = $2
44 next
45 }
46
47 /^$/ && device["is_line_power"] {
48 print("line_power", device["line_power_online"])
49 }
50 # END line-power
51
52 /^$/ {
53 delete device
54 next
55 }
This page took 0.077854 seconds and 4 git commands to generate.