Hey folks. I've deprecated this project in favor of a better solution. You can find this solution explained on my blog.
go-lguf
is a Go library that interfaces with the LG UltraFine 4K monitor in order to adjust brightness from Linux.
This simple library is needed because this monitor was designed specifically for Apple computers and thus has no physical buttons.
Without the built-in features of macOS, adjusting brightness on this monitor wasn't possible.
Note: This was specifically made and tested for the UltraFine 4K 21.5" model 22MD4KA-B. This may work with the newer 23" 2019 model, or even with the 5K model. I don't know for sure, you can open an Issue or tweet me to let me know.
- libusb - Needed in order to talk to the monitor over USB. Most modern Linux desktops will have this installed. If not, on Ubuntu and Debian this can be installed by:
sudo apt install libusb-1.0
- root - In order to use
libusb
, root access is needed.
go-lguf
is a Go module and so the best way to use it is to import it into your own code and then run go mod tidy
to get it downloaded.
import(
"github.com/felicianotech/go-lguf/lguf"
)
The lguf
package provides a Connection
struct that does most of the work for you.
Just remember to Close()
is.
Here's a simple program that simply prints the current brightness level and quits.
package main
import (
"fmt"
"log"
"github.com/felicianotech/go-lguf/lguf"
)
func main() {
conn, err := lguf.NewConnection()
if err != nil {
log.Fatalf("%v", err)
}
defer conn.Close()
value, err := conn.Brightness()
if err != nil {
log.Fatalf("%v", err)
}
fmt.Printf("LG UltraFine 4K brightness is: %x", value)
}
This library is written and tested with Go v1.12+ in mind.
go fmt
is your friend.
Please feel free to open Issues and PRs are you see fit.
Any PR that requires a good amount of work or is a significant change, it would be best to open an Issue to discuss the change first.
This repository is licensed under the MIT license. This repo's license can be found here.
This project would not exist if it wasn't for Jean-François Beauchamp's repository. It's a C++ based, light-weight version of this.