diff options
Diffstat (limited to 'examples/lua')
-rw-r--r-- | examples/lua/simple-bar/init.lua | 7 | ||||
-rw-r--r-- | examples/lua/simple-bar/widget/Bar.lua | 20 |
2 files changed, 20 insertions, 7 deletions
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 d44db2d..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") @@ -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), @@ -164,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({ |