summaryrefslogtreecommitdiff
path: root/python/sample.py
blob: af09ce24414045e4fa6abe924baa3c69dd7acbe0 (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
#!/usr/bin/env python3
import gi

gi.require_version("Playerctl", "2.0")

from gi.repository import Playerctl
from astal import App, Astal, Variable, Widget, bind

player = Playerctl.Player.new("spotify")
v = Variable(player.get_title()).observe(player, "metadata", lambda *_: player.get_title())


def Bar(monitor):
    return Widget.Window(
        anchor=Astal.WindowAnchor.BOTTOM | Astal.WindowAnchor.LEFT | Astal.WindowAnchor.RIGHT,
        monitor=monitor,
        exclusivity=Astal.Exclusivity.EXCLUSIVE,
        child=Widget.CenterBox(
            start_widget=Widget.Label(
                label="Welcome to Astal.py!",
            ),
            end_widget=Widget.Label(label=v()),
        ),
    )


def start():
    Bar(0)


App.start(callback=start)