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 // Cursor.HideAfter hides the pointer cursor after this long without
115 // motion; the next motion shows it. 0 never hides it.
116 Cursor struct{ HideAfter time.Duration }
117 Focus struct {
118 // FollowMove shows the target workspace after a column or window
119 // moves to it.
120 FollowMove bool
121 // Animation and Effect mark a window that just got the focus:
122 // FocusAnimation* (off disables it) and FocusEffect*. Strength is
123 // the effect's peak, 0.01 to 0.2.
124 Animation, Effect string
125 Strength float64
126 }
127 // Workspaces are declared with workspace.<name>.* keys, in first-seen order.
128 Workspaces []WorkspaceConfig
129 // Outputs selects and configures physical displays (drm backend).
130 Outputs []OutputConfig
131 Binds map[string]string
132 Render struct {
133 DirectScanout bool
134 // Tearing honours wp_tearing_control_v1 in direct scanout; VRR
135 // turns variable refresh on while a buffer is scanned out.
136 Tearing, VRR bool
137 // VRRFlipGap is the minimum time between a game frame's flip and
138 // the next frame commit under VRR (0: off). It works around
139 // flips that land at the panel's slowest refresh.
140 VRRFlipGap time.Duration
141 }
142 Performance struct{ Realtime bool }
143 Log struct {
144 Level string
145 Debug []string
146 }
147}
148
149// TouchpadConfig configures touchpads. NaturalScroll moves the content with
150// the fingers, for two-finger scroll and three-finger swipes. Tap clicks on
151// a tap: one finger left, two right, three middle. AccelSpeed (-1 to 1) and
152// AccelProfile (AccelAdaptive or AccelFlat) set the pointer speed;
153// ScrollFactor multiplies two-finger scroll.
154type TouchpadConfig struct {
155 NaturalScroll bool
156 Tap bool
157 AccelSpeed float64
158 AccelProfile string
159 ScrollFactor float64
160}
161
162// Touchpad pointer acceleration profiles.
163const (
164 AccelAdaptive = "adaptive"
165 AccelFlat = "flat"
166)
167
168// WorkspaceConfig declares a bind-only named workspace, outside the numbered list.
169// Zero MaxColumns and an empty Overflow use the layout.* defaults.
170type WorkspaceConfig struct {
171 Name string
172 // Monitor is the home monitor: a connector name (DP-2) or a monitor key
173 // ("make model serial"); empty follows the focused output when shown.
174 Monitor string
175 // Size overrides the workspace's logical width and height. Zero inherits
176 // the monitor; its scale is always inherited.
177 Size [2]int
178 // Slots are the declared columns (workspace.<name>.column.N), by N.
179 Slots []SlotConfig
180 LayoutRules
181}
182
183// SlotConfig reserves column N of a workspace for the window of one command.
184// neferwl spawns the command at startup; the window it opens goes to the
185// slot. Width is a layout width (fraction, percentage or pixels).
186type SlotConfig struct {
187 Index int
188 Width string
189 Argv []string
190}