include("cpu.source")
include("memory.source")

scanner {
# Get total and remaining battery charge
  file("/sys/class/power_supply/BAT0/charge_full") {
    BatteryTotal = Grab(Sum)
  }
  file("/sys/class/power_supply/BAT0/charge_now") {
    BatteryLeft = Grab(Sum)
  }
  file("/sys/class/power_supply/AC/online") {
    ACOnline = Grab(Sum)
  }
}

layout {
  # add a sub-grid to house scales
  style = "scales"
  scale {
    style = if(XCpuPresent,"","hidden")
    css = "progressbar progress { background-color: #0000ff;}"
    value = XCpuUtilization
  }
  scale {
    style = if(XMemoryPresent,"","hidden")
    css = "progressbar progress { background-color: #00ff00;}"
    value= XMemoryUtilization
  }
  scale {
    value = BatteryLeft/BatteryTotal
    style = ACOnline
    css = "progressbar#1 progress { background-color: #ff0000;} \
           progressbar#0 progress { background-color: #ffff00;}"
  }
}
