From 3c33226dc7c1636194491842c43dd3dd8945d3d0 Mon Sep 17 00:00:00 2001 From: kotontrion Date: Sat, 16 Nov 2024 12:07:28 +0100 Subject: lua: add actionGroup property --- examples/lua/simple-bar/widget/Bar.lua | 26 +++++++++----------------- 1 file changed, 9 insertions(+), 17 deletions(-) (limited to 'examples/lua/simple-bar/widget/Bar.lua') diff --git a/examples/lua/simple-bar/widget/Bar.lua b/examples/lua/simple-bar/widget/Bar.lua index bf230bb..843e292 100644 --- a/examples/lua/simple-bar/widget/Bar.lua +++ b/examples/lua/simple-bar/widget/Bar.lua @@ -19,24 +19,16 @@ local function SysTray() return Widget.Box({ 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 { + prefix = "dbusmenu", + action_group = ag + } + end), Widget.Icon({ g_icon = bind(item, "gicon"), }), -- cgit v1.2.3 From c5664e2941b33609de0743a8475a40b24522a3dc Mon Sep 17 00:00:00 2001 From: Aylur Date: Thu, 19 Dec 2024 23:42:33 +0100 Subject: update examples, fix styling --- examples/lua/simple-bar/widget/Bar.lua | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) (limited to 'examples/lua/simple-bar/widget/Bar.lua') diff --git a/examples/lua/simple-bar/widget/Bar.lua b/examples/lua/simple-bar/widget/Bar.lua index 843e292..e7bd4ff 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,18 +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) return Widget.MenuButton({ tooltip_markup = bind(item, "tooltip_markup"), - use_popover = false, + use_popover = false, menu_model = bind(item, "menu-model"), - action_group = bind(item, "action-group"):as(function(ag) - return { - prefix = "dbusmenu", - action_group = ag - } - end), + action_group = bind(item, "action-group"):as(function(ag) + return { "dbusmenu", ag } + end), Widget.Icon({ g_icon = bind(item, "gicon"), }), @@ -181,10 +177,10 @@ return function(gdkmonitor) }), Widget.Box({ halign = "END", + SysTray(), Wifi(), AudioSlider(), BatteryLevel(), - SysTray(), Time("%H:%M - %A %e."), }), }), -- cgit v1.2.3 From d16c856074531b9fb867b8922be370bcfc749614 Mon Sep 17 00:00:00 2001 From: rRedLim <82714753+rRedLim@users.noreply.github.com> Date: Fri, 20 Dec 2024 02:21:09 +0300 Subject: chore: simple-bar filter special workspaces (#168) --- examples/lua/simple-bar/widget/Bar.lua | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) (limited to 'examples/lua/simple-bar/widget/Bar.lua') 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), }) -- cgit v1.2.3