Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shape function in naughty notification rule passes wierd arguments. #3885

Open
armagidon-exception opened this issue Jan 9, 2024 · 0 comments

Comments

@armagidon-exception
Copy link

Output of awesome --version:

awesome v4.3-1639-g75758b07f-dirty (Too long)
• Compiled against Lua 5.4.6 (running with 0.9.2)
• API level: 4
• D-Bus support: yes
• xcb-errors support: yes
• execinfo support: yes
• xcb-randr version: 1.6
• LGI version: /usr/share/lua/5.4/lgi/version.lua
• Transparency enabled: yes
• Custom search paths: no

How to reproduce the issue:

  1. Add the following code to your config.
local ruled = require "rules"
local naughty = require "naughty"
local awful = require "awful"

local xresources = require "beautiful.xresources"
local dpi = xresources.apply_dpi
local gears = require "gears"
local rnotification = require "ruled.notification"
local menubar = require "menubar"
local theme = require "beautiful"
local wibox = require "wibox"

naughty.connect_signal("request::display", function(n)
	naughty.layout.box {
		notification = n,
		widget_template = {
			widget = naughty.container.background,
            shape = n.shape,
			{
				widget = wibox.container.margin,
				margins = n.margin,
				{
					layout = wibox.layout.fixed.vertical,
					naughty.widget.title,
					{
						layout = wibox.layout.fixed.horizontal,
						naughty.widget.icon,
						naughty.widget.message,
					},
					naughty.list.actions,
				},
			},
		},
	}
end)

-- Apply theme variables
naughty.config.spacing = dpi(8)
naughty.config.icon_dirs = {
	"/usr/share/icons/Papirus-Dark/",
}
naughty.config.icon_formats = { "svg", "png", "jpg", "gif" }

rnotification.connect_signal("request::rules", function()
	rnotification.append_rule {
		rule = {},
		properties = {
			timeout = 5,
			icon_size = dpi(32),
			max_width = dpi(250),
			ontop = true,
			hover_timeout = 300,
			title = "System Notification Title",
			margin = dpi(16),
			border_width = 0,
			position = "top_right",
            shape = function(cr, w, h)
                gears.debug.dump(w)
            end
		},
	}
	-- Critical notifs
	rnotification.append_rule {
		rule = { urgency = "critical" },
		properties = {
			bg = theme.bg_urgent,
			fg = theme.fg_normal,
		},
	}

	-- Normal notifs
	rnotification.append_rule {
		rule = { urgency = "normal" },
		properties = {
			bg = theme.notification_bg,
			fg = theme.notification_fg,
		},
	}

	-- Low notifs
	rnotification.append_rule {
		rule = { urgency = "low" },
		properties = {
			bg = theme.notification_bg,
			fg = theme.notification_fg,
		},
	}
end)

-- Error handling
naughty.connect_signal("request::display_error", function(message, startup)
	naughty.notification {
		urgency = "critical",
		title = "Oops, an error happened" .. (startup and " during startup!" or "!"),
		message = message,
		app_name = "System Notification",
		icon = theme.awesome_icon,
	}
end)

-- XDG icon lookup
naughty.connect_signal("request::icon", function(n, context, hints)
	if context ~= "app_icon" then
		return
	end
	-- try use application icon
	local path = menubar.utils.lookup_icon(hints.app_icon) or menubar.utils.lookup_icon(hints.app_icon:lower())

	if path then
		n.icon = path
	end
end)

naughty.connect_signal("request::action_icon", function(a, _, hints)
	a.icon = menubar.utils.lookup_icon(hints.id)
end)
  1. Send notification via notify-send

Actual result:

This was printed in the stdout:

  table: 0x563abd099260
  border_width : 0 (number)
  position : top_right (string)
  timeout : 5 (number)
  icon_size : 31 (number)
  hover_timeout : 300 (number)
  title : System Notification Title (string)
  max_width : 245 (number)
  shape : function: 0x563abcaded30 (function)
  margin : 16 (number)
  ontop : true (boolean)

Expected result:

Some number corresponding to width should've been printed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant