display

package
v1.4.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 16, 2026 License: MIT Imports: 6 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package display reads and changes the target monitor through the operating system: its modes, its gamma table and whether it is lit. display_darwin.go and display_windows.go implement Target and the Monitor methods.

Index

Constants

View Source
const (
	VCPBrightness byte = 0x10
	VCPContrast   byte = 0x12
	VCPRedGain    byte = 0x16
	VCPGreenGain  byte = 0x18
	VCPBlueGain   byte = 0x1A
	VCPInput      byte = 0x60
	VCPVolume     byte = 0x62
	VCPSharpness  byte = 0x87
)

MCCS VCP codes MonitorBar uses over DDC/CI.

Variables

View Source
var ErrGammaLimited = errors.New("display: the system limited the dimming")

ErrGammaLimited means the system refused the requested dimming and a milder one was applied: Windows keeps gamma ramps near the identity.

Functions

func InputName added in v1.1.0

func InputName(code int) string

InputName names an MCCS input source code.

func InputNameFor added in v1.4.0

func InputNameFor(model string, code int) string

InputNameFor names an input of a monitor model, with its overrides.

func ParseCapabilities added in v1.1.0

func ParseCapabilities(caps string) map[byte][]int

ParseCapabilities reads the vcp(...) section of an MCCS capability string, e.g. "vcp(10 12 60(0F 11 12))", into each code and its values.

func SizeLabel

func SizeLabel(w, h int) string

SizeLabel names a resolution the way monitors are sold: "4K", "2K".

Types

type DDC added in v1.1.0

type DDC struct {
	// contains filtered or unexported fields
}

DDC controls the monitor's own settings over the video cable. Get blocks; Set returns at once and sends only the latest value of each code, so a dragged slider doesn't queue up slow writes.

func (*DDC) Capabilities added in v1.1.0

func (d *DDC) Capabilities() string

Capabilities is the monitor's MCCS capability string, "" if unreadable.

func (*DDC) Close added in v1.1.0

func (d *DDC) Close()

Close stops the writer and releases the monitor.

func (*DDC) Get added in v1.1.0

func (d *DDC) Get(code byte) (value, maximum int, ok bool)

Get reads a VCP code: its value, its maximum, and whether the monitor supports it.

func (*DDC) Set added in v1.1.0

func (d *DDC) Set(code byte, value int)

Set queues a write of a VCP code.

type Mode

type Mode struct {
	Width, Height           int // the size the desktop uses (points on macOS)
	PixelWidth, PixelHeight int // the size drawn
	RefreshRate             int
	// contains filtered or unexported fields
}

Mode is a resolution and refresh rate the monitor can show.

func RefreshRates

func RefreshRates(modes []Mode, current Mode) []Mode

RefreshRates returns the modes of the resolution of current, fastest first.

func Resolutions

func Resolutions(modes []Mode, hiDPI bool, refreshRate int) []Mode

Resolutions returns one mode per resolution, HiDPI or not, preferring the given refresh rate, from the largest.

func (Mode) HiDPI

func (m Mode) HiDPI() bool

func (Mode) ID

func (m Mode) ID() string

func (Mode) SizeKey

func (m Mode) SizeKey() string

SizeKey identifies the resolution, whatever the refresh rate.

func (Mode) Title

func (m Mode) Title() string

type Monitor

type Monitor struct {
	Name       string // e.g. "Mi Monitor"
	Connection string // e.g. "HDMI", or "" when unknown
	// Native is the panel's own resolution where the system tells it
	// (Windows, from the EDID), zero otherwise.
	NativeWidth, NativeHeight int
	// contains filtered or unexported fields
}

Monitor is the external display the app manages.

func (Monitor) NativeSize

func (m Monitor) NativeSize(modes []Mode, current Mode) (w, h int)

NativeSize is the monitor's own resolution: what the system reports, or the largest mode drawn 1:1, as HiDPI modes draw more pixels than the panel has. A reported size smaller than the current mode is not trusted (virtual displays of remote desktops report one): the current mode wins.

func (Monitor) OpenDDC added in v1.1.0

func (m Monitor) OpenDDC() (*DDC, error)

OpenDDC returns the monitor's DDC/CI channel, or an error when the monitor doesn't answer it: many don't, or have it off in their menu.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL