diff options
Diffstat (limited to 'lua')
-rw-r--r-- | lua/astal-dev-1.rockspec | 36 | ||||
-rw-r--r-- | lua/astal/application.lua | 4 | ||||
-rwxr-xr-x | lua/sample.lua | 81 |
3 files changed, 24 insertions, 97 deletions
diff --git a/lua/astal-dev-1.rockspec b/lua/astal-dev-1.rockspec index 35517d3..616f4f8 100644 --- a/lua/astal-dev-1.rockspec +++ b/lua/astal-dev-1.rockspec @@ -1,22 +1,30 @@ package = "astal" version = "dev-1" + source = { - url = "git+https://github.com/astal-sh/libastal" + url = "git+https://github.com/astal-sh/libastal", } + description = { - summary = "lua bindings for libastal.", - homepage = "https://github.com/astal-sh/libastal", - license = "GPL-3" + summary = "lua bindings for libastal.", + homepage = "https://github.com/astal-sh/libastal", + license = "GPL-3", } + +dependencies = { + "lua >= 5.1, < 5.4", + "lgi >= 0.9.2", +} + build = { - type = "builtin", - modules = { - ["astal.application"] = "astal/application.lua", - ["astal.binding"] = "astal/binding.lua", - ["astal.init"] = "astal/init.lua", - ["astal.process"] = "astal/process.lua", - ["astal.time"] = "astal/time.lua", - ["astal.variable"] = "astal/variable.lua", - ["astal.widget"] = "astal/widget.lua", - } + type = "builtin", + modules = { + ["astal.application"] = "astal/application.lua", + ["astal.binding"] = "astal/binding.lua", + ["astal.init"] = "astal/init.lua", + ["astal.process"] = "astal/process.lua", + ["astal.time"] = "astal/time.lua", + ["astal.variable"] = "astal/variable.lua", + ["astal.widget"] = "astal/widget.lua", + }, } diff --git a/lua/astal/application.lua b/lua/astal/application.lua index 6146e33..551367a 100644 --- a/lua/astal/application.lua +++ b/lua/astal/application.lua @@ -6,8 +6,8 @@ local request_handler function AstalLua:do_request(msg, conn) if type(request_handler) == "function" then - request_handler(msg, function(request) - Astal.write_sock(conn, request, function(_, res) + request_handler(msg, function(response) + Astal.write_sock(conn, tostring(response), function(_, res) Astal.write_sock_finish(res) end) end) diff --git a/lua/sample.lua b/lua/sample.lua deleted file mode 100755 index 2c76af6..0000000 --- a/lua/sample.lua +++ /dev/null @@ -1,81 +0,0 @@ -#!/usr/bin/env lua --- imports -local astal = require("astal.init") -local Widget, Variable, App, bind = astal.Widget, astal.Variable, astal.App, astal.bind - --- state -local player = astal.require("Playerctl").Player.new("spotify") - -local title = Variable(player:get_title()):observe(player, "metadata", function() - return player:get_title() -end) - -local rnd = Variable(1):poll(1000, function() - return math.random(1, 10) -end) - --- ui -local Bar = function(monitor) - return Widget.Window({ - application = App, - id = "bar", - name = "bar", - monitor = monitor, - anchor = astal.Astal.WindowAnchor.BOTTOM - + astal.Astal.WindowAnchor.LEFT - + astal.Astal.WindowAnchor.RIGHT, - exclusivity = "EXCLUSIVE", - - Widget.CenterBox({ - class_name = "bar", - start_widget = Widget.Label({ - valign = "CENTER", - label = "Welcome to Astal.lua", - }), - center_widget = Widget.Box({ - children = bind(rnd):as(function(n) - local children = {} - for i = 1, n, 1 do - table.insert( - children, - Widget.Button({ - label = tostring(i), - on_clicked = function() - print(i) - end, - }) - ) - end - return children - end), - }), - end_widget = Widget.Label({ - valign = "CENTER", - label = bind(title), - }), - }), - }) -end - --- css -local css = [[ -.bar button { - color: blue; -} -]] - --- main -App:start({ - request_handler = function(msg, res) - if msg == "quit" then - os.exit(0) - end - if msg == "inspector" then - res(App:inspector()) - end - res("hi") - end, - css = css, -}, function() - Bar(0) -end) |