Better libddcutil error handling
The previous detect
code was never clearing the vector of displays, it would only append new displays leaving the old ones there.
Since we call detect
when there's an error setting the brightness, it meant the vector would grow each time we try to set the brightness for a display that is in the vector but doesn't exist anymore (or even worse, for a faulty display causing an infinite loop).
This does two things:
- Clears the vector of displays on each
detect
- Calls
detect
only once if there are errors when setting the brightness.