Giter Club home page Giter Club logo

brightness's Introduction

Brightness

Sync macbook screen brightness to non-Apple external display. Has a menu item to adjust brightness on all monitors simultaneously.

It works on Catalina. It also seems to not conflict with Night Shift.

Installation

Download the precompiled app here: https://github.com/ojotoxy/Brightness/releases/tag/with-slider

(Debug build from Mojave xcode 10.2)

Unzip and run the app. A "sun" icon appears in the menu bar, it has a slider to control brightness on all monitors simulataneously.

Other Thoughts

Pull requests welcome!

How it works:

  • Periodically sync brightness. Explained below.
  • Listen for these events: NSWorkspaceSessionDidBecomeActiveNotification, NSWorkspaceScreensDidWakeNotification, NSWorkspaceDidWakeNotification
  • When this event happens, recheck the displays configuration and decide what mode to be in.
  • Pick a 'driving display'. This is the monitor whose brightness should be copied to the others.
  • A driving display is the first display found whose real backlight brightness can be read. (Macbook internal display for example)
  • Periodically, copy the brightness to all other monitors.
  • Two methods are available for setting brightness, which I call Real and Fake.
  • Real is supported on apple monitors. There turns out to be a semi-documented api for doing setting brightness. This stuff is sort of on the fringes of what is offically supported by Apple!
  • Fake is supported on all monitors. This is done using the graphics card Gamma Table. Which basically maps RGB values to new RGB values. It is meant for color correction, but brightness correction is a subset of that. The original gamma table is read, and then scaled downward. (It does this the easy way now, but what might be better is to stretch the gamma table rightward, using interpolation. This could preserve color better while dimming? I thought I did this, but apparently it's doing it the dumb way...)
  • Because OSX will auto control the brightness of an apple external monitor, there is not much point to syncing it with this app. And it sort of does odd stuff sometimes when you do that.

Some ideas for improvements:

  • Rewrite it in Swift, Duh.
  • Make it compatible with apple thunderbolt displays. (Basically, detect when the display can already control its own brightness and turn off the syncing.)
  • Incorporate pretty much all the good ideas from F.lux, but open source! Why not?
  • Debug the occasional crashes. Clean up the code.
  • Rewrite the code in swift. Maybe rewrite the code, period. I don't pretend that it's very good as it is.
  • Find a robust way to control a non-apple monitors actual backlight brightess. There have been attempts at this before, but they are seem kind of hacky and have actually crashed my computer before! This is highly dependent on the GPU of the computer, and the external monitor itself. Most monitors seem to support this via https://en.wikipedia.org/wiki/Display_Data_Channel which should be present on all of Displayport(thunderbolt), DVI, HDMI, VGA. Doing this well would have the effect of Much Better contrast at low brightness levels, which is the lame part of doing the brightness this way.
  • Perhaps a USB dongle could act as a middle man for the DDC control, using a microcontroller to send instructions to the monitor. This would be a Displayport passthru device, basically, that can inject additional DDC commands. Read starting pg 89 here, if you don't immediately think this is a terrible idea: http://ftp.cis.nctu.edu.tw/csie/Software/X11/private/VeSaSpEcS/VESA_Document_Center_Video_Interface/DportV1.1.pdf

License: Artistic License 2.0, thanks Larry.

brightness's People

Contributors

baragona avatar marckrenn avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.