Skip to content

[Bug]: internal/tray is rendered with global margins when empty #3036

@agorgl

Description

@agorgl

Checklist

  • I have read the appropriate section in the contributing guidelines
  • I believe this issue is a problem with polybar itself and not a misconfiguration on my part
  • I have searched for other open and closed issues that may have already reported this problem
  • I have checked the known issues page for this problem.
  • I have followed the debugging guide to narrow down the problem to a minimal config.

Steps to reproduce

polybar -r main

Minimal config

[bar/main]
width = 100%
module-margin-left = 2
module-margin-right = 0
modules-right = time tray

[module/tray]
type = internal/tray
format-offset = 0px
format-margin = 0px
format-padding = 0px
tray-padding = 0px
tray-spacing = 8px

Polybar log

No response

Expected behavior

When tray is empty (no active items in tray) rendering it along with the global margins module-margin-left and module-margin-right should be skipped to avoid creating unnecessary empty space, I believe this is handled here:

https://github.com/polybar/polybar/blob/7d7bf84e16f19c31cc89ac4406224f864cb2fb58/src/components/controller.cpp#L519C44-L519C44

Actual behavior

The empty tray is rendered along with the global margins

Window Manager and Version

bspwm

Linux Distribution

Arch

Polybar version

polybar 3.7.0

Features: +alsa +curl +i3 +mpd +network(libnl) +pulseaudio +xkeyboard

X extensions: +randr (+monitors) +composite +xkb +xrm +xcursor

Build type: Release
Compiler: /usr/bin/c++
Compiler flags: -march=x86-64 -mtune=generic -O2 -pipe -fno-plt -fexceptions         -Wp,-D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security         -fstack-clash-protection -fcf-protection -Wp,-D_GLIBCXX_ASSERTIONS -g -ffile-prefix-map=/build/polybar/src=/usr/src/debug/polybar -flto=auto -O3 -DNDEBUG -Wall -Wextra -Wpedantic -Wdeprecated-copy-dtor -Wsuggest-override
Linker flags: -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now -flto=auto -Wall -Wextra -Wpedantic -Wdeprecated-copy-dtor -Wsuggest-override  -Wall -Wextra -Wpedantic -Wdeprecated-copy-dtor -Wsuggest-override

Additional Context / Screenshots

Expected (behavior of legacy tray):
image

Actual (new internal/tray module):
image

I suppose this could be tackled in two possible ways:

  1. mark internal/tray module as not visible when empty and avoid rendering it in the main modules loop
  2. allow overriding module-margin-{left,right} on a per module basis (would give additional flexibility to polybar in general)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions