import app from "ags/gtk3/app"
import style from "./style.scss"
import Heartbeat from "./widget/Heartbeat"
import Bar from "./widget/Bar"
import BrainPower from "./widget/panels/BrainPower"

app.start({
  css: style,
  main() {
    for (const monitor of app.get_monitors()) {
      Heartbeat(monitor)
      Bar(monitor)
      BrainPower(monitor)
    }
  },
  requestHandler(request: any, res: (response: any) => void) {
    const cmd = String(request)
    if (cmd.includes("toggle-brain")) {
      const win = app.get_window("brain-power")
      if (win) {
        win.visible = !win.visible
        res("toggled")
      } else {
        res("window not found")
      }
    } else {
      res(`unknown: '${cmd}'`)
    }
  },
})
