common

package
v0.0.0-...-c97b081 Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2023 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MaxAllowedFrequencyDeviation = 0.01
	Epsilon                      = 0.005 // for comparing floats
)
View Source
const (
	PropertyVRRSupported = "vrr_supported"
	PropertyVRREnabled   = "vrr_enabled"
)

Variables

This section is empty.

Functions

func Closest

func Closest[F constraints.Float | constraints.Integer](scales []F, wanted F) F

Closest find the closest number in slice to the requested number

func EnsureConfigDir

func EnsureConfigDir()

func FindProperty

func FindProperty[T any](props map[string]any, key string) (T, bool)

FindProperty checks if the properties contains a specific value with the correct type and returns true as the second argument if it was found.

func GetConfigDir

func GetConfigDir() string

func GetProperty

func GetProperty[T any](props map[string]any, key string) T

GetProperty returns the value of the property, false/zero value if not found.

func GetPropertyDefault

func GetPropertyDefault[T any](props map[string]any, key string, def T) T

GetProperty returns the value of the property or the given default if not found.

func ModesEqual

func ModesEqual(a, b Mode) bool

Types

type DesktopSession

type DesktopSession interface {
	Resources() (Resources, error)
	ScreenStates() ([]LogicalMonitor, error)
	Apply(profile Profile, verify, persistent bool) error
	Close()
	DebugInfo(output io.Writer) error
}

type LogicalMonitor

type LogicalMonitor struct {
	Outputs     map[string]Mode `json:"outputs"`
	Scale       float64         `json:"scale"`
	Orientation Orientation     `json:"orientation"`
	Offset      Rect            `json:"offset"`
	Primary     bool            `json:"primary"`
	Properties  map[string]any  `json:"properties,omitempty"`
}

LogicalMonitor represents one logical monitor. It can have one or more physical monitors as its outputs, in which case the same logical monitor is cloned to all of the outputs.

type Mode

type Mode struct {
	Dimensions Rect    `json:"dimensions"`
	Frequency  float64 `json:"frequency"`
}

func (Mode) MarshalText

func (m Mode) MarshalText() ([]byte, error)

func (Mode) String

func (m Mode) String() string

func (*Mode) UnmarshalText

func (m *Mode) UnmarshalText(text []byte) error

type Orientation

type Orientation uint8
const (
	OrientNormal     Orientation = 0
	Orient90         Orientation = 1
	Orient180        Orientation = 2
	Orient270        Orientation = 3
	OrientFlipped    Orientation = 4
	Orient90Flipped  Orientation = 5
	Orient180Flipped Orientation = 6
	Orient270Flipped Orientation = 7
)

func (Orientation) MarshalText

func (o Orientation) MarshalText() ([]byte, error)

func (Orientation) String

func (o Orientation) String() string

func (*Orientation) UnmarshalText

func (o *Orientation) UnmarshalText(text []byte) error

type PhysicalMonitor

type PhysicalMonitor struct {
	Vendor        string         `json:"vendor"`
	Product       string         `json:"product"`
	Serial        string         `json:"serial"`
	PreferredMode Mode           `json:"preferred_mode"`
	Modes         []Mode         `json:"modes"`
	Properties    map[string]any `json:"properties,omitempty"`
}

PhysicalMonitor represents one connected physical monitor output.

type Profile

type Profile struct {
	Monitors []LogicalMonitor `json:"monitors"`
}

Profile represents a complete monitor layout.

type Rect

type Rect struct {
	X int
	Y int
}

func (Rect) Add

func (r Rect) Add(s Rect) Rect

func (Rect) Eq

func (r Rect) Eq(s Rect) bool

func (Rect) MarshalText

func (r Rect) MarshalText() ([]byte, error)

func (Rect) String

func (r Rect) String() string

func (Rect) Sub

func (r Rect) Sub(s Rect) Rect

func (*Rect) UnmarshalText

func (r *Rect) UnmarshalText(text []byte) error

type Resources

type Resources struct {
	// Monitors maps connectors to connected physical monitors
	Monitors map[string]PhysicalMonitor `json:"monitors"`
}

Resources is the output of the resources command

type State

type State struct {
	Monitors []LogicalMonitor `json:"monitors"`
}

State is the output of the state command

Jump to

Keyboard shortcuts

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