-
Notifications
You must be signed in to change notification settings - Fork 429
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
"stdin" manual provider #690
Comments
bump, any comment please? Thanks. |
I am also interested in talking directly to a running redshift process. My use case is the brightness setting. I have an OLED display; none of the backlight-adjusting tools work because, well, I don't have a backlight. I have been using On a related note, I frequently invert the colors of my screen (also using xrandr; keeping most pixels dark saves considerable energy on OLED displays and is sometimes easier on the eyes). @jonls, would you accept code implementing such functionality for redshift? If not, I'll write my own tool after all. |
I'd rather not depend on having a redshift config to reload if it can be helped but I guess that could work... I'm still open to helping as well, but, yeah, need to decide on something first :) |
OK, I have forged ahead. Here are three patches on top of @martinetd's wayland branch commit 420d0d5 (and not on top of @jonls' upstream because I need this for wayland):
I compiled and tested them only under Linux using randr and wayland. The first two patches should be uncontroversial; they are simple and unobtrusive. The third is also simple and unobtrusive, but the way it is implemented may be up for debate. I took the following decisions:
There is room for improvement here, but I think this should be done by a major refactoring of As it stands, it works for me, and I will soon start using it in production. I'd love these patches - or something better - to be applied upstream (by @martinetd and/or @jonls). |
Neat, I'm definitely ok with something that just read commands continuously, it's just a matter of formatting and does solve the provider issue I described neatly. I'll give this a spin and update my scripts to use this mode in the next few days. Just reading the commits though a few comments:
Anyway, will give this a try; if it works I don't mind taking the patches in my branch but my tree definitely is not 'upstream'; don't expect too much from this alone. |
Patch 2 depends on Patch 1, but the two are unrelated to Patch 3. @jonls and @martinetd, do you need me to fork your repos on github and create pull requests (dreaded enforced github workflow), or can you pick up the patches directly?
Absolutely :-) It looks like
Pipes are weird beasts. Once the last writer quits, the reader receives an EOF, and the connection is severed. If the pipe was connected to
Someone packaged your wayland branch for the Arch User Repository; this is where I found it. So your tree is a sort of de-facto "upstream" for some number of users out there, whether you want it to be or not :-) |
I hate github for that as well and have no problem with the gists, personally. Back to the 3rd patch, it doesn't apply on either branch and it took me a while to apply manually because the format isn't exactly the same as what my patch program likes (the 'modified xxx' part, it's not what I get with git format-patch?); anyway, it was just some 3 lines offset in redshift.c but I did say git am was a pain... So now I have this checked out (branch here for convenience), a few more comments:
Eeep, first time I've heard of this. . . Well, I guess it's AUR as usual :) |
Sorry about that. I wanted one patch that spans two commits instead of a two-patch series. I won't do that again...
Hmm... I did not try that; I hard-coded my location in the config file. I'll check that out.
Our use cases differ. You want a single feeder process, which, when it exits, might as well take redshift with it. Here, a fifo does not really buy you anything. I, in contrast, want to feed something into redshift at any time, by any means. For example, I'll configure my brightness keys to launch a little utility that writes the respective command into redshift. So, for this utility to know where to write to, I need something like a fifo anyway. I put it the explicit file opening because it's only a few lines of code and avoids extra plumbing with a separate
Good catch. I'll take a look. Not sure when I'll get to it though. This brief, fun programming interlude may be over for a while... |
Hmm, out of curiosity how did you do that? Even something like
Yeah I don't have any config file, so it tries the default geoclue provider; I guess I can just pass a Anyway, even then I can't get -O to work at all; I hadn't read the patch thoroughly enough and was convinced the continual mode was a new one, but it's not and the way it works really is too closely related to location / automatic adjustments for gamma to work for oneshot type commands so my use-case is pretty much screwed there...
I actually want the same thing (binding some script to gamma keys, e.g. shift + brightness up/down); but it's more of a "standard unixy thing" than anything else; in my head it should behave like
No hurry as far as I'm concerned, I'm not sure what kind of option you were passing to get memory corruptions with g_strfreev but at least with the current version asan does not seem to trip on any use after scope with what I tried so I guess it's "good enough". (This also was a good occasion for me to play with the brightness setting of redshift, it's fun to see it behave quite differently from the built-in brightness of my screen, I might be able to get some interesting usage out of this as well by combining the two somehow; I wonder if battery usage cares about which way the brightness is tuned... Well, that's for later anyway) |
I used magit-diff from emacs, specifying a 2-commit range. It should map to git diff commitA..commitB. No idea why this appears to be different...
This is exactly what I had in mind for this use case :-)
How about this: If
I don't have a strong opinion on this; if you or someone else prefers the filename argument of
Independently of what caused the memory corruption or whether such still happen: How about declaring |
Yeah that was more or less my idea; I said a few hours because I just hard-coded that for now for my own use :p
I don't mind having to pass a filename or
Hmm, I don't really like static variables in general but I guess there is little harm here; no opinion. We're already non-reentrant with strtok anyway... I'd only change Anyway, my script has been updated to use this, I'm pretty happy with how it turned out. I'll push this as my wayland branch once the last few points open here settle down a bit. |
Or, since it waits only on a single fd, skip it altogether and have
Just pipe your commands directly into
This was my first thought too, but nothing prevents
Great, then the AUR package will pick it up :-)
If you trust me enough to give me commit access to your repo, we can streamline the settling-down a bit. I'd only ever push to your |
I discovered the reason for some confusion above: I was confused. My patches above applied to @minus7's wayland branch, not @martinetd's. Both are largely the same though, fortunately; the wayland code in @martinetd's tree is from @minus7. Also, the AUR packages @minus7's wayland branch, not @martinetd's. Sorry... I'll continue to interact here, working on @martinetd's tree from now on, since everything should go upstream to @jonls anyway. |
This is an old issue (unfortunate), but I really have to thank you for these patches. I finally have a working backlight setup for my X1 Yoga's OLED screen after more than a year going without it. PKGBUILD and a script to run from sway here: https://gist.github.com/zikaeroh/b687938443a59d3f0645ed7dabe67aea |
I think D-Bus or similar is what I would consider (#54). I don't think I'm willing to maintain a custom protocol for this. |
Sure; I don't particularily like dbus but it would work for my purposes with The patches @piater pushed don't really implement a new protocol for that though, he just loops over stdin and parses it as if it were argv -- I'm happy with that for now :) Feel free to close this issue when #54 gets merged. |
Is your feature request related to a problem? Please describe.
The new wlr-gamma-control protocol (used by wlroots based wayland compositors like sway, and implemented in https://github.com/minus7/redshift/tree/wayland ) has a "feature" that the gamma adjustment resets when the client exits like Quartz.
I'm exclusively using redshift manually with a script that lets me bump the temperature up/down on key bindings, like brightness, and while it is easy to make redshift not exit until it is killed there is a small flicker when I replace an instance of redshift with another.
Describe the solution you'd like
I'd like to be able to implement a trivial "stdin" or "manual control" provider - something simple that would just read from stdin continuously (blocking), try to convert each line of input to a temperature and if it could just apply it.
The problem is that providers aren't meant to provide a temperature directly, but a location that will let the main loop compute where the sun is and what temperature should be used -- the plugin model would need to be adapted to have the provider give either location or temp.
The least bad approach I can think of for that would be to not have the provider return location but something that would be an union of location or temperature, and the available bool could be changed to an enum going unavailable/location/temperature, that the main loop could act on accordingly.
Describe alternatives you've considered
Complain loudly to wlroots folks to have an option to not reset the ramp on exit? But I already did that, not sure it'd have much chance of working :P
I don't think it's possible to backcompute a location that would get the desired temp, that might be another way to go if it were.
A more plausible alternative to both would be to just implement that alongside the other modes, e.g. a
PROGRAM_MODE_MANUAL_STDIN
that would just do that -- it's trivial to do and doesn't need anything changed, just not as elegant.Additional context
I'm more than willing to implement whatever direction you prefer - I just don't want the "wayland" fork to drift further apart and would like to submit it here even if there is no real reason to have this mode for X11. It would still be useful for people using Quartz I suppose.
Would this make sense for you?
What solution do you prefer?
Thanks!
The text was updated successfully, but these errors were encountered: