Skip to content

Commit

Permalink
Merge pull request #10 from kdhansen/kinetic
Browse files Browse the repository at this point in the history
Fix for systems without a power_now file when unplugged.
  • Loading branch information
k-okada authored Nov 16, 2019
2 parents 605a256 + 14df25d commit 67bb14d
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion laptop_battery_monitor/scripts/laptop_battery.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,11 @@ def _check_battery_state(_battery_acpi_path):
rv.power_supply_status = state_to_val.get(state, 0)

if os.path.exists(_battery_acpi_path + '/power_now'):
rv.current = _read_number(_battery_acpi_path + '/power_now')/10e5 / \
try:
rv.current = _read_number(_battery_acpi_path + '/power_now')/10e5 / \
_read_number(_battery_acpi_path + '/voltage_now')
except IOError:
rv.current = 0
else:
rv.current = _read_number(_battery_acpi_path + '/current_now')/10e5

Expand Down

0 comments on commit 67bb14d

Please sign in to comment.