SbarLua icon indicating copy to clipboard operation
SbarLua copied to clipboard

Debugging lua widget

Open keefetang opened this issue 2 months ago • 1 comments

I'm building on @FelixKratz's dotfiles for sketchybar and when I create a new widget, the widget label isn't updated as I expect it should.

Steps to reproduce

Created a new widget under .config/sketchybar/items/widgets/ with the name warp.lua and added it to init.lua.

local colors = require("colors")
local settings = require("settings")

local warp = sbar.add("item", "widgets.warp", {
    position = "right",
    icon = {
        drawing = false
    },
    label = {
        string = "????",
        font = { family = settings.font.numbers }
    },
    update_freq = 5,
    popup = { align = "center" }
})

warp:subscribe("routine", function()
    sbar.exec("warp-cli settings | grep 'Mode:' | awk '{print $3}'", function(warp_info)
        if warp_info == "WarpWithDnsOverHttps" then
            warp:set({ label = { string = "WARP" } })
        elseif warp_info == "DnsOverHttps" then
            warp:set({ label = { string = "DoH" } })
        end
    end)
end)

sbar.add("bracket", "widgets.warp.bracket", { warp.name }, {
    background = { color = colors.bg1 }
})

sbar.add("item", "widgets.warp.padding", {
    position = "right",
    width = settings.group_paddings
})

In shell, I get the output I expected.

❯ warp-cli settings | grep 'Mode:' | awk '{print $3}'
WarpWithDnsOverHttps

However, the widget label isn't being set for some reason. Screenshot 2024-04-23 at 2 42 04 PM

Question

With Sbar, what are my options to debug what may be the issue?

Additional info

❯ sketchybar --query widgets.warp
{
	"name": "widgets.warp",
	"type": "item",
	"geometry": {
		"drawing": "on",
		"position": "right",
		"associated_space_mask": 0,
		"associated_display_mask": 0,
		"ignore_association": "off",
		"y_offset": 0,
		"width": 5,
		"padding_left": 5,
		"padding_right": -1,
		"background": {
			"drawing": "off",
			"color": "0x0",
			"border_color": "0xff414550",
			"border_width": 2,
			"height": 28,
			"corner_radius": 9,
			"padding_left": 5,
			"padding_right": 5,
			"y_offset": 0,
			"clip": 0.000000,
			"image": {
				"value": "(null)",
				"drawing": "off",
				"scale": 1.000000
			},
			"shadow": {
				"drawing": "off",
				"color": "0xff000000",
				"angle": 30,
				"distance": 5
			}
		}
	},
	"icon": {
		"value": "",
		"drawing": "off",
		"highlight": "off",
		"color": "0xffe2e2e3",
		"highlight_color": "0xff000000",
		"padding_left": 3,
		"padding_right": 3,
		"y_offset": 0,
		"font": "SF Pro:Bold:14.00",
		"width": 0,
		"align": "left",
		"background": {
			"drawing": "off",
			"color": "0x0",
			"border_color": "0x0",
			"border_width": 0,
			"height": 0,
			"corner_radius": 0,
			"padding_left": 0,
			"padding_right": 0,
			"y_offset": 0,
			"clip": 0.000000,
			"image": {
				"value": "(null)",
				"drawing": "off",
				"scale": 1.000000
			},
			"shadow": {
				"drawing": "off",
				"color": "0xff000000",
				"angle": 30,
				"distance": 5
			}
		},
		"shadow": {
			"drawing": "off",
			"color": "0xff000000",
			"angle": 30,
			"distance": 5
		}
	},
	"label": {
		"value": "????",
		"drawing": "on",
		"highlight": "off",
		"color": "0xffe2e2e3",
		"highlight_color": "0xff000000",
		"padding_left": 3,
		"padding_right": 3,
		"y_offset": 0,
		"font": "SF Mono:Semibold:13.00",
		"width": 0,
		"align": "left",
		"background": {
			"drawing": "off",
			"color": "0x0",
			"border_color": "0x0",
			"border_width": 0,
			"height": 0,
			"corner_radius": 0,
			"padding_left": 0,
			"padding_right": 0,
			"y_offset": 0,
			"clip": 0.000000,
			"image": {
				"value": "(null)",
				"drawing": "off",
				"scale": 1.000000
			},
			"shadow": {
				"drawing": "off",
				"color": "0xff000000",
				"angle": 30,
				"distance": 5
			}
		},
		"shadow": {
			"drawing": "off",
			"color": "0xff000000",
			"angle": 30,
			"distance": 5
		}
	},
	"scripting": {
		"script": "",
		"click_script": "(null)",
		"update_freq": 5,
		"update_mask": 1196038,
		"updates": "when_shown"
	},
	"bounding_rects": {
		"display-1": {
			"origin": [ 1218.000000, 0.000000 ],
			"size": [ 37.000000, 40.000000 ]
		},
		"display-2": {
			"origin": [ -510.000000, -154.000000 ],
			"size": [ 37.000000, 40.000000 ]
		}
	}
}

keefetang avatar Apr 23 '24 04:04 keefetang