summaryrefslogtreecommitdiff
path: root/examples/py/simple-bar/app.py
blob: 17b678215e93e7bd8430cb43af03af60b81cb793 (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
#!/usr/bin/env python3
import sys
import versions
from gi.repository import AstalIO, Astal, Gio
from widget.Bar import Bar
from pathlib import Path

scss = str(Path(__file__).parent.resolve() / "style.scss")
css = "/tmp/style.css"


class App(Astal.Application):
    def do_astal_application_request(
        self, msg: str, conn: Gio.SocketConnection
    ) -> None:
        print(msg)
        AstalIO.write_sock(conn, "hello")

    def do_activate(self) -> None:
        self.hold()
        AstalIO.Process.execv(["sass", scss, css])
        self.apply_css(css, True)
        print("hello")
        for mon in self.get_monitors():
            self.add_window(Bar(mon))


instance_name = "python"
app = App(instance_name=instance_name)

if __name__ == "__main__":
    try:
        print(app.acquire_socket())
        app.run(None)
    except Exception as e:
        print(AstalIO.send_message(instance_name, "".join(sys.argv[1:])))