polybar / polybar

A fast and easy-to-use status bar
https://polybar.github.io
MIT License
14.05k stars 703 forks source link

Allow to override module-margin-xxx #1320

Open memeplex opened 6 years ago

memeplex commented 6 years ago

It's great to have a global setting but sometimes one or two modules need to be fine-tuned and currently the only way I know to do that is using an offset, which is given in pixels and thus far from ideal.

sinsinewave commented 6 years ago

You can work around this by adding spaces to the module labels by surrounding them with quotes, i.e like this: label-urgent = " %index% " .

It would still be good to have an override, since this doesn't add margin to under/overlines, instead extending them slightly.

patrick96 commented 6 years ago

Doesn't format-NAME-margin not work for you?

memeplex commented 6 years ago

Yes, it does. Probably this request was motivated for the text module but we're already adding a format there. Nevertheless separate left/right margins are missing, but this could be addressed as a limitation of format, couldn't it?

patrick96 commented 6 years ago

You're right, those are missing for formats. I have added an entry in our refactor project

vaygr commented 5 years ago

Doesn't format-NAME-margin not work for you?

I think it doesn't when a local margin < global margin. Same for padding. And the only workaround for that is indeed offset, which messes up with clickable modules (e.g. if you try to use minimal offsets between 3 modules, the second one almost loses its clickability).

vaygr commented 5 years ago

Oh it seems I've just found a workaround for that specific case. Turns out only modules with click-* formatting are affected.

Imagine this:

you have global configuration with the following margin settings:

...
[bar/top]
...
module-margin-left = 1
module-margin-right = 2
...

then you have the following section of 2 modules (these scripts show the status of a mic and a specific Bluetooth headset respectively – essentially just an icon / gray icon; the second one also allows to connect/disconnect the headset by left-click):

...
[module/mic]
type = custom/script
exec = ~/.config/polybar/mic.sh
interval = 2

click-left = ~/.config/polybar/mic.sh toggle &

[module/headset]
type = custom/script
exec = ~/.config/polybar/hs.sh "XX:XX:XX:XX:XX:XX"
interval = 2

click-left = ~/.config/polybar/hs.sh "XX:XX:XX:XX:XX:XX" toggle &

format-offset = -10
...

format-margin = 0 doesn't do anything, so you want to use format-offset to make these two set close to each other, however as they overlap, there's only a couple of clickable pixels left for the headset module. To fix this, you can use action handlers instead, and replace this:

click-left = ~/.config/polybar/hs.sh "XX:XX:XX:XX:XX:XX" toggle &

with this:

format = %{A1:~/.config/polybar/hs.sh "XX\:XX\:XX\:XX\:XX\:XX" toggle &:}<label>%{A}

I'm wondering if described behavior of modules with offset and click-* formatting defined is a bug.

patrick96 commented 5 years ago

I think it doesn't when a local margin < global margin

format margin and module margins compound, they unfortunately don't override each other. That's also why format-margin = 0 doesn't do anything.

@vaygr The thing with the clicks looks like a bug at first sight, could you open a new issue for this so we can track this separately.

Lomadriel commented 5 years ago

@vaygr The thing with the clicks looks like a bug at first sight, could you open a new issue for this so we can track this separately.

While I was developing #1671, I also noticed the same problem by using this string: %{O100}Filler%{B#ff0000 O100}First%{O200}Second%{O-100}Test The last part of the module, just after Test, is not clickable.

poly

However after investigation this seems to be the same with lemonbar but in my opinion this behavior is really weird and confusing for the end user.

vaygr commented 5 years ago

Sorry for the delay @patrick96, #1814 is there.