First of all, thank you very much for fixing the infinite mouse sluggishness!
As my external monitor is still too high on the lowest brightness level, I activated the option to lower the contrast after brightness is set to 0. But the contrast drop was way too high and I missed an option to incremently lower it.
So I changed the func handle(mediaKey: MediaKey, event: KeyEvent?) method like so:
case .brightnessUp:
if !prefs.bool(forKey: Utils.PrefKeys.lowerContrast.rawValue) {
// default brightness increasing
let brightnessValue = display.calcNewValue(for: BRIGHTNESS, withRel: +step)
display.setBrightness(to: brightnessValue)
} else {
// first increase contrast value until default value, then start increasing brightness value
let contrastValue = currentDisplay.calcNewValue(for: CONTRAST, withRel: +step)
if contrastValue <= display.defaultContrastValue {
display.setContrast(to: contrastValue)
display.setBrightness(to: 0)
} else {
display.setContrast(to: display.defaultContrastValue)
let brightnessValue = display.calcNewValue(for: BRIGHTNESS, withRel: +step)
display.setBrightness(to: brightnessValue)
}
}
case .brightnessDown:
if !prefs.bool(forKey: Utils.PrefKeys.lowerContrast.rawValue) {
// default brightness descreasing
let brightnessValue = currentDisplay.calcNewValue(for: BRIGHTNESS, withRel: -step)
display.setBrightness(to: brightnessValue)
} else {
// first decrease brightness until 0, then start decreasing contrast value
let brightnessValue = currentDisplay.calcNewValue(for: BRIGHTNESS, withRel: -step)
if brightnessValue >= 0 {
display.setBrightness(to: brightnessValue)
display.setContrast(to: display.defaultContrastValue)
} else {
display.setBrightness(to: 0)
let contrastValue = currentDisplay.calcNewValue(for: CONTRAST, withRel: -step)
display.setContrast(to: contrastValue)
}
}
In Display.swift I added a hard-coded default value for the contrast and a method for decreasing the contrast:
let defaultContrastValue = 70
func setContrast(to value: Int) {
let contrastValue = value < 0 ? 0 : value
Utils.sendCommand(CONTRAST, toMonitor: identifier, withValue: contrastValue)
if let slider = contrastSliderHandler?.slider {
slider.intValue = Int32(contrastValue)
}
saveValue(contrastValue, for: CONTRAST)
}
func setBrightness(to value: Int) {
let brightnessValue = value < 0 ? 0 : value
Utils.sendCommand(BRIGHTNESS, toMonitor: identifier, withValue: brightnessValue)
if let slider = brightnessSliderHandler?.slider {
slider.intValue = Int32(brightnessValue)
}
showOsd(command: BRIGHTNESS, value: brightnessValue)
saveValue(brightnessValue, for: BRIGHTNESS)
}
For this to work, the calcNewValue method needs to be able to return negative values:
func calcNewValue(for command: Int32, withRel rel: Int) -> Int {
let currentValue = prefs.integer(forKey: "\(command)-\(identifier)")
// return max(0, min(100, currentValue + rel))
return min(100, currentValue + rel)
}
Works like a charm and my eyes are happy at night.
Things to improve:
- Add option for manuelly setting a
defaultContrastValue for each display
- Maybe add an OSD for contrast or combine both into one like this:

First of all, thank you very much for fixing the infinite mouse sluggishness!
As my external monitor is still too high on the lowest brightness level, I activated the option to lower the contrast after brightness is set to 0. But the contrast drop was way too high and I missed an option to incremently lower it.
So I changed the
func handle(mediaKey: MediaKey, event: KeyEvent?)method like so:In
Display.swiftI added a hard-coded default value for the contrast and a method for decreasing the contrast:For this to work, the
calcNewValuemethod needs to be able to return negative values:Works like a charm and my eyes are happy at night.
Things to improve:
defaultContrastValuefor each display