summaryrefslogtreecommitdiff
path: root/js/sample.gjs.js
diff options
context:
space:
mode:
authorAylur <[email protected]>2024-05-25 14:44:50 +0200
committerAylur <[email protected]>2024-05-25 14:44:50 +0200
commit58fa1ab9be7ee8fd4a8e96865121a54d613978cc (patch)
tree56f01ba49fd2929690a16ac05a4af8f763e6b30b /js/sample.gjs.js
parenta7e25a4a5fcf4de89fe5a149a9aaf50a92be7af1 (diff)
separate node and gjs into its own package
Diffstat (limited to 'js/sample.gjs.js')
-rwxr-xr-xjs/sample.gjs.js43
1 files changed, 0 insertions, 43 deletions
diff --git a/js/sample.gjs.js b/js/sample.gjs.js
deleted file mode 100755
index c435c14..0000000
--- a/js/sample.gjs.js
+++ /dev/null
@@ -1,43 +0,0 @@
-#!/usr/bin/env -S gjs -m
-import { Variable, App, Widget, Astal, bind } from "../js/dist/gjs/astal.js"
-import Playerctl from "gi://Playerctl"
-
-// state
-const player = Playerctl.Player.new("spotify")
-const date = Variable("").poll(1000, "date")
-const title = Variable(player.get_title()).observe(player, "metadata", () => player.get_title())
-
-// ui
-function Bar(monitor) {
- return Widget.Window(
- {
- monitor,
- application: App,
- exclusivity: Astal.Exclusivity.EXCLUSIVE,
- anchor: Astal.WindowAnchor.BOTTOM |
- Astal.WindowAnchor.LEFT |
- Astal.WindowAnchor.RIGHT
- },
- Widget.CenterBox({
- startWidget: Widget.Label({
- label: date(l => `Current date: ${l}`),
- }),
- endWidget: Widget.Label({
- label: bind(title).as(t => `Title: ${t}`)
- }),
- })
- )
-}
-
-// main
-App.start({
- requestHandler(msg, res) {
- switch (msg) {
- case "inspector": return res(App.inspector())
- case "quit": return res(App.quit())
- default: return App.eval(msg).then(res).catch(console.error)
- }
- }
-}, () => {
- Bar(0)
-})