Closed the1ts closed 3 years ago
column should be available in all arch based distros as well, as it's part of util-linux, however there might still be distros that don't have it. A more universal solution is always better, especially considering that this is a core part of the script.
As to the formatting, it looks promising but also a bit wonky right now.
Ideally, the columns would all line up.
I agree on the universal ideally will investigate a few more distros for column.
As to the not lining up, I think that is due to not using a mono spaced font. As you can see the ll in fall is in no way the same size as ES in ESL. With only text based methods (space and tabs) rather than layout methods available (I tried using pango alignment), I'm not sure we can do more than force a mono spaced font.
Overriding font (-font) with a universal mono spaced font, Courier for example, may fix that.
Lines up very nicely with a mono spaced font indeed. Looks amusingly terrible though, and forcing a font seems bad.
There are some nice mono spaced fonts out there, I'm personally a big fan of Source Code Pro, which looks great in a terminal, but very unfitting here, as subjective as that opinion is.
Not sure about this right now.
I thought about this for a bit. Something we could do is add another config option and let the user decide between this new "compact" view and the old legacy view, with the limitation of the compact view being that a monospace font is forced. And then maybe add yet another config option to easily select a font?
An additional issue with this is that the necessary width to display all information varies a lot based on the name of the streamer and the game. People who use rofi for it's original purpose might have set up their window size such that it is quite small and basically useless for this. This is already a bit of an issue with the submenu, but that is at least static. I looked at the rofi wiki and afaik there's no way to have the width dynamically scale with the contents.
Mainly just thinking out loud here.
Took a look at font handling in rofi, there is a nice rofi -dump-xresources
which gives the font and size from config files, both .Xdefaults or .Xresources. We can use that and rofi config file to get the font and font size used by the user.
That leaves us with font mono spaced picking, fc-list :spacing=mono | cut -d : -f 2 | sort | uniq
will give a list of mono spaced fonts available. If the discovered font is in that list we can simply use, else we can rely on fontconfig to pick a mono spaced font by using -font "mono $FONT_SIZE". Of note, my dump-xresources is simply "mono 12" which is the default font for rofi config since I have no font set in rofi config or .Xresources. User could also be allowed to override with a FONT="Fontname Fontsize" value in the kpl config file, this format is the same as rofi config requires.
I have a method in mind to find the max width of streamer game viewers so can size the rofi window to that value. Simple while read loop echo'd to wc -m using sort -n and tail -1 to find max.
Need to work on those pieces together then can put in a if/else to handle legacy/expanded view config item.
Does that sound an acceptable set of solutions?
That all sounds good to me, lost me a bit at sizing the rofi window but that's why I'm starting uni next week :p
Worked a little on the expanded view with the 2 new config items, would appreciate some more eyes on it.
In short, the first monospaced font found is used, i.e. FONT variable from kpl config, rofi config, xresources config or defaults to "mono 12" which is rofi's default. Doesn't change anything with fonts, streams menu or width unless the new VIEW variable is present and set to expanded.
and by the way, enjoy your time at uni, I certainly did.
Okay, this is a lot of lines.
I'm not getting this font behavior though. I have no font set in kpl config (FONT=) and a non-monospaced font set in rofi config (Dejavu Sans 12). It should default to mono 12 (right?), but it remains Dejavu Sans 12. This might have something to do with the fact that fc-list :mono | awk -F : '{print $2}' | sort -u
includes "Dejavu Sans Mono" but I'm not sure.
More bizarrely, if I use FONT="mono 12" in kpl config it's still remains Dejavu Sans 12. I assume this all worked for you so there must be something wrong with my setup, but I went over it like 3 times. All with expanded view setting of course.
Right it works with Arial 12 and Helvetica 12 but not with Dejavu Sans 12 (or Dejavu 12). So it must be a specific bug
Last commit wraps each discovered monospaced font with single quotes and checks our font wrapped by single quotes. Fixes the partial line grep issues found.
Yep that works, nice one.
The dynamic width solution mostly works too. Increasing the font size is a nice way to scale the window up. There are some inconsistencies though.
Using TerminessTTF Nerd Font: 10 - only shows 2 first viewer numbers and ... unless less than 1000 viewers 12 - works perfectly 14 - same as 12 but extra space on the right 16 - same as 12 but no space on the right 18 - works perfectly 20 - same as 12 but extra space on the right 22 - same as 12 but no space on the right
Similar but not exactly the same patterns with Mono, Nimbus Mono PS, Source Code Pro and Dejavu Sans Mono. Mono is perfect at 10 and a bit broken at 12 for example.
Is this something that can be corrected without too much effort? The slight space variations aren't really an issue but at least mono 12 should work okay if it's default for rofi.
Hmm, I'm unable to see any differences in padding or cutoff characters between font or font size on Mono, DejaVu Sans Mono, TerminessTTF Nerd Font Mono, Courier or Courier New. All show with the same padding on the right. That is on a couple of Debian Stable Systems running different GPU but both on 1440p hi-dpi screens.
I'm not sure if this is a kpl issue and perhaps not a rofi issue. Looks like a font rendering issue.
I've tried one thing that may help, change line 274 to the below, it calculates width in pixels not characters. Still displays fine on my setups, would be good to try I guess. So width is characters +2 times font size.
MAIN=$(echo "$STREAMS" | _rofi -font "$FNAME $FSIZE" -width $((($WIDTH +2) * $FSIZE)) -dpi 0 -theme-str 'inputbar { children: [prompt,entry];}' \
If that fixes the issue, we could use width in pixels rather than characters by using that calculation to get around whatever library/font render issue you are seeing on arch.
That actually seems to make it worse.
I'm actually on manjaro and I don't think I had any font rendering issues before. If it is just me then I don't care, I can just fix it by using a different font size and that's fine. But it might be an issue for others so idk.
I'll just merge this anyway
uhhhhhhh this is what it looks on my 1080p vertical monitor
Is there some sort of a connection between max screen width?
Okay, sorry for the confusion. Disregard the pics in the last two comments. There was something in my testing script that screwed with this. I made a new copy from the main script, and added monitor, xoffset and yoffset parameters to the main rofi function to test it.
With the original code it looks like this:
and with -width $((($WIDTH +2) * $FSIZE)) -dpi 0
it looks like this:
Is it possible for you to test it on 1080p?
Thanks for trying out some things. I'm not 100% sure where the issue lies, it might be related to screen size or simply a difference in libraries or other pieces on the rendering side. According to the man page etc, Rofi does quite a bit of guessing on screen size, dpi etc. It also allows three different measures of width -number being characters, number 1-100 is % of screen width, 101+ is pixels.
I was going to look at sizing the second screen based on the same technique of counting characters. But until we understand this issue and get a solution its not right to "infect" more of the default running of kpl.
I don't have a 1080p monitor, but dropping resolution to 1080p still doesn't show the width issue here.
What font and size are the last screen shots from? and where is the font being set, kpl config, rofi config or .Xresources/.Xdefaults? One last thought, what theme is this, I've removed my use of grubox-dark to see if this affects, but still can't get any not expected output.
Using mono 12 set in kpl config. If I change the font, and keep the size the same, the width does not change. Which is good.
As to the theme, it's custom. I can send you the rofi config file and maybe you can replicate this.
https://gist.github.com/jp1995/a68ce85e7d15528631398f1070fe2a5e
Interesting, mono 12 will use fontconfig to pick a monospaced font. What does fc-match mono
show?
Oh. DroidSansMono.ttf: "Droid Sans Mono" "Regular"