-
-
Notifications
You must be signed in to change notification settings - Fork 278
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Required "beautiful" library is bad practice approach #274
Comments
Can you elaborate this? (I don't know every widgets from this repo so I may have missed something) From what I can see in the current code, the usage of the beautiful library is exactly what it was designed for. Beautiful is exposed as a singleton (https://en.m.wikipedia.org/wiki/Singleton_pattern), it has no incidence to This is the case of widgets from this module. All the access to beautiful properties are done in widgets constructor(/instances?). It is the responsibility of the user to initialize beautiful before creating widgets. I don't see anything abnormal here.
Why? I don't see why a third party module couldn't use these theme variables. Every "base" widgets from awesome also uses these variables [1]. The main advantage of doing so is to keep the theme consistent without needing the user to define X times the I can understand why you want custom theme variable, but you should ask it a as feature request instead of doing a rant... (and maybe propose a PR, this is not hard to implement, but time consuming) [1] Most widgets defines their own custom theme variables but they defaults to "base" variables in case it's not part of the user theme. |
The reason is that the assembly of panel with widgets is part of theme.lua (or some additional modules which are part of theming, not part of rc.lua, like for example copycats). to usage registration of listener for define panels and its widgets: but in this case the connect_signal method is called from theme initialization part, not by previous "hack" Yes, there is still possible to create some additional function inside the theme and call it again similar way as previous hack in rc.lua, but it is workaround and not necessary for I'm using this approach 2 years, and I haven't problems with any other widgets, because beautiful was not directly used inside the common widgets. I found the problems with these widgets:
Main problem are widgets where is using just beautiful inside methods and functions. Or worst in the initialization part in worker function without possible input parameters for configuration support of widget. Good example of much more better approach is visible in the "nice" git plugin (you know it, we discuss some correction in few days before). https://github.com/mut-ex/awesome-wm-nice As benefit, the "beatiful" will be taken in the initialization part only. The "large" widget has to operate with private fields only not with "beautiful" mapping in every widget method. Any time, any developer can change just ONE initialization line for other colors or parameters, not change 15 places with beatiful.bg_normal, or bg_focus, or bg_urgent or tons of additional colors which are "mapped" to the widget. This mapping has to be just one in the initalization part as default (not without input parameters) and add correctly defined input parameters too. |
Oh ok! I wasn't very familiar with the awesome-copycat code base. I took a closer look at their code with your explanation. Now I understand better what you are doing/what you want. (My personal point of view : I'm honestly not convinced by this design, beautiful shouldn't be responsible for instantiating widgets. I quickly checked the source code for fs-widget (the first one you mentioned). The hard dependency on beautiful can be removed as you suggested by adding parameters/specifying defaults in the widget. I think it would be enough to allow the usage of the widget from the theme (correct me if I'm wrong).
I totally agree with you! This is a very good design. (I would however, have added a fallback on beautiful variables before the defaults from module.) I used a similar approach with some of my custom widgets and I'd like to enforce this design/pattern to standard awesome widgets (right now, most of the widgets do the test "property vs beautiful vs default" every time we need a theme variable). |
Thank you very much for a constructive criticism, I really appreciate it! The idea is simialr to the one in nice - define widget's config parameters inside the widget, then, if beautiful is not nil, fallback some of them to beautiful (I'm using the basic ones: bg/fg_normal/focus/urgent, which I think are defined in most of users' configs), and then allow user to override them. |
Thank you too, very nice PR. |
I checked widgets inside this git project.
There are several problems which preclude general usage of this library (for example against lain libs).
I will describe few points for beginning:
AW is very good WM. Good and robust widgets can improve this WM to new level.
The text was updated successfully, but these errors were encountered: