cyring / CoreFreq

CoreFreq : CPU monitoring and tuning software designed for 64-bit processors.
https://www.cyring.fr
GNU General Public License v2.0
1.97k stars 126 forks source link

Terminal transparency in corefreq-cli #254

Closed leaty closed 3 years ago

leaty commented 3 years ago

Largely unimportant, but I thought I'd ask anyway. Currently it looks like the following in urxvt:

screen 2021-06-13 18 20 02

While e.g. htop looks like this:

screen 2021-06-13 18 20 53

Is this already possible? Or could I at least achieve this with a custom corefreq-cli-rsc-theme-usr1.h?

I'm absolutely loving this regardless, but it could look nicer if it didn't override the background.

cyring commented 3 years ago

Hi, I'm still wondering about getting such transparency! I wish I would achieve that in future.

Sure you can customize corefreq-cli-rsc-theme-usr1.h. That's its purpose.

You can even create corefreq-cli-rsc-theme-usr2.h if you want me to make it part of the project as a second theme.

leaty commented 3 years ago

I'm still wondering about getting such transparency! I wish I would achieve that in future.

Highly recommend it! It looks especially great with a smooth video background.

  • There's a great chance you will need new color combinations (fg, bg), not provided yet by the macros: please let me know about all variations you need, I will provide them.

Actually, most terminal programs avoid setting any background colors, so as to use the default user preferences instead. Is this possible with a macro here as well?

cyring commented 3 years ago
  • There's a great chance you will need new color combinations (fg, bg), not provided yet by the macros: please let me know about all variations you need, I will provide them.

Actually, most terminal programs avoid setting any background colors, so as to use the default user preferences instead. Is this possible with a macro here as well?

You mean altering the color palette ? Like changing the components {bg, fg, highlight and underline} of the current implemented macros ?

leaty commented 3 years ago

Yeah pretty much avoiding to set bg at all. Because if you do set it, it will override the global terminal settings.

Imagine two users with transparency, but each of them have different opacity and background colors configured. If you don't set bg at all, it should use their own configuration or the terminal defaults instead.

leaty commented 3 years ago

I read somewhere, that in ncurses, you use -1 to use the terminal default. I'm not sure if the same would work here but maybe. I'll give it ago!

cyring commented 3 years ago

Yeah pretty much avoiding to set bg at all. Because if you do set it, it will override the global terminal settings.

Imagine two users with transparency, but each of them have different opacity and background colors configured. If you don't set bg at all, it should use their own configuration or the terminal defaults instead.

Background of a zero value ?

There is a special value in CoreFreq UI which is zero in every components. Definition{.fg=0, .bg=0, .un=0, .hi=0} which translates to zero, informs the UI fuse function to continue without that character. https://github.com/cyring/CoreFreq/blob/ad622ca5e4cdb8a503da31a1049df609cd0545be/corefreq-ui.c#L1835

If transparency is based on zero then it's unfortunately not feasible.

leaty commented 3 years ago

After you showed me FuseAll, I got it to work by removing the following lines which are writing the background sequence :tada: https://github.com/cyring/CoreFreq/blob/ad622ca5e4cdb8a503da31a1049df609cd0545be/corefreq-ui.c#L1889-L1891

screen 2021-06-13 21 35 20

If transparency is based on zero then it's unfortunately not feasible.

I think I can still make this a theme with an if check in FuseAll, say if bg is -1, then skip those 3 lines. What do you think?

cyring commented 3 years ago

After you showed me FuseAll, I got it to work by removing the following lines which are writing the background sequence 🎉 https://github.com/cyring/CoreFreq/blob/ad622ca5e4cdb8a503da31a1049df609cd0545be/corefreq-ui.c#L1889-L1891

screen 2021-06-13 21 35 20

If transparency is based on zero then it's unfortunately not feasible.

I think I can still make this a theme with an if check in FuseAll, say if bg is -1, then skip those 3 lines. What do you think?

Oh ! Nice Let me handle this case. I have to evaluate all the drawing impacts, especially surface clearing, resetting and so on. I will also test with uxrvt

For latency reasons, I'm thinking about a new build directive to not compile the lines you are showing; rather than a runtime branch condition.

FuseAll is indeed the hot-spot of the Cli and UI call flow.

leaty commented 3 years ago

Alright sounds good, I'll configure a theme meanwhile and make a PR. Seems like the only changes I'd have to make basing off the original theme is to set white text for everything that previously had a white background (like the menus).

leaty commented 3 years ago

I know C is not my forte, but I can't seem to find the menu item color. I modified all lines which had bg = WHITE and replaced fg = BLACK with fg = WHITE, but it still looks like this:

screen 2021-06-13 23 09 05

cyring commented 3 years ago

I know C is not my forte, but I can't seem to find the menu item color. I modified all lines which had bg = WHITE and replaced fg = BLACK with fg = WHITE, but it still looks like this:

screen 2021-06-13 23 09 05

I will check tomorrow, but for now I suggest you first test your color without transparency.

EDIT: also note that:

  1. Pure console rendering matters. Please also test in VT.
  2. The console underline is forced to cyan. You'll have to compose with that.
  3. No PR yet. I think about creating a development branch for the transparency enhancement.
cyring commented 3 years ago

Thanks to your tips, I'm adding the new branch develop-ui-transparency in which you can push your PR.

Like you, using urxvt -tr with Awesome DE, UI menus are fully blank except the dimmed braces These are among of the impacts I hope we will solve with just some color choices.

