summaryrefslogtreecommitdiff
path: root/python/sample.py
diff options
context:
space:
mode:
authorAylur <[email protected]>2024-05-19 02:39:53 +0200
committerAylur <[email protected]>2024-05-19 02:39:53 +0200
commit1425b396b08f0e91d45bbd0f92b1309115c7c870 (patch)
tree8af1a899a14d8a01a9ef50e248c077b48aed25bc /python/sample.py
init 0.1.0
Diffstat (limited to 'python/sample.py')
-rwxr-xr-xpython/sample.py31
1 files changed, 31 insertions, 0 deletions
diff --git a/python/sample.py b/python/sample.py
new file mode 100755
index 0000000..af09ce2
--- /dev/null
+++ b/python/sample.py
@@ -0,0 +1,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)