-
-
Notifications
You must be signed in to change notification settings - Fork 696
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
Widgets from default config are alive while is not used #251
Comments
My understanding is that the default config is loaded so that whatever is missing from the users config is taken from the default file, so if you do not define screens object in your config, you get the default screen instance. |
Yes it is right, but I have screens defined in my config. I think it would be better to don't initialize unneeded values in default_config. We can initialize missing values in confreader. I can write a patch for that... Would it be acceptable solution? |
Or maybe the whole config logic should be refactored to use a Config class singleton object?.. Configuring qtile using a derivied Config class looks better than a config module and a default_config.py hack, imho. It could be added as alternative configuration way. |
Hm... no, looks like really there is no difference... |
The whole default_config.py setup is not that old (at least not the working one). Default values for some lesser used configuration variables are currently set using the default_config.py file through libqtile.config. Removing this mechanism will mean creating a new way to set default values. It might be worth looking to see how it was done before default_config.py I think an alternate set of values should be set for this purpose, the default_config.py clearly should only be used where the users config is absent or broken. Maybe the widget/layout defaults mechanism would be appropriate??? |
And what about the way I did it in my commit 5f0df30 ?
Do you mean defaults which are discussed in #234? Hmm, I doubt that it could be appropriate here. And as I understand it itself going to be replaced by something more accurate... |
@tych0 your commit doesn't fix the problem, as it is only a style change. |
Ah, true, python isn't a lazy language :-). I'll fix it in a sec.. |
Don't understand how, but it really fixes the problem in my case 0_o. Hmmm. Oh, it now just doesn't call _configure for initialized widgets. So, with the current Clock widget implementation (not mine which runs the timer from _configure) it calls the default_config.screens[0] panel Clock widget's .update method one time per second. Plus, the another one - for the Clock widget which is on the panel which is actualy displayed. diff --git a/libqtile/widget/clock.py b/libqtile/widget/clock.py
index 6d40593..67175d0 100644
--- a/libqtile/widget/clock.py
+++ b/libqtile/widget/clock.py
@@ -26,9 +26,11 @@ class Clock(base._TextBox):
"""
self.fmt = fmt
base._TextBox.__init__(self, " ", width, **config)
+ import ipdb; ipdb.set_trace()
self.timeout_add(1, self.update)
def update(self):
+ self.log.error("I'm called!")
if self.configured:
now = datetime.datetime.now().strftime(self.fmt)
if self.text != now: You can see there is two "I'm called!" messages per second: ei-grad@ei-grad repos/qtile (develop *%) » DISPLAY=:1 python2 ./bin/qtile 1 ↵
> /home/ei-grad/repos/qtile/bin/libqtile/widget/clock.py(30)__init__()
29 import ipdb; ipdb.set_trace()
---> 30 self.timeout_add(1, self.update)
31
ipdb> c
> /home/ei-grad/repos/qtile/bin/libqtile/widget/clock.py(30)__init__()
29 import ipdb; ipdb.set_trace()
---> 30 self.timeout_add(1, self.update)
31
ipdb> c
Fontconfig warning: "/etc/fonts/infinality/conf.d/41-repl-os-linux.conf", line 16: Having multiple values in <test> isn't supported and may not work as expected
Fontconfig warning: "/etc/fonts/infinality/conf.d/41-repl-os-linux.conf", line 29: Having multiple values in <test> isn't supported and may not work as expected
Fontconfig warning: "/etc/fonts/infinality/conf.d/41-repl-os-linux.conf", line 39: Having multiple values in <test> isn't supported and may not work as expected
Fontconfig warning: "/etc/fonts/infinality/conf.d/41-repl-os-linux.conf", line 48: Having multiple values in <test> isn't supported and may not work as expected
Fontconfig warning: "/etc/fonts/infinality/conf.d/41-repl-os-linux.conf", line 60: Having multiple values in <test> isn't supported and may not work as expected
Fontconfig warning: "/etc/fonts/infinality/conf.d/41-repl-os-linux.conf", line 71: Having multiple values in <test> isn't supported and may not work as expected
Fontconfig warning: "/etc/fonts/infinality/conf.d/41-repl-os-linux.conf", line 82: Having multiple values in <test> isn't supported and may not work as expected
Fontconfig warning: "/etc/fonts/infinality/conf.d/41-repl-os-linux.conf", line 92: Having multiple values in <test> isn't supported and may not work as expected
2012-12-26 20:52:10,667 qtile update:33 I'm called!
2012-12-26 20:52:11,426 qtile update:33 I'm called!
2012-12-26 20:52:11,429 qtile update:33 I'm called!
2012-12-26 20:52:12,419 qtile update:33 I'm called!
2012-12-26 20:52:12,426 qtile update:33 I'm called!
2012-12-26 20:52:13,418 qtile update:33 I'm called!
2012-12-26 20:52:13,426 qtile update:33 I'm called!
2012-12-26 20:52:14,418 qtile update:33 I'm called!
2012-12-26 20:52:14,431 qtile update:33 I'm called!
2012-12-26 20:52:15,418 qtile update:33 I'm called!
2012-12-26 20:52:15,426 qtile update:33 I'm called!
^C---------------------------------------------------------------------------
KeyboardInterrupt Traceback (most recent call last)
/home/ei-grad/repos/qtile/bin/qtile in <module>()
87 if __name__ == "__main__":
88 locale.setlocale(locale.LC_ALL, locale.getdefaultlocale())
---> 89 q = make_qtile()
90 try:
91 q.loop()
/home/ei-grad/repos/qtile/bin/libqtile/manager.py in loop(self)
561 context = gobject.main_context_default()
562 while True:
--> 563 if context.iteration(True):
564 try:
565 # this seems to be crucial part
KeyboardInterrupt: So, may be I'll make a pull request with 5f0df30 ? |
Ah, good point. I guess I'd like to keep the default config out of confreader.py if possible. Is there some way we can leave default_config.py mostly intact (e.g. perhaps just have a function that will tack on missing stuff in there?). |
I think a slightly different approach is needed. default_config should not be providing values for the users config. If some values need defaults (like auto_fullscreen) they should be defined in configreader not default_config. We should not have default values for required config objects, like keys or groups... |
I have applied my thinking to ei-grad's config branch in my confreader branch https://github.com/cjbarnes18/qtile/tree/confreader. |
I have re-based my branch on the current develop and have all tests passing, so unless you guys have any other ideas I will send a pull request. |
I guess I'd like to find a way to keep the default config intact, it's nice to have a place we can point to that says "here's the defaults". Additionally, it seems odd to have default values in the config "parser" itself. Is there some way we can keep default_config.py but still initialize things lazily? |
I think the best solution for this will be to have an .ini-style config. |
Wouldn't we lose a lot of power then? Some of the more advanced configs make use of python functions at minimum. Switching config paradigms seems like making a mountain out of a molehill for this problem. |
No, I mean .ini config as alternative. |
ini files AFAIK can only contain strings and numbers, the current config contains python objects, to change this we would need to put another layer between the config and qtile, and in doing so we would lose a lot of the hackability in Qtile. The problem with having default values in the default_config.py file is that to use any of the values you have to import the module which instantiates the objects within. We could separate this out into 2 files, one for default values, the other for the fallback configuration, but I don't see how this is any better and will be prone to the same kind of problems, e.g. the current default floating layer object. With the defaults in the parser (which as far as I have seen this is pretty common practice), we instantiate default objects only when needed. For documentation purposes, I think we should document all config objects in the parser source and pull that out using sphinx. Happy to do this if this is how we decide to proceed. With default values removed from default_config I think this serves as a better example of what is needed in a working config. |
Actually, this is the problem. It is bad to have unused objects living with the qtile process. Ability to use .ini file for configuration (keeping the ability to use the config.py instead of .ini) is a solution. Another alternative is to remove this objects somewhere after default_config import, but it would be an ugly hack, imho.
As I understand, @tych0 wants to avoid this. I think this makes sense, too.
I do not understand what kind of parser you mean and how you came to this, but yes, with the .ini file we, obviously, need some kind of parser, which would provide an interface allowing to create python objects from .ini file. And this way we could instantiate only the required objects for the config.
Not sure what do you want to do, but it looks reasonable. |
Other way could be to import default_config only if some config parameters are not defined in config. |
Another try to fix qtile#251
But in this case we have to force the users to define all parameters, even those which have the None/True/False values, in their configs. @tych0, is it acceptable? |
Isn't the problem really just that we're attaching the clock's timer in Perhaps the simplest solution is just to remove the Clock from the default config? |
Actually if you accept Andrews clock patch it will be set in _configure On 30 December 2012 14:53, Tycho Andersen notifications@github.com wrote:
|
I think it is wrong way. It is bad that there are live unused objects in the qtile process. I'll write an .ini config implementation this week, lets see. |
I agree with you on the1st point, we should not be creating objects unless we intend to use them, it is a dirty hack way to do it. I do think that the default_config should serve one purpose and serve it well, which should be the configuration used in the absence of a working users config.py. I think that the config parser If you think that you can add functionality to ini as in my current config, then I will be glad to test it. |
On Sun, Dec 30, 2012 at 08:41:07PM -0800, Andrew Grigorev wrote:
Well, they're not huge... I think this may be a case of "premature
I still don't understand how this solves the problem. We won't get rid \t |
This is a fair point. Craig |
I'm going to go ahead and close this, since #185 has been merged. It's a good thing to be aware of, but I'm not sure we need to address it at this point. If it becomes a problem again, we can re-open and revisit it. |
In #185 I had found that there two instances of the Clock widget in running qtile, but I create only one clock instance in my config. The second instance comes from default_config and it is not good.
It is in current develop branch head.
The text was updated successfully, but these errors were encountered: