Skip to content

Commit

Permalink
Merge pull request #154 from ruiiiijiiiiang/fix/skip-unused-battery
Browse files Browse the repository at this point in the history
fixed issue with unused battery
  • Loading branch information
iinsertNameHere authored Nov 19, 2024
2 parents 2623f97 + 3ce1c8c commit 92259ca
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/catnaplib/platform/probe.nim
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,10 @@ proc getBattery*(): string =
# Collect all batterys
for dir in os.walk_dir(powerPath):
if re.match(os.last_path_part(dir.path), BATTERY_REGEX):
batterys.add((parseInt($dir.path[^1]), dir.path & "/"))
let batteryPath = dir.path & "/"
# Only check if battery has capacity and status
if fileExists(batteryPath & "capacity") and fileExists(batteryPath & "status"):
batterys.add((parseInt($dir.path[^1]), batteryPath))

if batterys.len < 1:
logError("No battery detected!")
Expand Down

0 comments on commit 92259ca

Please sign in to comment.