Skip to content

Commit

Permalink
fix: error on windows with no battery (#51)
Browse files Browse the repository at this point in the history
* feat(parsers): move all parsers to their own submodule (#43)

BREAKING CHANGE: Parser modules have been moved

Add `check` functions to all parser modules

* fix: Termux compatible `is_readable_directory` function (#42)

* feat(util): use test command to check directory

* fix: use single quotes in util/file.lua

* feat(util): add type hints and documentation, remove old function

* feat(parsers): move all parsers to their own submodule (#43)

BREAKING CHANGE: Parser modules have been moved

Add `check` functions to all parser modules

* feat(util): use old "readable directory" method when not in Termux

* docs: start adding type definitions

* docs: consistent doc-comment

* fix(parsers/powershell): default to 2 when no batteries
  • Loading branch information
Agent-E11 authored Jul 21, 2024
1 parent f51e230 commit bbee969
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lua/battery/parsers/powershell.lua
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,10 @@ local function parse_powershell_battery_info(result, battery_status)

-- only the first battery is used to determine charging or not
-- since they should all be the same
local status = batteries[1]['BatteryStatus']
local status = (
batteries[1] and batteries[1]['BatteryStatus'] -- Get BatteryStatus if present
or 2 -- Default to 2 ("AC Power")
)
local ac_power = status_code_to_ac_power[status]

if count > 0 then
Expand Down

0 comments on commit bbee969

Please sign in to comment.