summaryrefslogtreecommitdiff
path: root/examples/lua/simple-bar/widget/Bar.lua
diff options
context:
space:
mode:
authorkotontrion <[email protected]>2024-12-20 09:49:58 +0100
committerkotontrion <[email protected]>2024-12-20 09:49:58 +0100
commitfcef5cea5ca84fa06a74e69de34e84b4d0842fcc (patch)
tree798de065ecce20a6f5892bc729ef73455abe209c /examples/lua/simple-bar/widget/Bar.lua
parent5ed7a1416c2532188a7e01fead3842602fdb670f (diff)
parentd7d11b341db85ce9768fa06b6f225d713621ec56 (diff)
Merge branch 'main' into feat/wayland-glib
Diffstat (limited to 'examples/lua/simple-bar/widget/Bar.lua')
-rw-r--r--examples/lua/simple-bar/widget/Bar.lua52
1 files changed, 21 insertions, 31 deletions
diff --git a/examples/lua/simple-bar/widget/Bar.lua b/examples/lua/simple-bar/widget/Bar.lua
index bf230bb..5e62253 100644
--- a/examples/lua/simple-bar/widget/Bar.lua
+++ b/examples/lua/simple-bar/widget/Bar.lua
@@ -1,8 +1,6 @@
local astal = require("astal")
-local App = require("astal.gtk3.app")
local Widget = require("astal.gtk3.widget")
local Variable = astal.Variable
-local Gdk = astal.require("Gdk", "3.0")
local GLib = astal.require("GLib")
local bind = astal.bind
local Mpris = astal.require("AstalMpris")
@@ -17,26 +15,16 @@ local function SysTray()
local tray = Tray.get_default()
return Widget.Box({
+ class_name = "SysTray",
bind(tray, "items"):as(function(items)
return map(items, function(item)
- if item.icon_theme_path ~= nil then
- App:add_icons(item.icon_theme_path)
- end
-
- local menu = item:create_menu()
-
- return Widget.Button({
+ return Widget.MenuButton({
tooltip_markup = bind(item, "tooltip_markup"),
- on_destroy = function()
- if menu ~= nil then
- menu:destroy()
- end
- end,
- on_click_release = function(self)
- if menu ~= nil then
- menu:popup_at_widget(self, Gdk.Gravity.SOUTH, Gdk.Gravity.NORTH, nil)
- end
- end,
+ use_popover = false,
+ menu_model = bind(item, "menu-model"),
+ action_group = bind(item, "action-group"):as(function(ag)
+ return { "dbusmenu", ag }
+ end),
Widget.Icon({
g_icon = bind(item, "gicon"),
}),
@@ -139,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),
})
@@ -189,10 +179,10 @@ return function(gdkmonitor)
}),
Widget.Box({
halign = "END",
+ SysTray(),
Wifi(),
AudioSlider(),
BatteryLevel(),
- SysTray(),
Time("%H:%M - %A %e."),
}),
}),