davatorium / rofi

Rofi: A window switcher, application launcher and dmenu replacement
https://davatorium.github.io/rofi/
Other
12.81k stars 610 forks source link

Use xresources in rasi theme #756

Closed budRich closed 6 years ago

budRich commented 6 years ago

:arrow_right: First read the guidelines! :arrow_left:

Version

Version: 1.4.2

Launch Command

.Xresources

#define fnt3 FixedSys
#define fsz1 12
rofi.font:                fnt3  fsz1
rofi.theme:               oneliner

rofi.color-enabled:       true

! State:           'bg',     'fg',     'bgalt',  'hlbg',   'hlfg'
rofi.color-normal: #000000,  #002b36,  #eee8d5,  #586e75,  #eee8d5
rofi.color-urgent: #000000,  #dc322f,  #eee8d5,  #dc322f,  #000000
rofi.color-active: #000000,  #268bd2,  #eee8d5,  #268bd2,  #fdf6e3

!                  'background', 'border', 'separator'
rofi.color-window: #000000,      #002b36,  #002b36

Steps to reproduce

add above stuff to ~/.Xresources
xrdb -load ~/.Xresources
echo "" | rofi -dmenu

What behaviour you see

Font and font size defined in xresources is applied, but not colors. If i remove the line:
rofi.theme: oneliner

The colors are applied to the default theme.

What behaviour you would like to see

colors defined in .Xresources being available in the theme file so they could be used. I guess possible solutions oculd be either to to set the colors in the global section of the theme to whats gathered in .Xresources or being able to get resources from within the rasi file with: @xres-background or something.

Thanks so much for all the effort you guys have put in to rofi, it is a truly great launcher and by surpasses all alternatives. I hope yu consider this feature request. Then colors could be modified in xresources (which makes unified theme (i3/polybar/rofi) setting up much more convenient), but the layout of the menu can and should be done in the excellent rasi format.

sardemff7 commented 6 years ago

.Xresources is going to disappear in a future release, so you should rely on the rasi format as much as possible from now on.

DaveDavenport commented 6 years ago

This is intended behaviour.

(Partially) Because of the upcoming wayland support, xresources will be dropped in the future. We are currently in a transitional period (that is why they are internally converted into rasi (default) theme, you can actually see this theme by using -dump-theme).

budRich commented 6 years ago

Ok. Is it possible to have like global color definitions for all themes in a separate file then? I tend to use three different themes(layouts) depending on what kind of menu i'm displaying, and i don't change colors that often, but when i do, I need to change all theme files individually. It's not a mega big deal, a simple awk script changes the coloras in the global section on each theme now, but i relly think you guys should consider some way to define global colors. Personally i see no point in dropping .Xresources, is the current feature causing any problems? You could limit xresources to only colors and fonts but force all layout to rasi files.

Also, is there a way to modify the layout of the rasi generated by xresources?

DaveDavenport commented 6 years ago

If you check out the rasi format you will see that it is actually possible to have all the colors defined in one 'global property section' and reference these from the theme. These can be a separate file and imported, it is even possible to override individual colors from this section via a commandline argument or import another color set via the commandline.

You can have a theme: a-color1.rasi that contains:

@import "mytheme.rasi"
@import "mycolors1.rasi"

The new system is actually nicer for this.

There are good reasons for dropping the xresources format, as mentioned above the main reason:

Furthermore with the new format:

budRich commented 6 years ago

That's great!

I have been playing around with themes for a couple of days and the rasi format is truly great. And this @import was the missing piece for me, don't know how i missed it from the docs.

And I understand if you drop xresources now. It will just get confusing with two totally different ways to do the same thing. And I made a simple script that fetches xresources values and sed them into rasi or any other file that doesn't natively support xresources and it worked good.

On a sidenote, i am creating some tutorial videos about linux ricing, tweaking and such. The next videos will be about how to set up rofi with themes and some more advanced use with -dmenu option enabled. Is there some forum or community page for rofi where i can link these videos when they are made? (they will probably be up in a couple of days).

Keep up the good work!

DaveDavenport commented 6 years ago

There is a reddit I currently use: https://reddit.com/r/qtools/

I am planning to revive the website again that links to different online sources. Videos would be very welcome!

budRich commented 6 years ago

Cool. A website or maybe some kind of hub to share and browse custom themes would be great. I let you know when the videos are up.

DaveDavenport commented 6 years ago

Something like: https://github.com/DaveDavenport/rofi-themes

budRich commented 6 years ago

