⬆️ ⬇️

Ergonomics in the dark

How many of you have a monitor next to a window in which the sun shines in the morning, afternoon or evening? Even if the rays of the Sun do not dazzle and do not create glare on the screen surface, it will still create a little discomfort during sunset, at least for me.



How?



Everything is very simple. Towards evening, the sun is setting to a sunset and the light enters the room very brightly, sanctifying the space around my workplace is brighter than ever. But the closer the sun comes to the horizon, the duller its rays become and it is necessary to turn on artificial lighting. And at this very time, the difference in the illumination of the room is formed and against the background of the subdued illumination the 22-inch monitor begins to “cut” the eyes.



Decision



Although there are already ready-made programs, for example f.lux or Redshift , in which a gradual change in color temperature is realized, I nevertheless decided to give my attention to brightness. And since I am the proud owner of an HD3870 video card with the proprietary fglrx driver installed, I wrote three small shell scripts to automatically gradually change the screen brightness.

')

How?



Again, everything is very simple!

"Evening" algorithm

  1. Determine the initial brightness.
  2. Determine the duration of the transition and divide the time by Δ brightness.
  3. Dim the screen gradually.

    now=$((now-1))

    aticonfig --set-dispattrib=tmds1,brightness:$now
  4. We are waiting for n / m seconds, where "n" is the dimming time, and "m" is Δ brightness.
  5. Repeat the 3rd and 4th paragraph until $ now becomes equal to the required blackout.


“Morning” algorithm

  1. Determine the initial brightness.

    aticonfig --query-dispattrib=tmds1,brightness
  2. Determine the duration of the transition, find Δ brightness.
  3. We continue if Δ brightness 0, otherwise the required mark has already been reached.
  4. Add brightness.

    now=$((now+1))

    aticonfig --set-dispattrib=tmds1,brightness:$now
  5. We are waiting for n / m seconds, where "n" is the dimming time, and "m" is Δ brightness.
  6. Repeat the 4th and 5th paragraph until $ now becomes equal to the initial level of brightness.


"Boot" algorithm



Evening ”, “ Morning ” and “ Boot ” script, works without root rights. Carefully read the comments at the very top, as you may have to guess with a different type of display!





Tricky question"



How to make it all work? Again, everything is elementary.

Voila! Everything is ready for long night coding. It remains to make coffee and snacks, for programming new bugs appear on an empty stomach.





It was and became



image



image





It only remains for me to write an algorithm for calculating the beginning and end of daylight depending on the date and location, but this is a completely different story. I hope someone else, besides me, will need these scripts. Take care of your health, especially eyesight. Good luck!






1 Be sure to specify export DISPLAY=:0 to run from under the “X”. Works great in Ubuntu 9.10 Karmic Koala.

2 I didn’t manage to reset the brightness to zero through cron, because first X and drivers should be launched, and only then the script itself, but if someone could manage to achieve the same result in the same way, please add your comments in the comments option.

Source: https://habr.com/ru/post/94745/



All Articles