-
-
Notifications
You must be signed in to change notification settings - Fork 398
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
Add window arguments #431
Add window arguments #431
Conversation
oh wow |
Damn, this is huge! Love it, and thanks a lot already for all the effort you put into this! I was planning to implement something like this before, already, very cool! Obviously this is going to take some time for me to think about, both in terms of design decisions and implementation detail, but here's a few initial thoughts:
|
Thanks for the feedback! So with the first point about having a separate argument that is enforced with a window id, do you think it should look something like this (with the structure in the second point):
I do agree that would be cleaner option, and would be a lot nicer when trying to update variables for a given window id. The only issue I can see with this is that I'm currently using the id of the window to regenerate the arguments when a config is loaded. Which links to an interesting issue I just randomly stumbled across, which is that I also agree with the second point with the args as then it would allow you to use the names of the variables instead of its positions, and would probably fit with the current system of attributes a lot better. With #324, that would be awesome, and would solve the problem I was trying to fix with the per window variables. I'm trying to figure out if that would make the per window option redundant, they both can serve different things but I am failing to come up with a good use case for the per window global variables. If you have any ideas, would love to hear them. But, I think it might just be best to remove it as the per window variables are a bit of an awkward middle ground. But I agree waiting for #324 to be implemented first would be good as I'm guessing that would change quite a bit of the scope structure. However I do have one question about it, would it allow a widget further down the stack to set the variable of a widget further up the stack? I'm guessing this would have to be done through passing the variable down the stack, as otherwise the syntax validator would have a really hard time. In the mean time I can fix the tests and update the commands for creating a window. |
yea, exactly, that's how the IDs would have to look I think that if we had #324 we'd not need global per-window variables, those would just need to be passed down from the window to the widgets. |
a99a070
to
0be8753
Compare
Just a quick update I've been researching how to do the arguments with the From what I have read I don't think it will be possible to have something like.
After reading this post To summarise (from my understanding), you can't have something like
Secondly, I think it would be very hard to get the command below working
There may be a way if you override start overriding the So I have two simpler alternatives, both of which are definitely nowhere near as nice though. Alternative 1Using similar logic to the current
The only issue which comes with this is that Alternative 2One that is probably even more disgusting, but would work with
Technically you could swap An issue which appears with this one is that would you want to move the options Anyway, if I'm being stupid and missing something in Other ideas are also welcome :) |
Yea, I've been thinking about that structopt limitation too, I fear -- I think there's an issue about that open somewhere, but nothing happened in a loooong while. worst-case yea, the strat would be to do a partly custom command line argument parsing thing,.. but PAIN |
8ad78d6
to
17c930d
Compare
Just quick proposal as I just came up with a horrid(ish) way of making the So basically for E.g.
And if we did want to define an id for each window, following the common theme, we can do something like:
I guess the only real downside to this (other than how hacky it is) is that its a slight pain to automate as you have to have each variable have the id put before |
f88ed0b
to
6d32cb0
Compare
I have now implemented a version of this to experiment with, I have made it so it is backwards compatible and seems to work pretty well so far. I have also added documentation and added to the changelog for the arguments so I think we are just wating to see what happens with #440. I have not altered the per window variables, so I think I will move that change out of this branch so it doesn't get confused with this change - but will probably keep in in another branch on my fork. |
a3e6d8f
to
f0af07a
Compare
f0af07a
to
0163dfe
Compare
0163dfe
to
a79e381
Compare
ea03afd
to
f7c0387
Compare
f7c0387
to
dc20b02
Compare
dc20b02
to
22a05dd
Compare
f634c79
to
4374f8c
Compare
As a quick update to this: A (somewhat) recent change made me reconsider the implementation of this. So I have renamed and reorganised some things:
This new change just makes it easier to have configurations in Currently doing some more testing but hopefully I can now easily transfer some more options to use SimplExpr in the window definition. |
8321d07
to
fd28347
Compare
I have now implemented all options to use
|
I have also added a small bug fix, which I couldn't find reported yet, where the struts don't take into account the scale factor when being created. So on 2 monitors with gtk interface scaling set to 2, the struts are in incorrect locations (meaning on the second monitor the strut is created on the first monitor but displays on the second). Feel free to cherry-pick or copy into another MR to merge quicker :) |
d1212e2
to
68fd71b
Compare
Hey! So, after months of not getting to this, I finally managed to do an in-depth review, and I figured the easiest thing to do is to just do some cleanup as I go through the code, committing my changes as I go. Please look over those last few commits and check if theres anything that you strongly disagree with, or where I might be missing something. There's a few small open questions still:
|
0cec067
to
3c8851a
Compare
Thanks for cleaning up the code a bit, looks a lot better.
Just going over the implementation for this and it seems that there may not be a nice way to implement this... Currently I'm thinking we want to show the instances which are using the window name so have something in the form:
However this may be a bit of a pain to have a script read the information Then there is the implementation... Currently it seems to produce the intended result there are two methods:
I'm kinda more leaning towards the first method as its easier but can do the second (or another) if you prefer.
Cool will update the documentation now |
319ae64
to
5a65726
Compare
RE
which would indicate that there's two instances of This would be a breaking change, but would maximise the usability of this API in the future, I'd think |
Pushed an implementation of that API |
1e5cbab
to
6b2da6c
Compare
6b2da6c
to
334b1ce
Compare
9ff61ea
to
aa1142b
Compare
aa1142b
to
80441ce
Compare
I HIT MERGE IT FINALLY HAPPENED OMG OMG OMG OMG OMG Congrats man! Terribly sorry this took so horribly long, Idk, can't really explain it except me being super distracted and busy all the time,.... |
I've just created this for my config to work so thought I would create a PR to see if this is wanted in the master branch. If it is wanted, I shall flesh out the features a bit more + add docs and update tests
Description
The main goal of these changes were to make to use the same configuration for multiple bars on different screens
There are two features that I implemented in this as they seemed somewhat similar/linked
defwindow
, which can be specified when opening a window by function like parameters e.g.window(param1,param2)
. (this was the first format I was able to come up with, but happy for suggestions, I wanted to allow it so it can be written without spaces.). The config for that would look like:(defwindow [arg1, arg2] ...)
[]
do still workmonitor
option can use these local variables, I think we could also update it so that it can update other options, however I was only looking for setting the screen through this optionwindow(param1,param2)
when saving open windows as well as the scope:per_window true
option set (the default is false) which will mean that the variable will be stored separately for each window. To do this I have refactored thesuper_scope
out into an argument for the build functions so that it has to be specified, which then allows to create a specific "global" scope for each window, which then all the widgets link to instead of directly to the root scope.--window
option to the update command which allows you to specify the window this is for e.g.--window primary
, or to also include an example of a window with parameters--window "secondary(param1,param2)"
Usage
Kind of done this above but will show some better examples:
For the window parameters, I use this for a secondary bar, so that whatever number of monitors I have I can have a simple script get the number of monitors connected and generate a secondary bar for each monitor which is not the primary one
Then my current launch script for each bars uses a function to generate the arguments and spits them in a command:
So then for the local variable, when having an expanding option for a configuration, such as volume control, it allows the bars to work separately without having to have separate instances running in the background. So, currently my config for the volume widget looks like (99% stolen from saimoom's config):
As you can see it uses the variable
eww_update
to update the volume, which is set above in thesecondary
config and passed down through the widgets. This then allows to get results such as shown in the showcase where one volume widget is showing the full slider where the other is not.Showcase
Apologies for the bad screenshot, my monitors are not aligned but they get the point across
As you can see the bar on the left is showing the volume slider whereas the bar on the right is not, when both are running through the same instance of
eww
and also using the same widget shown above in the configurationAdditional Notes
I guess I shall include my idea of "fleshing" the features out here.
Would love some feedback on these:
stacking
orwindowtype
, or anything set in thegeometry
defwindow
, instead being stuck with only the local variables defined through the argumentsAttrSpec
asdefwindow
does use it but it currently doesn't use theoptional
variable. This might be better off moved back so onlywidget_use
uses it and insteadwindow_definition
uses just a simple Vector ofAttrName
open-many
commandmonitor__num
aSimplExpr
instead of ani32
, I've probably broken a lot more, that is just the one I noticed.Question:
args_span
to theWindowDefintion
to be consistent with theWidgetDefintion
, however just looking at it, it seems that this is only referenced in thevalidate.rs
as debugging stuff, which I do not use so would this actually be necessary/should I remove it?Checklist
I've left most of these blank for now as I wanted to check these features are wanted before updating docs and stuff as I was not able to find anyone mentioning/asking for these features. (Also why its a draft PR)
docs/content/main
directory has been adjusted to reflect my changes.cargo fmt
to automatically format all code before committing (I must admit this is sad that it gets rid of aligned aligned code)EDIT: the per window variables have been moved off this MR as a similar but better implementation is currently being worked on, to see my version of it see https://github.com/WilfSilver/eww/tree/per_window_variables