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 strutils
|
||||||
import osproc
|
import ../../../batmon/src/batmon
|
||||||
import jsony
|
|
||||||
|
|
||||||
import ../common
|
import ../common
|
||||||
import ../common/colours
|
import ../common/colours
|
||||||
|
@ -19,15 +18,6 @@ const alert_bg = yellow
|
||||||
const med_fg = green
|
const med_fg = green
|
||||||
#const med_bg = black
|
#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 =
|
proc batteryExists(): bool =
|
||||||
try:
|
try:
|
||||||
let state = strip(readFile("/sys/class/power_supply/" & battery & "/present"))
|
let state = strip(readFile("/sys/class/power_supply/" & battery & "/present"))
|
||||||
|
@ -113,11 +103,9 @@ proc getBatteryInfo() =
|
||||||
|
|
||||||
proc getBatteryInfoBSD() =
|
proc getBatteryInfoBSD() =
|
||||||
try:
|
try:
|
||||||
let batmon = osproc.execCmdEx("batmon -o")
|
let bat = get_battery_status()
|
||||||
if batmon.exitCode == 0:
|
let data = getOutput(bat.charge, bat.charging)
|
||||||
let bat = batmon.output.fromJson(Battery)
|
outputData(data)
|
||||||
let data = getOutput(bat.charge, bat.charging)
|
|
||||||
outputData(data)
|
|
||||||
except:
|
except:
|
||||||
echo getCurrentExceptionMsg()
|
echo getCurrentExceptionMsg()
|
||||||
|
|
||||||
|
|
|
@ -15,6 +15,7 @@ requires "parsetoml >= 0.7.1"
|
||||||
requires "argparse"
|
requires "argparse"
|
||||||
requires "configparser"
|
requires "configparser"
|
||||||
requires "jsony"
|
requires "jsony"
|
||||||
|
requires "batmon"
|
||||||
|
|
||||||
task refresh_emoji, "Refresh Emoji Library file":
|
task refresh_emoji, "Refresh Emoji Library file":
|
||||||
exec "nim c -r src/lib/refresh_emoji.nim"
|
exec "nim c -r src/lib/refresh_emoji.nim"
|
||||||
|
|
Loading…
Add table
Reference in a new issue