:) great. I might submit some themes there later. I posted a link to one of the videos on reddit. I really like doing these videos and if you have any requests I can make some more on rofi, i can even "donate" some custom videos that's more about general rofi usage and tone (not promoting my name or style and such and not using things like i3, solarized et.c.) and you could host it at your own channel or other video service. Maybe 5, 5 minute videos about different features or something like that. just some thoughts.

tangxinfa commented 5 years ago

I don't think any system tool application like rofi has a private theme system is a good idea, it's better to adhere desktop system's theme. Rofi can use rasi format to configuration layouts, but should still support use colors defined by Xresource.

budRich commented 5 years ago

One compromising solution could be something like this:

.Xresources

rofi.vars.mycolor1 #FF00FF
rofi.vars.mycolor2 #00FF00

xresources vars will be available as variables in rasi in the same way as if a global variables file was included:

theme.rasi

#element selected {
  text-color: @mycolor1;
  background-color: @mycolor2;
}

with this approach both methods could be used, even in conjunction with each other.

Personally I think it's up to the developers how they want to apply styles. And implementing xrdb, adds a lot of work and extra dependencies, also xrdb syntax is terrible (you can't have a variable name if a resource have the same name (#define rofi #FF00FF <- this would for example break all rofi.* resource definitions). And I have seen many projects abandoning or excluding xresources (dunst f.i.), also xrdb is bound to xorg, meaning more or less bound to linux, and harder to upgrade to wayland.

DaveDavenport commented 5 years ago

I don't think any system tool application like rofi

Rofi is a system tool? what defines a system tool?

has a private theme system is a good idea, it's better to adhere desktop system's theme.

What desktop system's theme? many different DEs have their own theme system, a lot of standalone WMs has none or not exposed.

Supporting multiple systems is a lot of work and a battle lost before it started.

sardemff7 commented 5 years ago

Xresources is nothing like a “system” theme, it is a loose variable/setting framework with. Xresources requires a specific dependency (xcb-xrm) to work, or a rollback to Xlib (which is worse). Xresources requires glue code that is a burden to maintain and slows some of the features to appear because they’d require more glue code.

rofi will drop Xresources support are no more efforts will be made on adding features to it. In the mean time, please migrate to the rasi format.

xrdb is bound to xorg, meaning more or less bound to linux, and harder to upgrade to wayland

Linux is irrelevant here, both X11 and Wayland work perfectly on Linux. If anything, the Wayland compositors are even less portable, though there is work to port the relevant code to work of *BSDs. (I even kind of started work to make it usable on Windows.)

budRich commented 5 years ago

@sardemff7 that was what i meant, by bond to linux, the current xrdb support is one thing making it difficult to port to bsd/windows. And i see no reason why all functionality of rofi wouldn't work on windows or BSD, and i think that especially on windows this would be a very welcome application.

I know i started this issue, and i am glad i did, you guys got me re evaluate some opinions, and I now think that all good gui applications, especially ones that are like rofi, and totally "DE" agnostic, with few and simple GUI elements, should have their own theme "engine", especially with the stupid never ending GTK/QT "war", and the totalitarian vibes that the GNOME are spreading.

It's better if we can say that json, is the default (which it more or less is) config system, but then make it fit the application in the best possible way, like rofi. And then all we lame ricers, just learn jq, and have consistent colors everywhere for ever!

sardemff7 commented 5 years ago

First, Xresources are an X11 thing, and BSD have been using X11/Xorg ages now…

Second, rofi’s rasi format is CSS syntax with custom properties, not JSON at all, and is in no way parseable by JSON parser.

And rofi (thanks to libnkutils) will try its best to use some of the DE-specific settings, like icon theme, but widget theming is a completely different level. I feel like CSS is a great language for that, and both GTK+ and Qt are using (variants of) CSS, so maybe some day we’ll see some standard on that and rofi could use that.

budRich commented 5 years ago

ok. glhf

tangxinfa commented 5 years ago

One my personal requirements is output partial of emacs's current color theme to Xresource file, and reference these colors in polybar and rofi's config file. So when i change my emacs's theme(especially at sunset), my desktop will keep the same look.

Technically rofi drop Xresources is a good idea, i will export a css version of my emacs theme colors for rofi.

Thanks all.

pinpox commented 5 years ago

output partial of emacs's current color theme to Xresource file, and reference these colors in polybar and rofi's config file. So when i change my emacs's theme(especially at sunset), my desktop will keep the same look.

Sorry for the offtopic, but that sounds great! How do you do it? I'd love to just have to change the emacs theme and have my system adapt to it!

sardemff7 commented 5 years ago

Do not hijack issues for anything not directly related to them. You can contact people via other means (the most obvious being the email on their Github account).