daitj / gnome-display-brightness-ddcutil

Display brightness slider for gnome shell using ddcutil backend
GNU General Public License v3.0
308 stars 38 forks source link

smooth all slider #135

Closed slaclau closed 6 months ago

slaclau commented 7 months ago

Builds on #134 with additional all slider functionality.

Algorithm is as follows:

Assume the all slider has value $v$ and slider $i$ has value $v_i$. If the all slider is increased by $a$, slider $i$ is increased by $a_i = a\times \frac{1-v_i}{1-v}$
Let $v$ be the value of the all slider and $v_i$ the value of display slider $i$. It follows that $$v = \frac{\sum_i v_i}{n}$$ Assuming that $v$ is increase by $a$, my algorithm increases $v_i$ by $a_i = a\times \frac{1-v_i}{1-v} < {1-v_i}$ ensuring no slider is moved above $1$. Then $$\frac{\sum_i(v_i + a_i)}{n} = \frac{\sum_i v_i}{n} + \frac{\sum_i a_i}{n} = v + \frac{a}{n(1-v)}\times \sum_i(1-v_i) = v + \frac{a}{n(1-v)}\times (n-v) = a + v $$ The value of the all slider still corresponds to the average value
daitj commented 7 months ago

Have you tested with $v_i$ and $v$ being $1$, because the fraction would become indeterminate $a_i = a\times \frac{0}{0}$

slaclau commented 7 months ago

When $v=1$ the brightness can only be decreased not increased, I skipped over this for brevity but when decreasing brightness the decrease fraction is instead $a=v_i/v$

daitj commented 6 months ago

will follow this up in #136 since that includes all of the changes