aboutsummaryrefslogtreecommitdiff
path: root/ags/config.js
blob: bc50aa8373a18940517fe15f4225485ff46ab634 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
// @ts-ignore
const battery = await Service.import("battery")

const BatteryPercent = () => Widget.Label()
  .hook(battery, self => {
    self.label = `${battery.percent}%`
    self.visible = battery.available
  }, "changed")

const MyButton = () => Widget.Button()
  .on("clicked", self => {
    print(self, "is clicked")
  })

const MyDate = () => Widget.Label({
  css: "color:blue; padding: 1em;",
})
  .poll(1000, self => {
    self.label = Utils.exec("date +'%_H:%_M:%S'")
  })

const MyKeybind = () => Widget.Button()
  .keybind(["MOD1", "CONTROL"], "a", (_self, _event) => {
    print("alt+control+a was pressed")
  })

const Bar = () => Widget.Window({
  name: 'bar',
  anchor: ['top', 'left', 'right'],
  child: MyDate(),
})

const scss = `${App.configDir}/style.scss`
const css = "/tmp/my-style.css"
Utils.exec(`sassc ${scss} ${css}`)

App.config({
  style: css,
  windows: [Bar()],
})