summaryrefslogtreecommitdiff
path: root/examples/lua/simple-bar/widget
diff options
context:
space:
mode:
Diffstat (limited to 'examples/lua/simple-bar/widget')
-rw-r--r--examples/lua/simple-bar/widget/Bar.lua20
1 files changed, 14 insertions, 6 deletions
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({