Skip to content

Commit

Permalink
[bat_linux] Fallback to computing (dis)charge rate
Browse files Browse the repository at this point in the history
Co-authored-by: Alexander Godlewski <[email protected]>
  • Loading branch information
arch-stack and Alexander Godlewski authored Nov 11, 2024
1 parent 579ebf7 commit c239dbb
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
Changelog
=========

Changes in 2.7.1
----------------

Fixed:

- [bat_linux] Fallback to computing bat (dis)charge rate in some cases

Changes in 2.7.0
----------------

Expand Down
6 changes: 6 additions & 0 deletions widgets/bat_linux.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
-- Copyright (C) 2017 David Udelson <[email protected]>
-- Copyright (C) 2017 Roberto <[email protected]>
-- Copyright (C) 2017 mutlusun <[email protected]>
-- Copyright (C) 2024 arch-stack <[email protected]>
--
-- This file is part of Vicious.
--
Expand Down Expand Up @@ -46,8 +47,13 @@ return helpers.setcall(function (format, warg)

-- Get current power usage in watt
local curpower = "N/A"

if battery.power_now then
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

-- Check if the battery is present
Expand Down

0 comments on commit c239dbb

Please sign in to comment.