added batmon usage for battery output
This commit is contained in:
parent
2cff444a6b
commit
2df81dc670
2 changed files with 5 additions and 16 deletions
|
@ -1,6 +1,5 @@
|
|||
import strutils
|
||||
import osproc
|
||||
import jsony
|
||||
import ../../../batmon/src/batmon
|
||||
|
||||
import ../common
|
||||
import ../common/colours
|
||||
|
@ -19,15 +18,6 @@ const alert_bg = yellow
|
|||
const med_fg = green
|
||||
#const med_bg = black
|
||||
|
||||
type
|
||||
Battery = object
|
||||
charge: float
|
||||
status: string
|
||||
charging: bool
|
||||
|
||||
proc postHook(b: var Battery) =
|
||||
b.charging = b.status == "Charging"
|
||||
|
||||
proc batteryExists(): bool =
|
||||
try:
|
||||
let state = strip(readFile("/sys/class/power_supply/" & battery & "/present"))
|
||||
|
@ -113,11 +103,9 @@ proc getBatteryInfo() =
|
|||
|
||||
proc getBatteryInfoBSD() =
|
||||
try:
|
||||
let batmon = osproc.execCmdEx("batmon -o")
|
||||
if batmon.exitCode == 0:
|
||||
let bat = batmon.output.fromJson(Battery)
|
||||
let data = getOutput(bat.charge, bat.charging)
|
||||
outputData(data)
|
||||
let bat = get_battery_status()
|
||||
let data = getOutput(bat.charge, bat.charging)
|
||||
outputData(data)
|
||||
except:
|
||||
echo getCurrentExceptionMsg()
|
||||
|
||||
|
|
|
@ -15,6 +15,7 @@ requires "parsetoml >= 0.7.1"
|
|||
requires "argparse"
|
||||
requires "configparser"
|
||||
requires "jsony"
|
||||
requires "batmon"
|
||||
|
||||
task refresh_emoji, "Refresh Emoji Library file":
|
||||
exec "nim c -r src/lib/refresh_emoji.nim"
|
||||
|
|
Loading…
Add table
Reference in a new issue