[bat_linux] Fallback to computing (dis)charge rate
Co-authored-by: Alexander Godlewski <alex@arch.fun>
This commit is contained in:
parent
579ebf772c
commit
c239dbb2e4
|
@ -1,6 +1,13 @@
|
||||||
Changelog
|
Changelog
|
||||||
=========
|
=========
|
||||||
|
|
||||||
|
Changes in 2.7.1
|
||||||
|
----------------
|
||||||
|
|
||||||
|
Fixed:
|
||||||
|
|
||||||
|
- [bat_linux] Fallback to computing bat (dis)charge rate in some cases
|
||||||
|
|
||||||
Changes in 2.7.0
|
Changes in 2.7.0
|
||||||
----------------
|
----------------
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
-- Copyright (C) 2017 David Udelson <dru5@cornell.edu>
|
-- Copyright (C) 2017 David Udelson <dru5@cornell.edu>
|
||||||
-- Copyright (C) 2017 Roberto <empijei@users.noreply.github.com>
|
-- Copyright (C) 2017 Roberto <empijei@users.noreply.github.com>
|
||||||
-- Copyright (C) 2017 mutlusun <mutlusun@github.com>
|
-- Copyright (C) 2017 mutlusun <mutlusun@github.com>
|
||||||
|
-- Copyright (C) 2024 arch-stack <arch-stack@github.com>
|
||||||
--
|
--
|
||||||
-- This file is part of Vicious.
|
-- This file is part of Vicious.
|
||||||
--
|
--
|
||||||
|
@ -46,8 +47,13 @@ return helpers.setcall(function (format, warg)
|
||||||
|
|
||||||
-- Get current power usage in watt
|
-- Get current power usage in watt
|
||||||
local curpower = "N/A"
|
local curpower = "N/A"
|
||||||
|
|
||||||
if battery.power_now then
|
if battery.power_now then
|
||||||
curpower = string.format("%.2f", tonumber(battery.power_now) /1000000)
|
curpower = string.format("%.2f", tonumber(battery.power_now) /1000000)
|
||||||
|
elseif battery.current_now and battery.voltage_now then
|
||||||
|
local current = tonumber(battery.current_now)
|
||||||
|
local voltage = tonumber(battery.voltage_now)
|
||||||
|
curpower = string.format("%.2f", current * voltage / 10^12)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Check if the battery is present
|
-- Check if the battery is present
|
||||||
|
|
Loading…
Reference in New Issue