Skip to content
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

Graduated transition when setting brightness #26

Open
akiva opened this issue Nov 26, 2018 · 6 comments
Open

Graduated transition when setting brightness #26

akiva opened this issue Nov 26, 2018 · 6 comments

Comments

@akiva
Copy link

akiva commented Nov 26, 2018

Would it be possible to implement an option to transition the fade when setting, ie. brightnessctl set 5%-, so that it's more aesthetically pleasing and feels less clunky as it steps up or down?

@Hummer12007
Copy link
Owner

Sure! It's an awesome idea. I'll definitely merge a PR.

If you're up to it, I'd be glad to discuss the implementation with you.

@akiva
Copy link
Author

akiva commented Dec 17, 2018

I would be happy to try and help with this—it would be my first c-based PR. Would you care to provide any implementation tips here or in e-mail? Cheers!

@Hummer12007
Copy link
Owner

Great!
You will roughly need to do the following:

  • Add an option for transition duration (0 by default)
  • An example of a way to implement smooth transition would be: when the transition duration is non-zero, you can split the duration into equal chunks (|d->curr_brightness - new| chunks to be precise, https://github.com/Hummer12007/brightnessctl/blob/master/brightnessctl.c#L325) , and increment/decrement the brightness, writing the new value on each chunk.

I'd also like you to consider what would happen if a user executes multiple instances of smooth transition concurrently, and how/whether we'd need to handle that.

@CameronNemo
Copy link

CameronNemo commented Dec 29, 2018

FWIW my project brillo implements this feature. Most of the functionality to enable it is concentrated in this file (note: this is 0BSD now).

Some tips from my experience:

  • You need to decide on a sleep interval at which to write to the brightness file, and if it is too rapid udevd will eat up a lot of resources. I used 100 writes per second; you may not need this many.
  • You will need to write at each interval, then flush the write data (if applicable), then sleep the remaining time in the interval.
  • You will need to check the clock before and after each write. The write may take some time, so you will need to subtract the difference from the sleep interval duration.

Best of luck!

@dirdi
Copy link

dirdi commented Feb 1, 2020

This would be a really nice feature. Unfortunately my C skills are very limited, so I can not provide a PR. However, I wrote this short BASH script that does the job:

I=0
while [ $I -lt 10 ]; do
    brightnessctl -c backlight -q s 2%-
    sleep 0.05
    ((I = I + 1));
done

Adjust the values to fit your needs.

@Hummer12007
Copy link
Owner

There's some work-in-progress code in the anim branch, I think there are a few concurrency left to be resolved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants