diff options
author | rRedLim <[email protected]> | 2024-12-20 02:21:09 +0300 |
---|---|---|
committer | GitHub <[email protected]> | 2024-12-20 00:21:09 +0100 |
commit | d16c856074531b9fb867b8922be370bcfc749614 (patch) | |
tree | 08ee70023bf18a6dc39f312269c0a4e63ff0b7e0 | |
parent | 23083cdec69853bc8e480807a5f93b03df340183 (diff) |
chore: simple-bar filter special workspaces (#168)
-rw-r--r-- | examples/js/simple-bar/widget/Bar.tsx | 1 | ||||
-rw-r--r-- | examples/lua/simple-bar/widget/Bar.lua | 24 | ||||
-rw-r--r-- | examples/py/simple-bar/widget/Bar.py | 3 | ||||
-rw-r--r-- | examples/vala/simple-bar/widget/Bar.vala | 8 |
4 files changed, 22 insertions, 14 deletions
diff --git a/examples/js/simple-bar/widget/Bar.tsx b/examples/js/simple-bar/widget/Bar.tsx index 87cc20d..54a14b0 100644 --- a/examples/js/simple-bar/widget/Bar.tsx +++ b/examples/js/simple-bar/widget/Bar.tsx @@ -89,6 +89,7 @@ function Workspaces() { return <box className="Workspaces"> {bind(hypr, "workspaces").as(wss => wss + .filter(ws => !(ws.id >= -99 && ws.id <= -2)) // filter out special workspaces .sort((a, b) => a.id - b.id) .map(ws => ( <button diff --git a/examples/lua/simple-bar/widget/Bar.lua b/examples/lua/simple-bar/widget/Bar.lua index e7bd4ff..5e62253 100644 --- a/examples/lua/simple-bar/widget/Bar.lua +++ b/examples/lua/simple-bar/widget/Bar.lua @@ -127,17 +127,19 @@ local function Workspaces() end) return map(wss, function(ws) - return Widget.Button({ - class_name = bind(hypr, "focused-workspace"):as(function(fw) - return fw == ws and "focused" or "" - end), - on_clicked = function() - ws:focus() - end, - label = bind(ws, "id"):as(function(v) - return type(v) == "number" and string.format("%.0f", v) or v - end), - }) + if !(ws.id >= -99 and ws.id <= -2) then -- filter out special workspaces + return Widget.Button({ + class_name = bind(hypr, "focused-workspace"):as(function(fw) + return fw == ws and "focused" or "" + end), + on_clicked = function() + ws:focus() + end, + label = bind(ws, "id"):as(function(v) + return type(v) == "number" and string.format("%.0f", v) or v + end), + }) + end end) end), }) diff --git a/examples/py/simple-bar/widget/Bar.py b/examples/py/simple-bar/widget/Bar.py index ca02dd6..3c5c3f8 100644 --- a/examples/py/simple-bar/widget/Bar.py +++ b/examples/py/simple-bar/widget/Bar.py @@ -32,7 +32,8 @@ class Workspaces(Gtk.Box): child.destroy() for ws in hypr.get_workspaces(): - self.add(self.button(ws)) + if not (ws.id >= -99 and ws.id <= -2): # filter out special workspaces + self.add(self.button(ws)) def button(self, ws): hypr = Hyprland.get_default() diff --git a/examples/vala/simple-bar/widget/Bar.vala b/examples/vala/simple-bar/widget/Bar.vala index ba9f06c..8913c95 100644 --- a/examples/vala/simple-bar/widget/Bar.vala +++ b/examples/vala/simple-bar/widget/Bar.vala @@ -10,8 +10,12 @@ class Workspaces : Gtk.Box { foreach (var child in get_children()) child.destroy(); - foreach (var ws in hypr.workspaces) - add(button(ws)); + foreach (var ws in hypr.workspaces) { + // filter out special workspaces + if (!(ws.id >= -99 && ws.id <= -2)) { + add(button(ws)); + } + } } Gtk.Button button(AstalHyprland.Workspace ws) { |