Awesome: Variable to increase gap between notification and the edge of the screen

Created on 28 Mar 2020  路  13Comments  路  Source: awesomeWM/awesome

Hello,

There is no way to increase the gap between a notification and the edge of the screen.

I did read the APIDoc and except notification_spacing, which increase the gap between each notification, I did not find anything.

Is it possible to add a new theme variable ?

Most helpful comment

this works for me but i didn't tested it with other notification positions than "top_right":

diff --git a/lib/naughty/layout/box.lua b/lib/naughty/layout/box.lua
index ecbc365f8..cc95ad528 100644
--- a/lib/naughty/layout/box.lua
+++ b/lib/naughty/layout/box.lua
@@ -61,6 +61,16 @@ local function get_spacing()
     return {top = margin, bottom = margin}
 end

+local function get_offset(position)
+    local margin = beautiful.notification_spacing or 2
+    if position:match('_right') then
+        return {x = -margin}
+    elseif position:match('_left') then
+        return {x = margin}
+    end
+    return {}
+end
+
 -- Leverage `awful.placement` to create the stacks.
 local function update_position(position)
     local pref  = position:match("top_") and "bottom" or "top"
@@ -76,6 +86,9 @@ local function update_position(position)
                 margins             = get_spacing(),
                 honor_workarea      = true,
             }
+            if k == 1 then
+                args.offset              = get_offset(position)
+            end

             -- The first entry is aligned to the workarea, then the following to the
             -- previous widget.

All 13 comments

https://github.com/awesomeWM/awesome/blob/f997009ff4c4cb73c1364126e6df7867832705d3/lib/naughty/layout/box.lua#L59-L62

This is probably what you mean as the margins for the top and bottom are set and used here for the popup:
https://github.com/awesomeWM/awesome/blob/f997009ff4c4cb73c1364126e6df7867832705d3/lib/naughty/layout/box.lua#L76

This is speculation on my part since i haven't tried it but I wonder if the right/left margins are set with that too, it would have the desired effect.

IIRC, the spacing is used to separate multiples notifications. That's similar to gaps between clients.

@SethBarberee indeed adding left/right in get_spacing() kind of works, but each notification is shifted.
Here is a screenshot :
20200331_222953

Stupid question, but what if somebody want different spacing for left/right and top/bottom ?

Yeah, that is probably the effect of that hack as awful.placement thinks they are sideways next to each other. I'll take a deeper look into the code later this week to see if I can draft up a PR/idea.

this works for me but i didn't tested it with other notification positions than "top_right":

diff --git a/lib/naughty/layout/box.lua b/lib/naughty/layout/box.lua
index ecbc365f8..cc95ad528 100644
--- a/lib/naughty/layout/box.lua
+++ b/lib/naughty/layout/box.lua
@@ -61,6 +61,16 @@ local function get_spacing()
     return {top = margin, bottom = margin}
 end

+local function get_offset(position)
+    local margin = beautiful.notification_spacing or 2
+    if position:match('_right') then
+        return {x = -margin}
+    elseif position:match('_left') then
+        return {x = margin}
+    end
+    return {}
+end
+
 -- Leverage `awful.placement` to create the stacks.
 local function update_position(position)
     local pref  = position:match("top_") and "bottom" or "top"
@@ -76,6 +86,9 @@ local function update_position(position)
                 margins             = get_spacing(),
                 honor_workarea      = true,
             }
+            if k == 1 then
+                args.offset              = get_offset(position)
+            end

             -- The first entry is aligned to the workarea, then the following to the
             -- previous widget.

i've updated the patch above

please test, and if works well for you too, i'll prepare a PR

But there was a config setting padding earlier. That one should be exposed by the new api.

@vn-ki

don't remember such, could you please point to older doc/source code?

https://awesomewm.org/apidoc/libraries/naughty.html#config

this is the master docs.

padding int Space between popups and edge of the workarea. (default apply_dpi(4))

ah, so it wasn't in beautiful, but only in the config

in that case patch would be a bit less trivial, as it will require accessing config of this notification from that update_position function

@actionless patch works like a charm :) ! Thank you !
Here is a screenshot :
20200517_110037

Thanks guys, i've created a PR

btw whlie testing this i also found what popup have sorta related bug with spacing from the screen :(
now need to dig into that one :D

Was this page helpful?
0 / 5 - 0 ratings