diff options
Diffstat (limited to 'pkgs/astal/src/widget/bar/workspaces.lua')
-rw-r--r-- | pkgs/astal/src/widget/bar/workspaces.lua | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/pkgs/astal/src/widget/bar/workspaces.lua b/pkgs/astal/src/widget/bar/workspaces.lua new file mode 100644 index 0000000..8bc1785 --- /dev/null +++ b/pkgs/astal/src/widget/bar/workspaces.lua @@ -0,0 +1,28 @@ +local astal = require("astal") +local Widget = require("astal.gtk3.widget") +local Hyprland = astal.require("AstalHyprland") +local lib = require('lib') +local bind = astal.bind + +local hypr = Hyprland.get_default() + +function Workspace(ws) + return Widget.Button({ + class_name = bind(hypr, "focused-workspace"):as(function(fw) + return "workspace " .. (fw == ws and "primary" or "") + end), + on_clicked = function() ws:focus() end, + label = ws.id, + }) +end + +function Workspaces(wss) + return lib.map(lib.sort(wss, 'id'), Workspace) +end + +return function() + return Widget.Box({ + class_name = "workspaces", + bind(hypr, "workspaces"):as(Workspaces) + }) +end |