Uneven spaces around icons
-
i3status-rust version: 0.14.3
-
Configuration:
[[block]]
block = "net"
device = "tun0"
format = ""
interval = 1
hide_inactive = true
hide_missing = true
[[block]]
block = "battery"
driver = "upower"
interval = 10
format = " {percentage}% {time}"
- Description:
I have uneven spaces around the VPN icon (net block) and the battery icon (battery block).

The Wi-Fi icon of another net block is shown for reference, as it has even spaces around it.
I too noticed this recently as I use the latest git version. I have almost the same issue except for me it was NetworkManager icon and Battery icon. It was first introduced in a commit sometime in December. I meant to report it then but I was having unrelated video issues with my computer and thought it might just be me. This is the first report I have noticed about this issue. I wound up having to reload linux a few days ago and noticed it is still there. Here are some notes,observations and workarounds I discoverd. For the battery block I discoverd if you use driver = "sysfs". It works. It shows a battery percentage after the icon but spacing is correct. As far as I can tell the spacing issues is in "upower" code possibly. I even tried to manually overide the icon but the spacing issue is still present with driver = "upower". For me, with NetworkManager I used until recently in my config "device_format = "{icon}" which worked until the mentioned commit. It dropped the left spacing in front of the icon. Since the icon is exposed in string for this block all I had to do was add a manual space to the code like this, "device_format = " {icon}" for it to work.
Can confirm the net block example in the OP with this minimal config:
[[block]]
block = "net"
format = ""
>cargo run test1001.toml
{"version": 1, "click_events": true}
[[...,{...,"full_text":" ETH ",...},{...,"full_text":" ",...}],
(leading and trailing spaces around the icon ETH, and the widget after that is just an empty space)
The double spacing happens because icons have spaces around them, and the string shown next to the icon also has a trailing space. However in this case the string is set to an empty string, so you end up with two spaces right after each other.
Possible solutions:
- override the VPN icon in your config to not have a trailing space
- we can add a "{icon}" key for the net block format string so you can control the spacing yourself (IIRC some other block already does this)
The battery block one is most likely due to https://github.com/greshake/i3status-rust/blob/a920c577669042bbf8d720c5af26355c166f6390/src/blocks/battery.rs#L756 introduced by https://github.com/greshake/i3status-rust/pull/923, however the whole point of that PR was to solve double spacing so it's strange that your issue is not having any space at all.
Either way these spacing issues are a real pain so regarding any trivial ones help would be appreciated!
I tried to do this for my net block the other day but couldn't find anything better than this really ugly mess. But i'm also not very experienced with Rust so there's probably a better solution
diff --git a/src/blocks/net.rs b/src/blocks/net.rs
index 341da89..293b496 100644
--- a/src/blocks/net.rs
+++ b/src/blocks/net.rs
@@ -969,12 +969,19 @@ impl Block for Net {
}
fn view(&self) -> Vec<&dyn I3BarWidget> {
- if self.active {
- vec![&self.network, &self.output]
- } else if self.hide_inactive || !self.exists && self.hide_missing {
+ if (!self.active && self.hide_inactive) || (!self.exists && self.hide_missing) {
vec![]
- } else {
+ } else if !self.active {
vec![&self.network]
+ } else if let FormatTemplate::Str(s, None) = &self.format {
+ // This is heckin ugly
+ if s == "" {
+ vec![&self.network]
+ } else {
+ vec![&self.network, &self.output]
+ }
+ } else {
+ vec![&self.network, &self.output]
}
}
Perhaps the spacing could be changed (set_spacing) when the format string is empty, assuming there are no other widgets after it. The same fix would be required everywhere that uses a format string, however realistically I doubt anyone is using an empty format string for blocks apart from net/battery that can provide info with only their block icon.
Perhaps the spacing could be changed (
set_spacing) when the format string is empty, assuming there are no other widgets after it. The same fix would be required everywhere that uses a format string, however realistically I doubt anyone is using an empty format string for blocks apart from net/battery that can provide info with only their block icon.
I am using the sound-block as an indicator for my microphone.

[[block]]
block = "sound"
driver = "pulseaudio"
device_kind = "source"
format = ""
step_width = 0
on_click = "pactl set-source-mute 1 toggle"
@HackHerz Does #1071 cover that case for you?
@quantizzed #1072 should cover your first example with the net block
@HackHerz Does #1071 cover that case for you?
Yes, thanks a lot :)
Is this issue resolved? If not, what blocks still have uneven spacing?
Haven't bisected but noticed double spaces when trying to disable icons by setting them empty. For example:
[icons.overrides]
time = ""
[[block]]
block = "time"
gives "full_text":"□□Wed 24/03 18:03□"
@ammgws That's because icons_format is still being applied. It's better to disable icons by setting icons_format = " " (it can be set for each block individually)
Ah yeah forgot about that.
Hmm, for the net block is there no way to disable just the block icon but leave the ones for speed_up etc as-is?
I guess in that case you have to set icons_format to "{icon}" and override all the icons you use in the net block to contain spaces.
But yeah, it's far from being convenient.
Maybe make an exception somewhere here
https://github.com/greshake/i3status-rust/blob/ef2e881308486e58becdd4c264dc5191b65854cd/src/config.rs#L61-L70
not to apply icons_format for empty icons?
@quantizzed #1072 should cover your first example with the net block
Thanks, is there any way to check?
Edit: OK, I checked and spaces around the VPN icon in the net block are now even:

However, the battery block icon still has uneven spaces around it.

However, the battery block icon still has uneven spaces around it.
@quantizzed Can you provide your configuration for battery block? Because it works for me.
However, the battery block icon still has uneven spaces around it.
@quantizzed Can you provide your configuration for battery block? Because it works for me.
It's quite simple:
[[block]]
block = "battery"
driver = "upower"
format = "{percentage} {time}"
What's it look like when the battery isn't at 100%?
