From 6589834329b2b1cf8149522b70ac603e3667a0c8 Mon Sep 17 00:00:00 2001 From: Kevin Date: Wed, 9 Oct 2024 21:10:24 -0300 Subject: Accurate lua example --- examples/lua/simple-bar/widget/Bar.lua | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'examples/lua/simple-bar') diff --git a/examples/lua/simple-bar/widget/Bar.lua b/examples/lua/simple-bar/widget/Bar.lua index d44db2d..d340cba 100644 --- a/examples/lua/simple-bar/widget/Bar.lua +++ b/examples/lua/simple-bar/widget/Bar.lua @@ -134,6 +134,10 @@ local function Workspaces() return Widget.Box({ class_name = "Workspaces", bind(hypr, "workspaces"):as(function(wss) + table.sort(wss, function(a, b) + return a.id < b.id + end) + return map(wss, function(ws) return Widget.Button({ class_name = bind(hypr, "focused-workspace"):as(function(fw) @@ -142,7 +146,9 @@ local function Workspaces() on_clicked = function() ws:focus() end, - label = bind(ws, "id"):as(tostring), + label = bind(ws, "id"):as(function(v) + return type(v) == "number" and string.format("%.0f", v) or v + end), }) end) end), -- cgit v1.2.3 From d63332b533b390e7e68f8f1fc2432958c4d36a4f Mon Sep 17 00:00:00 2001 From: Aylur Date: Tue, 15 Oct 2024 01:26:40 +0200 Subject: update examples --- examples/lua/simple-bar/init.lua | 7 ++++++- examples/lua/simple-bar/widget/Bar.lua | 12 +++++++----- 2 files changed, 13 insertions(+), 6 deletions(-) (limited to 'examples/lua/simple-bar') diff --git a/examples/lua/simple-bar/init.lua b/examples/lua/simple-bar/init.lua index aecf7a6..8c412fb 100644 --- a/examples/lua/simple-bar/init.lua +++ b/examples/lua/simple-bar/init.lua @@ -1,5 +1,5 @@ local astal = require("astal") -local App = astal.App +local App = require("astal.gtk3.app") local Bar = require("widget.Bar") local src = require("lib").src @@ -10,7 +10,12 @@ local css = "/tmp/style.css" astal.exec("sass " .. scss .. " " .. css) App:start({ + instance_name = "lua", css = css, + request_handler = function(msg, res) + print(msg) + res("ok") + end, main = function() for _, mon in pairs(App.monitors) do Bar(mon) diff --git a/examples/lua/simple-bar/widget/Bar.lua b/examples/lua/simple-bar/widget/Bar.lua index d340cba..bf230bb 100644 --- a/examples/lua/simple-bar/widget/Bar.lua +++ b/examples/lua/simple-bar/widget/Bar.lua @@ -1,9 +1,9 @@ local astal = require("astal") -local App = astal.App -local Widget = astal.Widget +local App = require("astal.gtk3.app") +local Widget = require("astal.gtk3.widget") local Variable = astal.Variable -local Gdk = astal.Gdk -local GLib = astal.GLib +local Gdk = astal.require("Gdk", "3.0") +local GLib = astal.require("GLib") local bind = astal.bind local Mpris = astal.require("AstalMpris") local Battery = astal.require("AstalBattery") @@ -170,10 +170,12 @@ local function Time(format) end return function(gdkmonitor) + local WindowAnchor = astal.require("Astal", "3.0").WindowAnchor + return Widget.Window({ class_name = "Bar", gdkmonitor = gdkmonitor, - anchor = astal.Astal.WindowAnchor.TOP + astal.Astal.WindowAnchor.LEFT + astal.Astal.WindowAnchor.RIGHT, + anchor = WindowAnchor.TOP + WindowAnchor.LEFT + WindowAnchor.RIGHT, exclusivity = "EXCLUSIVE", Widget.CenterBox({ -- cgit v1.2.3