-
-
Notifications
You must be signed in to change notification settings - Fork 261
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
module: add background and border colors #1486
Conversation
py3status/module.py
Outdated
err += 'should be a string' | ||
raise TypeError(err) | ||
self.py3_module_options[name] = Py3(self)._get_color(param) | ||
self.block_options.append(name) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tobes Look at this part. I don't know if Py3(self)._get_color(param)
is ideal.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes this is very bad
a) Instantiating Py3
just to access a function is a performance overhead
b) class methods starting with an underscore _
are private and should not be accessed outside of the class
I'll make a PR to make the function globally available
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll wait for this. :-)
2443b4c
to
20af299
Compare
py3status/module.py
Outdated
if not isinstance(param, basestring): | ||
err = 'invalid "{}" attribute, '.format(name) | ||
err += 'should be a string' | ||
raise TypeError(err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd do this to be more readable
Also the invalid
-> Invalid
and using backticks ```` (screw github) not quotes "
raise TypeError(
'Invalid attribute `%s`, should be a string' % name
)
but maybe we should also tell the user a little more info so they can better resolve the problem ie show them what we got
There is another example of this in this PR which you can fix too
20af299
to
2b608ab
Compare
2b608ab
to
3204fa6
Compare
@tobes Fixed. Ready for review. I included |
3204fa6
to
606c63f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok these are some thoughts. I've not even looked to see how it affects the other code so there may be lots more changes ahead.
This is just minimal quality control not looking at the logic
py3status/module.py
Outdated
@@ -311,7 +311,7 @@ def set_module_options(self, module): | |||
https://i3wm.org/i3status/manpage.html#_universal_module_options | |||
""" | |||
self.i3s_module_options = {} | |||
self.py3_module_options = {} | |||
self.py3_module_options = {'block': {}} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is ugly, I think we can do better
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Used to be self.block_option
. It's not going to be used for anything else other than background
, border
+ its widths. Happy to hear your suggestion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The whole dict is this.
self.py3.module_options = {
'block': {
'background': '#fff',
'border': '#fff',
'border_left': 1,
'border_right': 1,
'border_top': 1,
'border_bottom': 1,
},
'min_width': 15,
'align': 'left'
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is there anything special about the block stuff? If not why not just all live happily together?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We keep min_width
and align
to ourselves since i3bar is not equipped to handle more than one composite. That's why i3status is always colorized with good
or bad
.
Nothing special. I put them in its own dict for looping... I don't need to do anything with min_width
and align
and I wanted to keep custom (ie py3status and i3-gaps) options inside a dict instead of separate parameters. i3 universal options is in that other dict.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, if users didn't specify anything, the block is empty so I'm not wasting time looping through nothing. Can be background
only.. or border
stuffs only... or both of them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
whatever this needs a reworking at some point to make it more efficient/readable so I can live with it but make a comment explaining why this is in the code so the reasoning isn't lost
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left a comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have separated them to make it more readable. Three dict options. py3status
dict will not have more than two options max.
py3status/module.py
Outdated
@@ -325,7 +325,7 @@ def set_module_options(self, module): | |||
|
|||
if 'align' in mod_config: | |||
align = mod_config['align'] | |||
if not (isinstance(align, basestring) and | |||
if not isinstance(align, basestring) and ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why have you done this?
explain your working and why is this not in the PR description
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Travis. Flake8.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see why it is part of this PR maybe I've missed something
and please don't resolve issue I raise I'm not happy
Also I don't have to help you with your code I can just NAK it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
../module.py|328 col 25 warning| line break after binary operator [W504]
We have this in tox.ini
to skip those.
[pytest]
flake8-ignore =
# line break after binary operator (2018-Aug-22)
W504
# invalid escape sequence (2018-Aug-22)
W605
When we black
, we can remove W504
later so Travis will complain next time. W605
is complaining about several \?if=
. I'm just seeing this warning here and it didn't take much to remove the warning. I'll undo this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but wtf is this being done in this PR for - how many times do I have to say the same shit?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because that's how I fixed errors/warnings in first place. I forget I had this blacklisted.
65a98e0
to
b4b28ab
Compare
py3status/module.py
Outdated
@@ -325,7 +325,7 @@ def set_module_options(self, module): | |||
|
|||
if 'align' in mod_config: | |||
align = mod_config['align'] | |||
if not (isinstance(align, basestring) and | |||
if not isinstance(align, basestring) and ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see why it is part of this PR maybe I've missed something
and please don't resolve issue I raise I'm not happy
Also I don't have to help you with your code I can just NAK it
b4b28ab
to
e1b341d
Compare
py3status/module.py
Outdated
|
||
if name != 'border': | ||
continue | ||
borders = ('top', 'bottom', 'left', 'right') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd just prefer the real list than building them straight after, but not a biggy.
Why tuples not lists?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Faster? I don't need to touch the tuples.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please answer the question.
If you don't give me what I need how can I do a review? Also please try to review your comments I find some very hard to follow. Other times you can be clear so you have the skill if you are bothered, please be.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm serious. Is it not faster than the list? Immutable. I'm using it for loops so I don't need to manipulate the list.. That's what I meant by not needing to touch the tuples.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe it does not matter because it does not apply to the line 369, but the next line down... Should be used with tuples, not list. Meh.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please use a list it is clearer and no real other difference here. If you want to save cycles there are better ways - readability wins over pretty much anything else.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, I'll switch to list right now.
py3status/module.py
Outdated
if not isinstance(param, basestring): | ||
raise TypeError( | ||
'Invalid attribute `{}`, ' | ||
'should be an int. Got `{}`' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you did a copy paste string
not int
but really should be color
py3status/module.py
Outdated
) | ||
|
||
if name != 'border': | ||
continue |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what's going on here? I think you should just end the block here and unindent the following code seeing as you then screw the name variable over.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
background
and border
have identical code. I'm looping with two names. If users entered something... and it's background, continue
. If it's border, then we make a quick list of borders, then start checking for inputs from users. Fine with screwing the name variable because I'm finished with border
part (code is already added in block). Am working on getting border widths (int) at this time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you read what I write?
I'm pretty sure it's wrong - yeah it runs but it is messy for no reason and is a maintenance nightmare. If you are doing something clever where is the comment.
Have a fun evening I'm done :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You always say "What's going on here?" I explained it, but I know you know what's happening here... so why are you asking me that question? Maybe no question next time so I don't have to answer your question.
That's all I did... answering that question. I did read what you said. ;-) EDIT: Gnight! :)
EDIT: Answering your question. Yes, I did read what you wrote. See what I said above.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. :-) I keep tuples list because it looks ugly / out of place if I list em all.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok so the code was ok except it had no comment.
github sometimes makes it hard to see the actual code
but this is much clearer so I prefer it. Clarity is everything - make your code easy to read for idiot reviewers and your life is easier too
0274a1c
to
f529fba
Compare
py3status/module.py
Outdated
self.i3s_module_options = {} | ||
self.py3_module_options = {} | ||
self.gaps_module_options = {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looking much better now
self.gaps_module_options
I don't like this name self.i3_gaps_module_options
?
Also can the comment be by the definition not all above everything. I should not have to scan the code to see things - it should all be super clear.
As an aside - I think background is fine with classic i3-bar
for some time now (border is there but has issues so not practical)
we still need the _get_color(border)
fix and do you also want the alpha channel?
# keep i3-gaps module options in gaps module options.
this is wrong should it not be # module options only available in i3-gaps
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I made variable names more clear enough to not warrant a comment.
EDIT: Yes on alpha channel. More nice for users if we can add this too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://github.com/Airblader/i3#transparency--rgba-colors
Alpha may be already available with i3bar -t
. The exception is that this wouldn't work with CSS color names and general colors unless you have a solution in mind for those particular names. We also could support rgba()
in the future. I think users could be more likely to use color hex over rgba()
so maybe we don't really need to add anything here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tobes Ping... How goes the _get_color()
fix since it's the only thing preventing this PR from getting merged... I'm also okay with forgoing alpha channel if it's not an easy fix. Thanks.
02165f1
to
3c5e133
Compare
3c5e133
to
b4e6f1a
Compare
@maximbaz You should try this next!!!! order += "static_string left"
order += "static_string center"
order += "static_string right"
order += "static_string block"
static_string left {
format = 'l[\?color=good&show e]'
format += '[\?color=lightblue&show f][\?color=red&show t]'
border = '#EB709B'
position = "left"
min_length = 20
border_top = 2
border_bottom = 2
border_left = 2
border_right = 2
}
static_string center {
format = '\?color=degraded center'
format = 'c[\?color=degraded&show e][\?color=pink&show n]'
format += '[\?color=orange&show t][\?color=gold&show e]r'
border = 'orange'
background = '#005577'
position = "center"
min_length = 20
border_top = 2
border_bottom = 2
border_left = 2
border_right = 2
}
static_string right {
format = '\?color=bad right'
format = 'r[\?color=bad&show i][\?color=lightgreen&show g]'
format += 'h[\?color=lightblue&show t]'
border = 'lightgreen'
min_length = 20
position = "right"
border_top = 2
border_bottom = 2
border_left = 2
border_right = 2
}
static_string block {
format = '\?color=red ❤'
min_length = 20
background = 'gold'
position = 'center'
border = 'white'
border_top = 2
border_bottom = 2
border_left = 2
border_right = 2
} |
It's fun no doubt 🙂 I don't see how I personally will use this feature yet, but as I said in the other ticket, in principle I'm not against this PR because it enables functionality that i3bar (or i3status? I'm confused a bit) already supports, currently py3status prevents using some options that what i3bar/i3status provides. @su8, just curious, I see you upvoted this PR, could you tell us if you are going to use this feature? Maybe you already know how exactly, for which modules? I'm asking because this has been a point of discussion, whether there are some actual use-cases for this PR. |
Users don't have to use all borders. They can set
(i3bar). This works with @su8 does not use i3wm+py3status. @su8 is a good sport too. <3 |
Anyhow, if you wanted my feedback, you have it now: yes for this PR (because it allows using already existing i3bar features) and no for |
66843dd
to
74372bb
Compare
74372bb
to
72420f0
Compare
Ok @lasers the PR is now thin and I have found a way to get rid of the get_color function as you can see in my added commit. Could you test it one last time? It's working for me, so merge is soon to come. |
f55a5b1
to
0cafade
Compare
@ultrabug It's not working for me.
EDIT: If module's EDIT: Nevermind. Travis flake8 caught this. You see it now. |
0cafade
to
4d3e0df
Compare
@lasers hmm I can't reproduce this and it shows on a module that's not part of the project, can you repeat the problem on other modules? |
I don't see this problem on my usual modules. The colors is working now without |
Why then? :( |
I don't have a clue. It is just |
@ultrabug If you |
@ultrabug Hi. I have 6 open PRs... Plz get this junk out of here today. 🔥🗑️ |
Thanks, works fine for me |
@lasers if you make it a simple and one-thing-at-a-time PR, why not |
I don't know about making it simple. It's all-in because it's much easier to change background for all modules with one config in |
Then just open a PR that says this clearly. TBH the previous one was messy to me. |
This only works on
i3-gaps
. I addbackground
andborder
colors as well asborder_{top, bottom, left, right}
widths. The border widths only work if you specifiedborder
.