We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents 2623f97 + 3ce1c8c commit 92259caCopy full SHA for 92259ca
src/catnaplib/platform/probe.nim
@@ -204,7 +204,10 @@ proc getBattery*(): string =
204
# Collect all batterys
205
for dir in os.walk_dir(powerPath):
206
if re.match(os.last_path_part(dir.path), BATTERY_REGEX):
207
- batterys.add((parseInt($dir.path[^1]), dir.path & "/"))
+ let batteryPath = dir.path & "/"
208
+ # Only check if battery has capacity and status
209
+ if fileExists(batteryPath & "capacity") and fileExists(batteryPath & "status"):
210
+ batterys.add((parseInt($dir.path[^1]), batteryPath))
211
212
if batterys.len < 1:
213
logError("No battery detected!")
0 commit comments