1package config
2
3// Config represents the complete configuration for dumber.
4type Config struct {
5 Database DatabaseConfig `mapstructure:"database" yaml:"database" toml:"database"`
6 History HistoryConfig `mapstructure:"history" yaml:"history" toml:"history"`
7 SearchShortcuts map[string]SearchShortcut `mapstructure:"search_shortcuts" yaml:"search_shortcuts" toml:"search_shortcuts"`
8 // DefaultSearchEngine is the URL template for the default search engine (must contain %s placeholder)
9 DefaultSearchEngine string `mapstructure:"default_search_engine" yaml:"default_search_engine" toml:"default_search_engine"`
10 Dmenu DmenuConfig `mapstructure:"dmenu" yaml:"dmenu" toml:"dmenu"`
11 Logging LoggingConfig `mapstructure:"logging" yaml:"logging" toml:"logging"`
12 Appearance AppearanceConfig `mapstructure:"appearance" yaml:"appearance" toml:"appearance"`
13 Debug DebugConfig `mapstructure:"debug" yaml:"debug" toml:"debug"`
14 // DefaultWebpageZoom sets the default zoom level for pages without saved zoom settings (1.0 = 100%, 1.2 = 120%)
15 DefaultWebpageZoom float64 `mapstructure:"default_webpage_zoom" yaml:"default_webpage_zoom" toml:"default_webpage_zoom"`
16 // DefaultUIScale sets the default UI scale for GTK widgets (1.0 = 100%, 2.0 = 200%)
17 DefaultUIScale float64 `mapstructure:"default_ui_scale" yaml:"default_ui_scale" toml:"default_ui_scale"`
18 // Workspace defines workspace, pane, and tab handling behavior.
19 Workspace WorkspaceConfig `mapstructure:"workspace" yaml:"workspace" toml:"workspace"`
20 // Session controls session persistence and restoration.
21 Session SessionConfig `mapstructure:"session" yaml:"session" toml:"session"`
22 // ContentFiltering controls ad blocking and content filtering
23 ContentFiltering ContentFilteringConfig `mapstructure:"content_filtering" yaml:"content_filtering" toml:"content_filtering"`
24 // Clipboard controls clipboard-related behavior
25 Clipboard ClipboardConfig `mapstructure:"clipboard" yaml:"clipboard" toml:"clipboard"`
26 // Omnibox controls the omnibox behavior (initial history display)
27 Omnibox OmniboxConfig `mapstructure:"omnibox" yaml:"omnibox" toml:"omnibox"`
28 // Rendering controls WebKit, GTK and compositor behavior.
29 Rendering RenderingConfig `mapstructure:"rendering" yaml:"rendering" toml:"rendering"`
30 // Media controls video playback and hardware acceleration
31 Media MediaConfig `mapstructure:"media" yaml:"media" toml:"media"`
32 // Runtime configures optional runtime overrides (e.g., /opt prefix for WebKitGTK/GTK).
33 Runtime RuntimeConfig `mapstructure:"runtime" yaml:"runtime" toml:"runtime"`
34 // Performance holds internal performance tuning options (not exposed in UI).
35 Performance PerformanceConfig `mapstructure:"performance" yaml:"performance" toml:"performance"`
36 // Update controls automatic update checking and downloading.
37 Update UpdateConfig `mapstructure:"update" yaml:"update" toml:"update"`
38 // Downloads configures file download behavior.
39 Downloads DownloadsConfig `mapstructure:"downloads" yaml:"downloads" toml:"downloads"`
40}
41
42// RenderingMode selects GPU vs CPU rendering.
43type RenderingMode string
44
45const (
46 RenderingModeAuto RenderingMode = "auto"
47 RenderingModeGPU RenderingMode = "gpu"
48 RenderingModeCPU RenderingMode = "cpu"
49)
50
51// GSKRendererMode controls the GTK Scene Kit renderer selection.
52type GSKRendererMode string
53
54const (
55 GSKRendererAuto GSKRendererMode = "auto"
56 GSKRendererOpenGL GSKRendererMode = "opengl"
57 GSKRendererVulkan GSKRendererMode = "vulkan"
58 GSKRendererCairo GSKRendererMode = "cairo"
59)
60
61// RenderingConfig controls WebKit and GTK/GSK rendering behavior.
62type RenderingConfig struct {
63 // Mode controls GPU/CPU rendering selection for WebKit (auto, gpu, cpu).
64 Mode RenderingMode `mapstructure:"mode" yaml:"mode" toml:"mode"`
65
66 // DisableDMABufRenderer disables DMA-BUF accelerated renderer.
67 // Env: WEBKIT_DISABLE_DMABUF_RENDERER
68 DisableDMABufRenderer bool `mapstructure:"disable_dmabuf_renderer" yaml:"disable_dmabuf_renderer" toml:"disable_dmabuf_renderer"`
69
70 // ForceCompositingMode forces accelerated compositing.
71 // Env: WEBKIT_FORCE_COMPOSITING_MODE
72 ForceCompositingMode bool `mapstructure:"force_compositing_mode" yaml:"force_compositing_mode" toml:"force_compositing_mode"`
73
74 // DisableCompositingMode disables accelerated compositing.
75 // Env: WEBKIT_DISABLE_COMPOSITING_MODE
76 DisableCompositingMode bool `mapstructure:"disable_compositing_mode" yaml:"disable_compositing_mode" toml:"disable_compositing_mode"`
77
78 // GSKRenderer overrides GTK Scene Kit renderer selection.
79 // Env: GSK_RENDERER
80 GSKRenderer GSKRendererMode `mapstructure:"gsk_renderer" yaml:"gsk_renderer" toml:"gsk_renderer"`
81
82 // DisableMipmaps disables mipmap generation.
83 // Env: GSK_GPU_DISABLE=mipmap
84 DisableMipmaps bool `mapstructure:"disable_mipmaps" yaml:"disable_mipmaps" toml:"disable_mipmaps"`
85
86 // PreferGL forces OpenGL over GLES.
87 // Env: GDK_DEBUG=gl-prefer-gl
88 PreferGL bool `mapstructure:"prefer_gl" yaml:"prefer_gl" toml:"prefer_gl"`
89
90 // DrawCompositingIndicators shows compositing layer borders and repaint counters.
91 DrawCompositingIndicators bool `mapstructure:"draw_compositing_indicators" yaml:"draw_compositing_indicators" toml:"draw_compositing_indicators"` //nolint:lll // struct tags exceed lll limit
92
93 // ShowFPS displays WebKit FPS counter.
94 // Env: WEBKIT_SHOW_FPS
95 ShowFPS bool `mapstructure:"show_fps" yaml:"show_fps" toml:"show_fps"`
96
97 // SampleMemory enables memory sampling.
98 // Env: WEBKIT_SAMPLE_MEMORY
99 SampleMemory bool `mapstructure:"sample_memory" yaml:"sample_memory" toml:"sample_memory"`
100
101 // DebugFrames enables frame timing debug output.
102 // Env: GDK_DEBUG=frames
103 DebugFrames bool `mapstructure:"debug_frames" yaml:"debug_frames" toml:"debug_frames"`
104}
105
106// HardwareDecodingMode controls video hardware acceleration.
107type HardwareDecodingMode string
108
109const (
110 // HardwareDecodingAuto lets GStreamer choose (hw preferred, sw fallback)
111 HardwareDecodingAuto HardwareDecodingMode = "auto"
112 // HardwareDecodingForce requires hardware decoding (fails if unavailable)
113 HardwareDecodingForce HardwareDecodingMode = "force"
114 // HardwareDecodingDisable uses software decoding only
115 HardwareDecodingDisable HardwareDecodingMode = "disable"
116)
117
118// GLRenderingMode controls OpenGL API selection for video rendering.
119type GLRenderingMode string
120
121const (
122 // GLRenderingModeAuto lets GStreamer choose the best GL API
123 GLRenderingModeAuto GLRenderingMode = "auto"
124 // GLRenderingModeGLES2 forces GLES2 (better for some mobile/embedded GPUs)
125 GLRenderingModeGLES2 GLRenderingMode = "gles2"
126 // GLRenderingModeGL3 forces OpenGL 3.x desktop
127 GLRenderingModeGL3 GLRenderingMode = "gl3"
128 // GLRenderingModeNone disables GL-based rendering
129 GLRenderingModeNone GLRenderingMode = "none"
130)
131
132// PerformanceProfile selects preset performance tuning settings.
133type PerformanceProfile string
134
135const (
136 // ProfileDefault uses WebKit defaults (no tuning applied).
137 ProfileDefault PerformanceProfile = "default"
138 // ProfileLite reduces resource usage for low-RAM systems.
139 ProfileLite PerformanceProfile = "lite"
140 // ProfileMax maximizes responsiveness for heavy pages (GitHub PRs, etc).
141 ProfileMax PerformanceProfile = "max"
142 // ProfileCustom allows full control over individual performance settings.
143 ProfileCustom PerformanceProfile = "custom"
144)
145
146// ThemeDefault is the default theme setting (follows system).
147const ThemeDefault = "default"
148
149const (
150 // ThemePreferDark explicitly selects dark theme.
151 ThemePreferDark = "prefer-dark"
152 // ThemePreferLight explicitly selects light theme.
153 ThemePreferLight = "prefer-light"
154)
155
156// MediaConfig holds video playback and hardware acceleration preferences.
157type MediaConfig struct {
158 // HardwareDecodingMode controls hardware vs software video decoding
159 // Values: "auto" (default), "force", "disable"
160 HardwareDecodingMode HardwareDecodingMode `mapstructure:"hardware_decoding" yaml:"hardware_decoding" toml:"hardware_decoding"`
161 // PreferAV1 prioritizes AV1 codec (most efficient) when available
162 PreferAV1 bool `mapstructure:"prefer_av1" yaml:"prefer_av1" toml:"prefer_av1"`
163 // ShowDiagnosticsOnStartup shows media capability warnings at startup
164 ShowDiagnosticsOnStartup bool `mapstructure:"show_diagnostics" yaml:"show_diagnostics" toml:"show_diagnostics"`
165 // ForceVSync forces vertical sync for video playback (may help with tearing)
166 ForceVSync bool `mapstructure:"force_vsync" yaml:"force_vsync" toml:"force_vsync"`
167 // GLRenderingMode controls OpenGL API selection for video rendering
168 // Values: "auto" (default), "gles2", "gl3", "none"
169 GLRenderingMode GLRenderingMode `mapstructure:"gl_rendering_mode" yaml:"gl_rendering_mode" toml:"gl_rendering_mode"`
170 // GStreamerDebugLevel sets GStreamer debug verbosity (0=off, 1-5=increasing verbosity)
171 GStreamerDebugLevel int `mapstructure:"gstreamer_debug_level" yaml:"gstreamer_debug_level" toml:"gstreamer_debug_level"`
172}
173
174// RuntimeConfig holds optional runtime overrides.
175type RuntimeConfig struct {
176 // Prefix points to a custom runtime prefix (e.g., /opt/webkitgtk).
177 // This is used to influence pkg-config lookup and dynamic library loading.
178 Prefix string `mapstructure:"prefix" yaml:"prefix" toml:"prefix"`
179}
180
181// DatabaseConfig holds database-related configuration.
182type DatabaseConfig struct {
183 Path string `mapstructure:"path" yaml:"path" toml:"path"`
184}
185
186// HistoryConfig holds history-related configuration.
187type HistoryConfig struct {
188 MaxEntries int `mapstructure:"max_entries" yaml:"max_entries" toml:"max_entries"`
189 RetentionPeriodDays int `mapstructure:"retention_period_days" yaml:"retention_period_days" toml:"retention_period_days"`
190 CleanupIntervalDays int `mapstructure:"cleanup_interval_days" yaml:"cleanup_interval_days" toml:"cleanup_interval_days"`
191}
192
193// PerformanceConfig holds internal performance tuning options.
194// These are not exposed in dumb://config UI but can be set in config file.
195type PerformanceConfig struct {
196 // Profile selects a preset performance configuration.
197 // Values: "default" (no tuning), "lite" (low RAM), "max" (heavy pages), "custom" (manual control)
198 // When profile is not "custom", individual tuning fields below are ignored and computed from the profile.
199 // Default: "default"
200 Profile PerformanceProfile `mapstructure:"profile" yaml:"profile" toml:"profile"`
201
202 // ZoomCacheSize is the number of domain zoom levels to cache in memory.
203 // Higher values reduce database queries but use more memory.
204 // Default: 256 domains (~20KB memory)
205 ZoomCacheSize int `mapstructure:"zoom_cache_size" yaml:"zoom_cache_size" toml:"zoom_cache_size"`
206
207 // WebViewPoolPrewarmCount is the number of WebViews to pre-create at startup.
208 // Higher values speed up initial tab creation but use more memory.
209 // Default: 4 (custom mode), computed from profile otherwise
210 WebViewPoolPrewarmCount int `mapstructure:"webview_pool_prewarm_count" yaml:"webview_pool_prewarm_count" toml:"webview_pool_prewarm_count"` //nolint:lll // struct tags must stay on one line
211
212 // --- Skia rendering threads (env vars) ---
213 // NOTE: Fields below only apply when Profile is "custom".
214 // SkiaCPUPaintingThreads sets WEBKIT_SKIA_CPU_PAINTING_THREADS.
215 // Default: 0 (unset, uses WebKit default)
216 SkiaCPUPaintingThreads int `mapstructure:"skia_cpu_painting_threads" yaml:"skia_cpu_painting_threads" toml:"skia_cpu_painting_threads"` //nolint:lll // struct tags must stay on one line
217
218 // SkiaGPUPaintingThreads sets WEBKIT_SKIA_GPU_PAINTING_THREADS.
219 // Default: -1 (unset). Value 0 disables GPU tile painting.
220 SkiaGPUPaintingThreads int `mapstructure:"skia_gpu_painting_threads" yaml:"skia_gpu_painting_threads" toml:"skia_gpu_painting_threads"` //nolint:lll // struct tags must stay on one line
221
222 // SkiaEnableCPURendering forces CPU rendering via WEBKIT_SKIA_ENABLE_CPU_RENDERING=1.
223 // Default: false
224 SkiaEnableCPURendering bool `mapstructure:"skia_enable_cpu_rendering" yaml:"skia_enable_cpu_rendering" toml:"skia_enable_cpu_rendering"` //nolint:lll // struct tags must stay on one line
225
226 // --- Web process memory pressure ---
227 // WebProcessMemoryLimitMB sets memory limit in MB for web processes.
228 // Default: 0 (unset, uses WebKit default: system RAM capped at 3GB)
229 WebProcessMemoryLimitMB int `mapstructure:"web_process_memory_limit_mb" yaml:"web_process_memory_limit_mb" toml:"web_process_memory_limit_mb"` //nolint:lll // struct tags must stay on one line
230
231 // WebProcessMemoryPollIntervalSec sets poll interval for memory checks.
232 // Default: 0 (unset, uses WebKit default: 30 seconds)
233 WebProcessMemoryPollIntervalSec float64 `mapstructure:"web_process_memory_poll_interval_sec" yaml:"web_process_memory_poll_interval_sec" toml:"web_process_memory_poll_interval_sec"` //nolint:lll // struct tags must stay on one line
234
235 // WebProcessMemoryConservativeThreshold sets threshold for conservative memory release.
236 // Valid: (0, 1). Default: 0 (unset, uses WebKit default: 0.33)
237 WebProcessMemoryConservativeThreshold float64 `mapstructure:"web_process_memory_conservative_threshold" yaml:"web_process_memory_conservative_threshold" toml:"web_process_memory_conservative_threshold"` //nolint:lll // struct tags must stay on one line
238
239 // WebProcessMemoryStrictThreshold sets threshold for strict memory release.
240 // Valid: (0, 1). Default: 0 (unset, uses WebKit default: 0.5)
241 WebProcessMemoryStrictThreshold float64 `mapstructure:"web_process_memory_strict_threshold" yaml:"web_process_memory_strict_threshold" toml:"web_process_memory_strict_threshold"` //nolint:lll // struct tags must stay on one line
242
243 // --- Network process memory pressure ---
244 // NetworkProcessMemoryLimitMB sets memory limit in MB for network process.
245 // Default: 0 (unset)
246 NetworkProcessMemoryLimitMB int `mapstructure:"network_process_memory_limit_mb" yaml:"network_process_memory_limit_mb" toml:"network_process_memory_limit_mb"` //nolint:lll // struct tags must stay on one line
247
248 // NetworkProcessMemoryPollIntervalSec sets poll interval for memory checks.
249 // Default: 0 (unset)
250 NetworkProcessMemoryPollIntervalSec float64 `mapstructure:"network_process_memory_poll_interval_sec" yaml:"network_process_memory_poll_interval_sec" toml:"network_process_memory_poll_interval_sec"` //nolint:lll // struct tags must stay on one line
251
252 // NetworkProcessMemoryConservativeThreshold sets threshold for conservative memory release.
253 // Valid: (0, 1). Default: 0 (unset)
254 NetworkProcessMemoryConservativeThreshold float64 `mapstructure:"network_process_memory_conservative_threshold" yaml:"network_process_memory_conservative_threshold" toml:"network_process_memory_conservative_threshold"` //nolint:lll // struct tags must stay on one line
255
256 // NetworkProcessMemoryStrictThreshold sets threshold for strict memory release.
257 // Valid: (0, 1). Default: 0 (unset)
258 NetworkProcessMemoryStrictThreshold float64 `mapstructure:"network_process_memory_strict_threshold" yaml:"network_process_memory_strict_threshold" toml:"network_process_memory_strict_threshold"` //nolint:lll // struct tags must stay on one line
259}
260
261// SearchShortcut represents a search shortcut configuration.
262type SearchShortcut struct {
263 URL string `mapstructure:"url" toml:"url" yaml:"url" json:"url"`
264 Description string `mapstructure:"description" toml:"description" yaml:"description" json:"description"`
265}
266
267// ShortcutURLs returns a simple map of shortcut keys to URL templates.
268// This is useful for passing to url.BuildSearchURL.
269func (c *Config) ShortcutURLs() map[string]string {
270 result := make(map[string]string, len(c.SearchShortcuts))
271 for key, shortcut := range c.SearchShortcuts {
272 result[key] = shortcut.URL
273 }
274 return result
275}
276
277// DmenuConfig holds dmenu/rofi integration configuration.
278type DmenuConfig struct {
279 MaxHistoryDays int `mapstructure:"max_history_days" yaml:"max_history_days" toml:"max_history_days"`
280 ShowVisitCount bool `mapstructure:"show_visit_count" yaml:"show_visit_count" toml:"show_visit_count"`
281 ShowLastVisited bool `mapstructure:"show_last_visited" yaml:"show_last_visited" toml:"show_last_visited"`
282 HistoryPrefix string `mapstructure:"history_prefix" yaml:"history_prefix" toml:"history_prefix"`
283 ShortcutPrefix string `mapstructure:"shortcut_prefix" yaml:"shortcut_prefix" toml:"shortcut_prefix"`
284 URLPrefix string `mapstructure:"url_prefix" yaml:"url_prefix" toml:"url_prefix"`
285 DateFormat string `mapstructure:"date_format" yaml:"date_format" toml:"date_format"`
286 SortByVisitCount bool `mapstructure:"sort_by_visit_count" yaml:"sort_by_visit_count" toml:"sort_by_visit_count"`
287}
288
289// LoggingConfig holds logging configuration.
290type LoggingConfig struct {
291 Level string `mapstructure:"level" yaml:"level" toml:"level"`
292 Format string `mapstructure:"format" yaml:"format" toml:"format"`
293 MaxAge int `mapstructure:"max_age" yaml:"max_age" toml:"max_age"`
294
295 // File output configuration
296 LogDir string `mapstructure:"log_dir" yaml:"log_dir" toml:"log_dir"`
297 EnableFileLog bool `mapstructure:"enable_file_log" yaml:"enable_file_log" toml:"enable_file_log"`
298
299 // Capture browser console to logs
300 CaptureConsole bool `mapstructure:"capture_console" yaml:"capture_console" toml:"capture_console" json:"capture_console"`
301}
302
303// AppearanceConfig holds UI/rendering preferences.
304type AppearanceConfig struct {
305 // Default fonts for pages that do not specify fonts.
306 SansFont string `mapstructure:"sans_font" yaml:"sans_font" toml:"sans_font"`
307 SerifFont string `mapstructure:"serif_font" yaml:"serif_font" toml:"serif_font"`
308 MonospaceFont string `mapstructure:"monospace_font" yaml:"monospace_font" toml:"monospace_font"`
309 // Default font size in CSS pixels (approx).
310 DefaultFontSize int `mapstructure:"default_font_size" yaml:"default_font_size" toml:"default_font_size"`
311 LightPalette ColorPalette `mapstructure:"light_palette" yaml:"light_palette" toml:"light_palette"`
312 DarkPalette ColorPalette `mapstructure:"dark_palette" yaml:"dark_palette" toml:"dark_palette"`
313 // ColorScheme controls the initial theme preference: "prefer-dark", "prefer-light", or "default" (follows system)
314 ColorScheme string `mapstructure:"color_scheme" yaml:"color_scheme" toml:"color_scheme"`
315}
316
317// ColorPalette contains semantic color tokens for light/dark themes.
318type ColorPalette struct {
319 Background string `mapstructure:"background" yaml:"background" toml:"background" json:"background"`
320 Surface string `mapstructure:"surface" yaml:"surface" toml:"surface" json:"surface"`
321 SurfaceVariant string `mapstructure:"surface_variant" yaml:"surface_variant" toml:"surface_variant" json:"surface_variant"`
322 Text string `mapstructure:"text" yaml:"text" toml:"text" json:"text"`
323 Muted string `mapstructure:"muted" yaml:"muted" toml:"muted" json:"muted"`
324 Accent string `mapstructure:"accent" yaml:"accent" toml:"accent" json:"accent"`
325 Border string `mapstructure:"border" yaml:"border" toml:"border" json:"border"`
326}
327
328// ContentFilteringConfig holds content filtering and ad blocking preferences
329type ContentFilteringConfig struct {
330 // Enabled controls whether ad blocking is active (default: true)
331 Enabled bool `mapstructure:"enabled" yaml:"enabled" toml:"enabled"`
332 // AutoUpdate controls whether filters are automatically updated (default: true)
333 AutoUpdate bool `mapstructure:"auto_update" yaml:"auto_update" toml:"auto_update"`
334 // Note: Filters are downloaded from bnema/ublock-webkit-filters GitHub releases
335 // Note: Whitelist is managed via database (content_whitelist table)
336}
337
338// ClipboardConfig holds clipboard-related behavior preferences
339type ClipboardConfig struct {
340 // AutoCopyOnSelection automatically copies selected text to clipboard (zellij-style).
341 // When enabled, selecting text in a webview immediately copies it to clipboard.
342 // Does not apply to text selection in input fields or textareas.
343 // Default: true
344 AutoCopyOnSelection bool `mapstructure:"auto_copy_on_selection" yaml:"auto_copy_on_selection" toml:"auto_copy_on_selection" json:"autoCopyOnSelection"` //nolint:lll // struct tags must stay on one line
345}
346
347// OmniboxConfig holds omnibox behavior preferences
348type OmniboxConfig struct {
349 // InitialBehavior controls what to show when omnibox opens with empty input
350 // Values: "recent" (recent visits), "most_visited" (most visited sites), "none" (nothing)
351 InitialBehavior string `mapstructure:"initial_behavior" yaml:"initial_behavior" toml:"initial_behavior"`
352 // AutoOpenOnNewPane opens the omnibox automatically when a new pane is created.
353 // Default: false
354 AutoOpenOnNewPane bool `mapstructure:"auto_open_on_new_pane" yaml:"auto_open_on_new_pane" toml:"auto_open_on_new_pane"`
355}
356
357// DebugConfig holds debug and troubleshooting options
358type DebugConfig struct {
359 // Enable browser developer tools (F12, Inspect Element in context menu)
360 EnableDevTools bool `mapstructure:"enable_devtools" yaml:"enable_devtools" toml:"enable_devtools"`
361}
362
363// UpdateConfig holds automatic update settings.
364type UpdateConfig struct {
365 // EnableOnStartup enables checking for updates when the browser starts.
366 // Default: true
367 EnableOnStartup bool `mapstructure:"enable_on_startup" yaml:"enable_on_startup" toml:"enable_on_startup"`
368 // AutoDownload automatically downloads updates in the background.
369 // When enabled, updates are applied on browser exit.
370 // Default: false
371 AutoDownload bool `mapstructure:"auto_download" yaml:"auto_download" toml:"auto_download"`
372 // NotifyOnNewSettings shows a toast notification on startup when new config settings are available.
373 // Default: true
374 NotifyOnNewSettings bool `mapstructure:"notify_on_new_settings" yaml:"notify_on_new_settings" toml:"notify_on_new_settings"`
375}
376
377// DownloadsConfig holds file download preferences.
378type DownloadsConfig struct {
379 // Path is the directory where downloads are saved.
380 // Empty string means use XDG_DOWNLOAD_DIR or ~/Downloads.
381 Path string `mapstructure:"path" yaml:"path" toml:"path"`
382}
383
384// WorkspaceConfig captures layout, pane, and tab behavior preferences.
385type WorkspaceConfig struct {
386 // NewPaneURL is the URL loaded when creating a new empty pane/tab.
387 // Default: "about:blank"
388 NewPaneURL string `mapstructure:"new_pane_url" yaml:"new_pane_url" toml:"new_pane_url"`
389 // PaneMode defines modal pane behavior and bindings.
390 PaneMode PaneModeConfig `mapstructure:"pane_mode" yaml:"pane_mode" toml:"pane_mode" json:"pane_mode"`
391 // TabMode defines modal tab behavior and bindings (Alt+T).
392 TabMode TabModeConfig `mapstructure:"tab_mode" yaml:"tab_mode" toml:"tab_mode" json:"tab_mode"`
393 // ResizeMode defines modal pane resizing behavior and bindings (Ctrl+N).
394 ResizeMode ResizeModeConfig `mapstructure:"resize_mode" yaml:"resize_mode" toml:"resize_mode" json:"resize_mode"`
395 // Shortcuts holds global (non-modal) keyboard shortcuts.
396 Shortcuts GlobalShortcutsConfig `mapstructure:"shortcuts" yaml:"shortcuts" toml:"shortcuts" json:"shortcuts"`
397 // TabBarPosition determines tab bar placement: "top" or "bottom".
398 TabBarPosition string `mapstructure:"tab_bar_position" yaml:"tab_bar_position" toml:"tab_bar_position" json:"tab_bar_position"`
399 // HideTabBarWhenSingleTab hides the tab bar when only one tab exists.
400 HideTabBarWhenSingleTab bool `mapstructure:"hide_tab_bar_when_single_tab" yaml:"hide_tab_bar_when_single_tab" toml:"hide_tab_bar_when_single_tab" json:"hide_tab_bar_when_single_tab"` //nolint:lll // struct tags must stay on one line
401 // SwitchToTabOnMove controls whether moving a pane to another tab switches focus to that tab.
402 // Default: true
403 SwitchToTabOnMove bool `mapstructure:"switch_to_tab_on_move" yaml:"switch_to_tab_on_move" toml:"switch_to_tab_on_move" json:"switch_to_tab_on_move"` //nolint:lll // struct tags must stay on one line
404 // Popups configures default popup placement rules.
405 Popups PopupBehaviorConfig `mapstructure:"popups" yaml:"popups" toml:"popups" json:"popups"`
406 // Styling configures workspace visual appearance.
407 Styling WorkspaceStylingConfig `mapstructure:"styling" yaml:"styling" toml:"styling" json:"styling"`
408}
409
410// PaneModeConfig defines modal behavior for pane management.
411type PaneModeConfig struct {
412 ActivationShortcut string `mapstructure:"activation_shortcut" yaml:"activation_shortcut" toml:"activation_shortcut" json:"activation_shortcut"` //nolint:lll // struct tags must stay on one line
413 TimeoutMilliseconds int `mapstructure:"timeout_ms" yaml:"timeout_ms" toml:"timeout_ms" json:"timeout_ms"`
414 Actions map[string][]string `mapstructure:"actions" yaml:"actions" toml:"actions" json:"actions"`
415}
416
417// GetKeyBindings returns an inverted map for O(1) key→action lookup.
418// This is built from the action→keys structure in the config.
419func (p *PaneModeConfig) GetKeyBindings() map[string]string {
420 keyToAction := make(map[string]string)
421 for action, keys := range p.Actions {
422 for _, key := range keys {
423 keyToAction[key] = action
424 }
425 }
426 return keyToAction
427}
428
429// TabModeConfig defines modal behavior for tab management (Zellij-style).
430type TabModeConfig struct {
431 ActivationShortcut string `mapstructure:"activation_shortcut" yaml:"activation_shortcut" toml:"activation_shortcut" json:"activation_shortcut"` //nolint:lll // struct tags must stay on one line
432 TimeoutMilliseconds int `mapstructure:"timeout_ms" yaml:"timeout_ms" toml:"timeout_ms" json:"timeout_ms"`
433 Actions map[string][]string `mapstructure:"actions" yaml:"actions" toml:"actions" json:"actions"`
434}
435
436// GetKeyBindings returns an inverted map for O(1) key→action lookup.
437// This is built from the action→keys structure in the config.
438func (t *TabModeConfig) GetKeyBindings() map[string]string {
439 keyToAction := make(map[string]string)
440 for action, keys := range t.Actions {
441 for _, key := range keys {
442 keyToAction[key] = action
443 }
444 }
445 return keyToAction
446}
447
448// ResizeModeConfig defines modal behavior for resizing panes (Zellij-style).
449type ResizeModeConfig struct {
450 ActivationShortcut string `mapstructure:"activation_shortcut" yaml:"activation_shortcut" toml:"activation_shortcut" json:"activation_shortcut"` //nolint:lll // struct tags must stay on one line
451 TimeoutMilliseconds int `mapstructure:"timeout_ms" yaml:"timeout_ms" toml:"timeout_ms" json:"timeout_ms"`
452 StepPercent float64 `mapstructure:"step_percent" yaml:"step_percent" toml:"step_percent" json:"step_percent"`
453 MinPanePercent float64 `mapstructure:"min_pane_percent" yaml:"min_pane_percent" toml:"min_pane_percent" json:"min_pane_percent"` //nolint:lll // struct tags must stay on one line
454 Actions map[string][]string `mapstructure:"actions" yaml:"actions" toml:"actions" json:"actions"`
455}
456
457// GetKeyBindings returns an inverted map for O(1) key→action lookup.
458// This is built from the action→keys structure in the config.
459func (r *ResizeModeConfig) GetKeyBindings() map[string]string {
460 keyToAction := make(map[string]string)
461 for action, keys := range r.Actions {
462 for _, key := range keys {
463 keyToAction[key] = action
464 }
465 }
466 return keyToAction
467}
468
469// GlobalShortcutsConfig defines global shortcuts (always active, not modal).
470type GlobalShortcutsConfig struct {
471 ClosePane string `mapstructure:"close_pane" yaml:"close_pane" toml:"close_pane" json:"close_pane"`
472 NextTab string `mapstructure:"next_tab" yaml:"next_tab" toml:"next_tab" json:"next_tab"`
473 PreviousTab string `mapstructure:"previous_tab" yaml:"previous_tab" toml:"previous_tab" json:"previous_tab"`
474
475 ConsumeOrExpelLeft string `mapstructure:"consume_or_expel_left" yaml:"consume_or_expel_left" toml:"consume_or_expel_left" json:"consume_or_expel_left"` //nolint:lll // struct tags must stay on one line
476 ConsumeOrExpelRight string `mapstructure:"consume_or_expel_right" yaml:"consume_or_expel_right" toml:"consume_or_expel_right" json:"consume_or_expel_right"` //nolint:lll // struct tags must stay on one line
477 ConsumeOrExpelUp string `mapstructure:"consume_or_expel_up" yaml:"consume_or_expel_up" toml:"consume_or_expel_up" json:"consume_or_expel_up"` //nolint:lll // struct tags must stay on one line
478 ConsumeOrExpelDown string `mapstructure:"consume_or_expel_down" yaml:"consume_or_expel_down" toml:"consume_or_expel_down" json:"consume_or_expel_down"` //nolint:lll // struct tags must stay on one line
479}
480
481// PopupBehavior defines how popup windows should be opened
482type PopupBehavior string
483
484const (
485 // PopupBehaviorSplit opens popups in a split pane (default)
486 PopupBehaviorSplit PopupBehavior = "split"
487 // PopupBehaviorStacked opens popups in a stacked pane
488 PopupBehaviorStacked PopupBehavior = "stacked"
489 // PopupBehaviorTabbed opens popups as a new tab
490 PopupBehaviorTabbed PopupBehavior = "tabbed"
491 // PopupBehaviorWindowed opens popups in a new workspace window
492 PopupBehaviorWindowed PopupBehavior = "windowed"
493)
494
495// PopupBehaviorConfig defines handling for popup windows.
496type PopupBehaviorConfig struct {
497 // Behavior determines how popups are opened (split/stacked/tabbed/windowed)
498 Behavior PopupBehavior `mapstructure:"behavior" yaml:"behavior" toml:"behavior" json:"behavior"`
499
500 // Placement specifies direction for split behavior ("right", "left", "top", "bottom")
501 // Only used when Behavior is "split"
502 Placement string `mapstructure:"placement" yaml:"placement" toml:"placement" json:"placement"`
503
504 // OpenInNewPane controls whether popups are opened in workspace or blocked
505 OpenInNewPane bool `mapstructure:"open_in_new_pane" yaml:"open_in_new_pane" toml:"open_in_new_pane" json:"open_in_new_pane"`
506
507 // FollowPaneContext determines if popup placement follows parent pane context
508 FollowPaneContext bool `mapstructure:"follow_pane_context" yaml:"follow_pane_context" toml:"follow_pane_context" json:"follow_pane_context"` //nolint:lll // struct tags must stay on one line
509
510 // BlankTargetBehavior determines how target="_blank" links are opened
511 // Accepted values: "split", "stacked" (default), "tabbed"
512 // This is separate from Behavior which controls JavaScript popups
513 BlankTargetBehavior string `mapstructure:"blank_target_behavior" yaml:"blank_target_behavior" toml:"blank_target_behavior" json:"blank_target_behavior"` //nolint:lll // struct tags must stay on one line
514
515 // EnableSmartDetection uses WebKitWindowProperties to detect popup vs tab intents
516 EnableSmartDetection bool `mapstructure:"enable_smart_detection" yaml:"enable_smart_detection" toml:"enable_smart_detection" json:"enable_smart_detection"` //nolint:lll // struct tags must stay on one line
517
518 // OAuthAutoClose enables auto-closing OAuth popups after successful auth redirects
519 OAuthAutoClose bool `mapstructure:"oauth_auto_close" yaml:"oauth_auto_close" toml:"oauth_auto_close" json:"oauth_auto_close"`
520}
521
522// WorkspaceStylingConfig defines visual styling for workspace panes.
523type WorkspaceStylingConfig struct {
524 // BorderWidth in pixels for active pane borders (overlay)
525 BorderWidth int `mapstructure:"border_width" yaml:"border_width" toml:"border_width" json:"border_width"`
526 // BorderColor for focused panes (CSS color value or theme variable)
527 BorderColor string `mapstructure:"border_color" yaml:"border_color" toml:"border_color" json:"border_color"`
528
529 // ModeBorderWidth in pixels for all mode indicator borders (pane, tab, session, resize)
530 ModeBorderWidth int `mapstructure:"mode_border_width" yaml:"mode_border_width" toml:"mode_border_width" json:"mode_border_width"` //nolint:lll // struct tags must stay on one line
531
532 // PaneModeColor for pane mode indicator (border and toaster). Defaults to "#4A90E2" (blue)
533 PaneModeColor string `mapstructure:"pane_mode_color" yaml:"pane_mode_color" toml:"pane_mode_color" json:"pane_mode_color"` //nolint:lll // struct tags must stay on one line
534 // TabModeColor for tab mode indicator (border and toaster). Defaults to "#FFA500" (orange)
535 TabModeColor string `mapstructure:"tab_mode_color" yaml:"tab_mode_color" toml:"tab_mode_color" json:"tab_mode_color"` //nolint:lll // struct tags must stay on one line
536 // SessionModeColor for session mode indicator (border and toaster). Defaults to "#9B59B6" (purple)
537 SessionModeColor string `mapstructure:"session_mode_color" yaml:"session_mode_color" toml:"session_mode_color" json:"session_mode_color"` //nolint:lll // struct tags must stay on one line
538 // ResizeModeColor for resize mode indicator (border and toaster). Defaults to "#00D4AA" (teal)
539 ResizeModeColor string `mapstructure:"resize_mode_color" yaml:"resize_mode_color" toml:"resize_mode_color" json:"resize_mode_color"` //nolint:lll // struct tags must stay on one line
540
541 // ModeIndicatorToasterEnabled shows a toaster notification when modal modes are active.
542 // Default: true
543 ModeIndicatorToasterEnabled bool `mapstructure:"mode_indicator_toaster_enabled" yaml:"mode_indicator_toaster_enabled" toml:"mode_indicator_toaster_enabled" json:"mode_indicator_toaster_enabled"` //nolint:lll // struct tags must stay on one line
544
545 // TransitionDuration in milliseconds for border animations
546 TransitionDuration int `mapstructure:"transition_duration" yaml:"transition_duration" toml:"transition_duration" json:"transition_duration"` //nolint:lll // struct tags must stay on one line
547}
548
549// SessionConfig holds session persistence settings.
550type SessionConfig struct {
551 // AutoRestore automatically restores the last session on startup.
552 // Default: false
553 AutoRestore bool `mapstructure:"auto_restore" yaml:"auto_restore" toml:"auto_restore" json:"auto_restore"`
554
555 // SnapshotIntervalMs is the minimum interval between snapshots in milliseconds.
556 // Default: 5000
557 SnapshotIntervalMs int `mapstructure:"snapshot_interval_ms" yaml:"snapshot_interval_ms" toml:"snapshot_interval_ms" json:"snapshot_interval_ms"` //nolint:lll // struct tags must stay on one line
558
559 // MaxExitedSessions is the maximum number of exited sessions to keep.
560 // Default: 50
561 MaxExitedSessions int `mapstructure:"max_exited_sessions" yaml:"max_exited_sessions" toml:"max_exited_sessions" json:"max_exited_sessions"` //nolint:lll // struct tags must stay on one line
562
563 // MaxExitedSessionAgeDays is the maximum age in days for exited sessions.
564 // Sessions older than this will be automatically deleted on startup.
565 // Default: 7
566 MaxExitedSessionAgeDays int `mapstructure:"max_exited_session_age_days" yaml:"max_exited_session_age_days" toml:"max_exited_session_age_days" json:"max_exited_session_age_days"` //nolint:lll // struct tags must stay on one line
567
568 // SessionMode defines modal behavior for session management (Ctrl+O).
569 SessionMode SessionModeConfig `mapstructure:"session_mode" yaml:"session_mode" toml:"session_mode" json:"session_mode"`
570}
571
572// SessionModeConfig defines modal behavior for session management.
573type SessionModeConfig struct {
574 ActivationShortcut string `mapstructure:"activation_shortcut" yaml:"activation_shortcut" toml:"activation_shortcut" json:"activation_shortcut"` //nolint:lll // struct tags must stay on one line
575 TimeoutMilliseconds int `mapstructure:"timeout_ms" yaml:"timeout_ms" toml:"timeout_ms" json:"timeout_ms"`
576 Actions map[string][]string `mapstructure:"actions" yaml:"actions" toml:"actions" json:"actions"`
577}
578
579// GetKeyBindings returns an inverted map for O(1) key→action lookup.
580// This is built from the action→keys structure in the config.
581func (s *SessionModeConfig) GetKeyBindings() map[string]string {
582 keyToAction := make(map[string]string)
583 for action, keys := range s.Actions {
584 for _, key := range keys {
585 keyToAction[key] = action
586 }
587 }
588 return keyToAction
589}