config.go RawHistoryFolder
1package ports
2
3import (
4 "image"
5 "time"
6)
7
8// DefaultSDRBrightness is the BT.2408 SDR reference white in HDR, in nits.
9const DefaultSDRBrightness = 203
10
11// OutputConfig configures one connector. Name is the connector (e.g. "DP-2").
12// Mode is "WxH" (highest refresh) or "WxH@Hz" (closest refresh); empty picks the
13// monitor's preferred mode. Off disables the connector.
14// Every connected output that is not off is used. Outputs are placed left to
15// right in config order, then in connection order.
16// Scale is the output scale (0 means 1); layout works in logical pixels,
17// physical = logical × Scale.
18// Primary gets the focus and the pointer at startup, wherever it is placed.
19// ScaleOnly marks an entry set only by output.<name> subkeys: it
20// does not select the connector.
21type OutputConfig struct {
22 Name string
23 Mode string
24 Off bool
25 Scale float64
26 // Pos is an explicit logical placement set at runtime; nil uses automatic layout.
27 Pos *image.Point
28 Primary bool
29 HDR bool // opt-in to HDR10 on capable outputs
30 SDRBrightness int // nits; default DefaultSDRBrightness
31 ScaleOnly bool
32}
33
34// LayoutRules are the layout settings shared by the defaults, screens and
35// named workspaces. Zero MaxColumns and an empty Overflow inherit.
36type LayoutRules struct {
37 // MaxColumns is how many columns share the screen at once.
38 MaxColumns int
39 // Overflow is "scroll" (further columns scroll) or "fixed" (they split
40 // the last one).
41 Overflow string
42}
43
44// Over fills the unset rules of r from base.
45func (r LayoutRules) Over(base LayoutRules) LayoutRules {
46 if r.MaxColumns == 0 {
47 r.MaxColumns = base.MaxColumns
48 }
49 if r.Overflow == "" {
50 r.Overflow = base.Overflow
51 }
52 return r
53}
54
55// OutputLayout is the layout of one screen, matched by connector (DP-2) or
56// monitor key.
57type OutputLayout struct {
58 Output string
59 LayoutRules
60}
61
62// Focus indicator: the animation (Config.Focus.Animation) shapes in time
63// the visual effect (Config.Focus.Effect) drawn on a newly focused window.
64const (
65 FocusAnimationOff = "off"
66 FocusAnimationPulse = "pulse"
67 FocusEffectScreen = "screen"
68)
69
70// Config is the parsed compositor configuration (see the config adapter for keys).
71type Config struct {
72 Keyboard struct {
73 Layout, Variant, Options string
74 RepeatRate int
75 RepeatDelay int
76 CmdKey string
77 }
78 Terminal struct {
79 Command []string
80 AutoOpen string
81 }
82 // Xwayland is the xwayland-satellite binary serving X11 clients; empty
83 // disables X11.
84 Xwayland string
85 // Startup are commands run once when the session starts, in order.
86 Startup [][]string
87 Background struct{ Color string }
88 Floating struct{ Dim float64 }
89 // Stash is the strip of windows set aside by toggle-window-stash:
90 // Width is the width of its selected window (10 to 90) and Gap the
91 // space between it and its neighbors (0 to 10), in percent of the
92 // usable width; Dim darkens the neighbors, 0 to 1. Capture puts new
93 // windows in the stash while it is shown.
94 Stash struct {
95 Width, Gap int
96 Dim float64
97 Capture bool
98 }
99 // Border is drawn inside the window edge; Width 0 disables it.
100 Border struct {
101 Width int
102 Active string
103 Inactive string
104 }
105 Layout struct {
106 Gaps int
107 Presets []string
108 // LayoutRules are the defaults; Outputs override them per screen and
109 // named workspaces override them again.
110 LayoutRules
111 Outputs []OutputLayout
112 }
113 Touchpad TouchpadConfig
114 Focus struct {
115 // FollowMove shows the target workspace after a column or window
116 // moves to it.
117 FollowMove bool
118 // Animation and Effect mark a window that just got the focus:
119 // FocusAnimation* (off disables it) and FocusEffect*. Strength is
120 // the effect's peak, 0.01 to 0.2.
121 Animation, Effect string
122 Strength float64
123 }
124 // Workspaces are declared with workspace.<name>.* keys, in first-seen order.
125 Workspaces []WorkspaceConfig
126 // Outputs selects and configures physical displays (drm backend).
127 Outputs []OutputConfig
128 Binds map[string]string
129 Render struct {
130 DirectScanout bool
131 // Tearing honours wp_tearing_control_v1 in direct scanout; VRR
132 // turns variable refresh on while a buffer is scanned out.
133 Tearing, VRR bool
134 // VRRFlipGap is the minimum time between a game frame's flip and
135 // the next frame commit under VRR (0: off). It works around
136 // flips that land at the panel's slowest refresh.
137 VRRFlipGap time.Duration
138 }
139 Performance struct{ Realtime bool }
140 Log struct {
141 Level string
142 Debug []string
143 }
144}
145
146// TouchpadConfig configures touchpads. NaturalScroll moves the content with
147// the fingers, for two-finger scroll and three-finger swipes. Tap clicks on
148// a tap: one finger left, two right, three middle. AccelSpeed (-1 to 1) and
149// AccelProfile (AccelAdaptive or AccelFlat) set the pointer speed;
150// ScrollFactor multiplies two-finger scroll.
151type TouchpadConfig struct {
152 NaturalScroll bool
153 Tap bool
154 AccelSpeed float64
155 AccelProfile string
156 ScrollFactor float64
157}
158
159// Touchpad pointer acceleration profiles.
160const (
161 AccelAdaptive = "adaptive"
162 AccelFlat = "flat"
163)
164
165// WorkspaceConfig declares a bind-only named workspace, outside the numbered list.
166// Zero MaxColumns and an empty Overflow use the layout.* defaults.
167type WorkspaceConfig struct {
168 Name string
169 // Monitor is the home monitor: a connector name (DP-2) or a monitor key
170 // ("make model serial"); empty follows the focused output when shown.
171 Monitor string
172 // Size overrides the workspace's logical width and height. Zero inherits
173 // the monitor; its scale is always inherited.
174 Size [2]int
175 // Slots are the declared columns (workspace.<name>.column.N), by N.
176 Slots []SlotConfig
177 LayoutRules
178}
179
180// SlotConfig reserves column N of a workspace for the window of one command.
181// neferwl spawns the command at startup; the window it opens goes to the
182// slot. Width is a layout width (fraction, percentage or pixels).
183type SlotConfig struct {
184 Index int
185 Width string
186 Argv []string
187}