It's clear now that it's more appropriate to provide a second resources theme dedicated to transparency. I'm preparing this for next commit.

cyring commented 3 years ago

Please pull branch develop-ui-transparency, you now have a new file corefreq-cli-rsc-theme-usr2.h in which you can customize the transparency theme. FYI, this file is a copy/past/rename of the default color theme.

leaty commented 3 years ago

Awesome! I'll have a look after work, I really need to find the menu foreground though.

This is irrelevant but I thought I'd mention that -tr is not true transparency so it does not work with either a moving background, or if you have any floating windows behind it (tiling masterrace of course). Instead you can use e.g. *background: [80]#313842 in .Xresources, or if you use pywal like me- it has an option for both opacity and color bg. Since this is true transparency, it will require a compositor like picom or others.

EDIT: Don't forget xrdb .Xresources if you decide to try the above.

cyring commented 3 years ago

Awesome! I'll have a look after work, I really need to find the menu foreground though.

This is irrelevant but I thought I'd mention that -tr is not true transparency so it does not work with either a moving background, or if you have any floating windows behind it (tiling masterrace of course). Instead you can use e.g. *background: [80]#313842 in .Xresources, or if you use pywal like me- it has an option for both opacity and color bg. Since this is true transparency, it will require a compositor like picom or others.

EDIT: Don't forget xrdb .Xresources if you decide to try the above.

cyring commented 3 years ago

Other things on the rxvt todolist:

leaty commented 3 years ago
* ( which can still be moved with [`SHIFT`] + {`q`/`z`/`d`/`s`} )

I see, qzds is like qwerty's wasd but for azerty right? What's your opinion on hjkl keys which is standard in many programs? Might be a nice addition.

cyring commented 3 years ago
* ( which can still be moved with [`SHIFT`] + {`q`/`z`/`d`/`s`} )

I see, qzds is like qwerty's wasd but for azerty right? What's your opinion on hjkl keys which is standard in many programs? Might be a nice addition.

I forgot to say wasd are also ready to play. I'm also an AZERTY user.

I made getkey to scan keys. The resulted scankey is a 64-bits value I will just have to add into the UI events loop.

cyring commented 3 years ago

OK, the RXVT keysym are now implemented in latest develop-ui-transparency

leaty commented 3 years ago

Oh nice, yeah I really thought you meant only qzds. Still, hjkl would be fancy. Unfortunately I have to retract my statement that I would attempt to fix the menu's today, I simply got no time for it I'm afraid. I'll get back to you once I got something.

cyring commented 3 years ago

Unfortunately h, k and l are already programmed as other shortcuts

cyring commented 3 years ago

Hello,

Thanks for your PR. This is what I'm getting (with my wallpaper) CoreFreq_Transparent_UI

leaty commented 3 years ago

Is that an inactive window getting the grey text? How do you open multiple windows?

Here is mine: screen 2021-06-20 03 20 55 screen 2021-06-20 03 21 12

leaty commented 3 years ago

Oh I see, you have to use F keys to open menu again. Here's an equal view:

screen 2021-06-20 03 26 30

leaty commented 3 years ago

I suppose it will depend a little on your colorscheme and wallpaper/terminal background color and opacity settings, but 100% transparency like your example is often hard to pull off unless your colorscheme contrast is high enough on it's own to your wallpaper.

leaty commented 3 years ago

Yeah I double checked, the grey text on the inactive window does match a color which other cli programs seem to use. It just looked poorly in your example, so I'd say it's correct without modifying :+1:

Notice the percent signs and such: screen 2021-06-20 03 36 24

cyring commented 3 years ago

Hi

leaty commented 3 years ago

I have observed that some Linux distributions are altering the color palette.

Yes, some.

That's why you get yellow where I'm having magenta for the same color index encoded in your theme.

No, the colors you are seeing on my examples are custom. I grab one frame from video backgrounds and then I let pywal generate a color scheme based on the image.

In tty however, I am still using the default arch colors, and the inactive window in corefreq is definitely a little darker grey, but it still works fine because- of course it's a completely opaque black background.

I just meant that the grey color is typically bright enough to work with transparency, while the black color is often too dark (as seen previously in the menus). So, I think the grey color is reasonable, notably since other programs often use the same. After all if you do opt for transparency, there will always be a certain colorschemes that will not work well with certain backgrounds. It's up to the user to match them properly contrast-wise.

For instance, with the convenience of changing the color palette and wallpaper, live- using hotkeys. I can make this happen, and as you can see it doesn't really match very well.

screen 2021-06-20 15 47 47

leaty commented 3 years ago

What I think is best to pay attention to when it comes to transparency, is to use the more common color codes, which you have already done in corefreq's default theme. It was just the black (0) color that- as far as I have seen, is rarely if ever used in cli programs. Unless of course you have a background color, which the default theme had (white background on menus), only then the black foreground works.

But let me know if you find something you consider should be changed in the theme.

cyring commented 3 years ago

pywal is a nice piece of code and it confirms I should not touch the RGB palette. Things I thought about for the UI

I'm relying on your theme customization. That's the whole purpose of a user theme. If bug solving or enhancements are needed in the UI code, just let me know. Or, if job is done, I'm able to merge into master whenever you're asking me for it.

leaty commented 3 years ago

I should not touch the RGB palette

I agree, and you did it very well. I used magenta for select/focus to make the windows pop a little more, because it was the least used color in the interface. Since with transparency there is no background color to offset contrasts.

Everything I've tested so far works perfectly, I think it's ready for master :+1: