Thursday, March 30, 2017

check battery from command line - linux ubuntu

~/learn/battery.upower.markdown.html
 1 
 2 # check battery from command line
 3 
 4 There are at least 2 command you can use,
 5  each will tell the percentage of battery.
 6 
 7     acpi
 8     upower
 9 
10 I made a video to demo it, if needed,
11  you can view the youtube video:
12 [how to get battery status](https://youtu.be/1De5MzqBz7I)
13 
14 By the way, I am using Ubuntu 16.04.
15 
16 ## acpi
17 
18     acpi
19 
20 This is what I got:
21 
22     Battery 0: Charging, 86%, 00:12:32 until charged
23 
24 
25 If you have no acpi installed, use the following to install
26 
27     sudo apt-get install acpi
28 
29 ## upower
30 
31     upower -e
32 
33 or
34 
35     upower --enumerate
36 
37 
38 As example, this is output on my laptop:
39 
40     /org/freedesktop/UPower/devices/line_power_AC
41     /org/freedesktop/UPower/devices/battery_BAT1
42     /org/freedesktop/UPower/devices/DisplayDevice
43 
44 
45 
46 ### Then use one of the above output in the following command
47 
48 
49     upower  -i  /org/freedesktop/UPower/devices/battery_BAT1
50 
51 
52 This is my output this time:
53 
54       native-path:          BAT1
55       vendor:               SANYO
56       model:                45N1767
57       serial:               1097
58       power supply:         yes
59       updated:              Thu 30 Mar 2017 05:00:18 PM CST (62 seconds ago)
60       has history:          yes
61       has statistics:       yes
62       battery
63         present:             yes
64         rechargeable:        yes
65         state:               charging
66         warning-level:       none
67         energy:              24.21 Wh
68         energy-empty:        0 Wh
69         energy-full:         40.09 Wh
70         energy-full-design:  47.52 Wh
71         energy-rate:         28.254 W
72         voltage:             11.753 V
73         time to full:        33.7 minutes
74         percentage:          60%
75         capacity:            84.3645%
76         technology:          lithium-ion
77         icon-name:          'battery-full-charging-symbolic'
78       History (charge):
79         1490864418  60.000  charging
80       History (rate):
81         1490864418  28.254  charging
82 
83 

No comments:

Post a Comment