I have my systray setup and works well. However, when it is empty it's keeping a big blank space and i'd like to get rid of that by hiding the tray with something like visibility = false
. Is there a way to count the number of icons and hide it when it is 0?
Asked
Active
Viewed 89 times
0

Mario Davó
- 21
- 4
1 Answers
0
I think the Answer (to the number of elements in systray) can be found in Awesome WM's Github Repo at awesome/lib/wibox/widget/systray.lua
:
num_entries
is the number of elements in your systray.
local capi = {
awesome = awesome,
screen = screen
}
local num_entries = capi.awesome.systray()
(I am not sure though, what happens if you have more than 1 systray)
I couldn't think of a nice way to hide your systray with this, but you could do it with gears.timer
:
gears.timer {
timeout = 10, -- Time between checks
call_now = true,
autostart = true,
callback = function()
if capi.awesome.systray() == 0 then -- if systray has no elements
your_systray_name.forced_height = 0 -- force heigt
your_systray_name.forced_width = 0 -- and width to be zero
end
end
}
Did that help/resolve your question?

awvle
- 1
- 1
-
I don't understand. Tried to implement this but it didn't work. – Mario Davó Feb 22 '23 at 13:02
-
Can you share with me what you have tried/what didn't work/and maybe your systray code? – awvle Feb 24 '23 at 11:17
-
i can't access 'capi' variable from outside systray.lua – Mario Davó Feb 25 '23 at 08:19
-
There is no `capi`. The code sample in the answer shows that this just uses the global `awesome` object, so you need `awesome.systray()` and not `capi.awesome.systray()`. – Uli Schlachter Apr 07 '23 at 09:19
-
`(I am not sure though, what happens if you have more than 1 systray)` Systray is a singleton. You cannot have more than one. Because X11. – Uli Schlachter Apr 07 '23 at 09:19