1package config
2
3import "github.com/bnema/dumber/internal/domain/entity"
4
5// Type aliases for config value types now defined in domain/entity.
6// These aliases keep all existing config-package callers working without
7// any changes to their import paths.
8
9// AppearanceConfig holds UI/rendering preferences.
10type AppearanceConfig = entity.AppearanceConfig
11
12// ColorPalette contains semantic color tokens for light/dark themes.
13type ColorPalette = entity.ColorPalette
14
15// ActionBinding defines a keybinding with optional description.
16type ActionBinding = entity.ActionBinding
17
18// PaneModeConfig defines modal behavior for pane management.
19type PaneModeConfig = entity.PaneModeConfig
20
21// TabModeConfig defines modal behavior for tab management (Zellij-style).
22type TabModeConfig = entity.TabModeConfig
23
24// ResizeModeConfig defines modal behavior for resizing panes (Zellij-style).
25type ResizeModeConfig = entity.ResizeModeConfig
26
27// SessionModeConfig defines modal behavior for session management.
28type SessionModeConfig = entity.SessionModeConfig
29
30// SessionConfig holds session persistence settings.
31type SessionConfig = entity.SessionConfig
32
33// GlobalShortcutsConfig defines global shortcuts (always active, not modal).
34type GlobalShortcutsConfig = entity.GlobalShortcutsConfig
35
36// FloatingPaneProfile defines a shortcut profile that opens a URL in the floating pane.
37type FloatingPaneProfile = entity.FloatingPaneProfile
38
39// FloatingPaneConfig defines persistent floating pane behavior.
40type FloatingPaneConfig = entity.FloatingPaneConfig
41
42// WorkspaceStylingConfig defines visual styling for workspace panes.
43type WorkspaceStylingConfig = entity.WorkspaceStylingConfig
44
45// PopupBehavior defines how popup windows should be opened.
46type PopupBehavior = entity.PopupBehavior
47
48const (
49 // PopupBehaviorSplit opens popups in a split pane (default)
50 PopupBehaviorSplit = entity.PopupBehaviorSplit
51 // PopupBehaviorStacked opens popups in a stacked pane
52 PopupBehaviorStacked = entity.PopupBehaviorStacked
53 // PopupBehaviorTabbed opens popups as a new tab
54 PopupBehaviorTabbed = entity.PopupBehaviorTabbed
55 // PopupBehaviorWindowed opens popups in a new workspace window
56 PopupBehaviorWindowed = entity.PopupBehaviorWindowed
57)
58
59// OmniboxInitialBehavior defines how omnibox history is ordered on open.
60type OmniboxInitialBehavior = entity.OmniboxInitialBehavior
61
62const (
63 // OmniboxInitialBehaviorRecent shows recent visits first.
64 OmniboxInitialBehaviorRecent = entity.OmniboxInitialBehaviorRecent
65 // OmniboxInitialBehaviorMostVisited shows most visited sites first.
66 OmniboxInitialBehaviorMostVisited = entity.OmniboxInitialBehaviorMostVisited
67 // OmniboxInitialBehaviorNone shows no initial history.
68 OmniboxInitialBehaviorNone = entity.OmniboxInitialBehaviorNone
69)
70
71// BrowsingContextConfig defines handling for browsing contexts (popups, tabs, new windows).
72type BrowsingContextConfig = entity.BrowsingContextConfig
73
74// Deprecated: PopupBehaviorConfig is a compatibility alias for BrowsingContextConfig.
75type PopupBehaviorConfig = entity.BrowsingContextConfig
76
77// WorkspaceConfig captures layout, pane, and tab behavior preferences.
78type WorkspaceConfig = entity.WorkspaceConfig
79
80// UpdateConfig holds automatic update settings.
81type UpdateConfig = entity.UpdateConfig
82
83// Config represents the complete configuration for dumber.
84type Config struct {
85 Database DatabaseConfig `mapstructure:"database" yaml:"database" toml:"database"`
86 History HistoryConfig `mapstructure:"history" yaml:"history" toml:"history"`
87 SearchShortcuts map[string]SearchShortcut `mapstructure:"search_shortcuts" yaml:"search_shortcuts" toml:"search_shortcuts"`
88 // DefaultSearchEngine is the URL template for the default search engine (must contain %s placeholder)
89 DefaultSearchEngine string `mapstructure:"default_search_engine" yaml:"default_search_engine" toml:"default_search_engine"`
90 Dmenu DmenuConfig `mapstructure:"dmenu" yaml:"dmenu" toml:"dmenu"`
91 Logging LoggingConfig `mapstructure:"logging" yaml:"logging" toml:"logging"`
92 Appearance AppearanceConfig `mapstructure:"appearance" yaml:"appearance" toml:"appearance"`
93 Debug DebugConfig `mapstructure:"debug" yaml:"debug" toml:"debug"`
94 // DefaultWebpageZoom sets the default zoom level for pages without saved zoom settings (1.0 = 100%, 1.2 = 120%)
95 DefaultWebpageZoom float64 `mapstructure:"default_webpage_zoom" yaml:"default_webpage_zoom" toml:"default_webpage_zoom"`
96 // DefaultUIScale sets the default UI scale for GTK widgets (1.0 = 100%, 2.0 = 200%)
97 DefaultUIScale float64 `mapstructure:"default_ui_scale" yaml:"default_ui_scale" toml:"default_ui_scale"`
98 // SidebarWidth sets the preferred width (px) for the history sidebar.
99 // Clamped to [280, 380] at runtime. 0 means use default (320).
100 SidebarWidth int `mapstructure:"sidebar_width" yaml:"sidebar_width" toml:"sidebar_width"`
101 // Workspace defines workspace, pane, and tab handling behavior.
102 Workspace WorkspaceConfig `mapstructure:"workspace" yaml:"workspace" toml:"workspace"`
103 // Session controls session persistence and restoration.
104 Session SessionConfig `mapstructure:"session" yaml:"session" toml:"session"`
105 // ContentFiltering controls ad blocking and content filtering
106 ContentFiltering ContentFilteringConfig `mapstructure:"content_filtering" yaml:"content_filtering" toml:"content_filtering"`
107 // Clipboard controls clipboard-related behavior
108 Clipboard ClipboardConfig `mapstructure:"clipboard" yaml:"clipboard" toml:"clipboard"`
109 // Omnibox controls the omnibox behavior (initial history display)
110 Omnibox OmniboxConfig `mapstructure:"omnibox" yaml:"omnibox" toml:"omnibox"`
111 // Media controls video playback and hardware acceleration
112 Media MediaConfig `mapstructure:"media" yaml:"media" toml:"media"`
113 // Update controls automatic update checking and downloading.
114 Update UpdateConfig `mapstructure:"update" yaml:"update" toml:"update"`
115 // Downloads configures file download behavior.
116 Downloads DownloadsConfig `mapstructure:"downloads" yaml:"downloads" toml:"downloads"`
117 // Engine holds engine selection and unified engine options.
118 Engine EngineConfig `mapstructure:"engine" toml:"engine" yaml:"engine"`
119}
120
121// CookiePolicy controls cookie acceptance behavior.
122type CookiePolicy string
123
124const (
125 // CookiePolicyAlways accepts all cookies.
126 CookiePolicyAlways CookiePolicy = "always"
127 // CookiePolicyNoThirdParty blocks third-party cookies.
128 CookiePolicyNoThirdParty CookiePolicy = "no_third_party"
129 // CookiePolicyNever blocks all cookies.
130 CookiePolicyNever CookiePolicy = "never"
131)
132
133// GSKRendererMode controls the GTK Scene Kit renderer selection.
134type GSKRendererMode string
135
136const (
137 GSKRendererAuto GSKRendererMode = "auto"
138 GSKRendererOpenGL GSKRendererMode = "opengl"
139 GSKRendererVulkan GSKRendererMode = "vulkan"
140 GSKRendererCairo GSKRendererMode = "cairo"
141)
142
143// HardwareDecodingMode controls video hardware acceleration.
144type HardwareDecodingMode string
145
146const (
147 // HardwareDecodingAuto lets GStreamer choose (hw preferred, sw fallback)
148 HardwareDecodingAuto HardwareDecodingMode = "auto"
149 // HardwareDecodingForce requires hardware decoding (fails if unavailable)
150 HardwareDecodingForce HardwareDecodingMode = "force"
151 // HardwareDecodingDisable uses software decoding only
152 HardwareDecodingDisable HardwareDecodingMode = "disable"
153)
154
155// GLRenderingMode controls OpenGL API selection for video rendering.
156type GLRenderingMode string
157
158const (
159 // GLRenderingModeAuto lets GStreamer choose the best GL API
160 GLRenderingModeAuto GLRenderingMode = "auto"
161 // GLRenderingModeGLES2 forces GLES2 (better for some mobile/embedded GPUs)
162 GLRenderingModeGLES2 GLRenderingMode = "gles2"
163 // GLRenderingModeGL3 forces OpenGL 3.x desktop
164 GLRenderingModeGL3 GLRenderingMode = "gl3"
165 // GLRenderingModeNone disables GL-based rendering
166 GLRenderingModeNone GLRenderingMode = "none"
167)
168
169// PerformanceProfile selects preset performance tuning settings.
170type PerformanceProfile string
171
172const (
173 // ProfileDefault uses WebKit defaults (no tuning applied).
174 ProfileDefault PerformanceProfile = "default"
175 // ProfileLite reduces resource usage for low-RAM systems.
176 ProfileLite PerformanceProfile = "lite"
177 // ProfileBalanced is a conservative compatibility preset between lite and max.
178 ProfileBalanced PerformanceProfile = "balanced"
179 // ProfileMax maximizes responsiveness for heavy pages (GitHub PRs, etc).
180 ProfileMax PerformanceProfile = "max"
181 // ProfileCustom allows full control over individual performance settings.
182 ProfileCustom PerformanceProfile = "custom"
183)
184
185// ThemeDefault is the default theme setting (follows system).
186const ThemeDefault = "default"
187
188const (
189 // ThemePreferDark explicitly selects dark theme.
190 ThemePreferDark = "prefer-dark"
191 // ThemePreferLight explicitly selects light theme.
192 ThemePreferLight = "prefer-light"
193)
194
195// MediaConfig holds video playback and hardware acceleration preferences.
196type MediaConfig struct {
197 // HardwareDecodingMode controls hardware vs software video decoding
198 // Values: "auto" (default), "force", "disable"
199 HardwareDecodingMode HardwareDecodingMode `mapstructure:"hardware_decoding" yaml:"hardware_decoding" toml:"hardware_decoding"`
200 // PreferAV1 prioritizes AV1 codec (most efficient) when available
201 PreferAV1 bool `mapstructure:"prefer_av1" yaml:"prefer_av1" toml:"prefer_av1"`
202 // ShowDiagnosticsOnStartup shows media capability warnings at startup
203 ShowDiagnosticsOnStartup bool `mapstructure:"show_diagnostics" yaml:"show_diagnostics" toml:"show_diagnostics"`
204 // ForceVSync forces vertical sync for video playback (may help with tearing).
205 //
206 // Deprecated: moved to [engine.webkit]. Kept for read compatibility during migration.
207 ForceVSync bool `mapstructure:"force_vsync" yaml:"force_vsync" toml:"-"`
208 // GLRenderingMode controls OpenGL API selection for video rendering.
209 // Values: "auto" (default), "gles2", "gl3", "none"
210 //
211 // Deprecated: moved to [engine.webkit]. Kept for read compatibility during migration.
212 GLRenderingMode GLRenderingMode `mapstructure:"gl_rendering_mode" yaml:"gl_rendering_mode" toml:"-"`
213 // GStreamerDebugLevel sets GStreamer debug verbosity (0=off, 1-5=increasing verbosity).
214 //
215 // Deprecated: moved to [engine.webkit]. Kept for read compatibility during migration.
216 GStreamerDebugLevel int `mapstructure:"gstreamer_debug_level" yaml:"gstreamer_debug_level" toml:"-"`
217}
218
219// DatabaseConfig holds database-related configuration.
220type DatabaseConfig struct {
221 Path string `mapstructure:"path" yaml:"path" toml:"path"`
222}
223
224// HistoryConfig holds history-related configuration.
225type HistoryConfig struct {
226 MaxEntries int `mapstructure:"max_entries" yaml:"max_entries" toml:"max_entries"`
227 RetentionPeriodDays int `mapstructure:"retention_period_days" yaml:"retention_period_days" toml:"retention_period_days"`
228 CleanupIntervalDays int `mapstructure:"cleanup_interval_days" yaml:"cleanup_interval_days" toml:"cleanup_interval_days"`
229}
230
231// PerformanceConfig holds internal performance tuning options.
232// These are not exposed in dumb://config UI but can be set in config file.
233type PerformanceConfig struct {
234 // Profile selects a preset performance configuration.
235 // Values: "default" (no tuning), "lite" (low RAM), "balanced" (compatibility), "max" (heavy pages), "custom" (manual control)
236 // When profile is not "custom", individual tuning fields below are ignored and computed from the profile.
237 // Default: "default"
238 Profile PerformanceProfile `mapstructure:"profile" yaml:"profile" toml:"profile"`
239
240 // ZoomCacheSize is the number of domain zoom levels to cache in memory.
241 // Higher values reduce database queries but use more memory.
242 // Default: 256 domains (~20KB memory)
243 ZoomCacheSize int `mapstructure:"zoom_cache_size" yaml:"zoom_cache_size" toml:"zoom_cache_size"`
244
245 // WebViewPoolPrewarmCount is the number of WebViews to pre-create at startup.
246 // Higher values speed up initial tab creation but use more memory.
247 // Default: 4 (custom mode), computed from profile otherwise
248 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
249
250 // --- Skia rendering threads (env vars) ---
251 // NOTE: Fields below only apply when Profile is "custom".
252 // SkiaCPUPaintingThreads sets WEBKIT_SKIA_CPU_PAINTING_THREADS.
253 // Default: 0 (unset, uses WebKit default)
254 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
255
256 // SkiaGPUPaintingThreads sets WEBKIT_SKIA_GPU_PAINTING_THREADS.
257 // Default: -1 (unset). Value 0 disables GPU tile painting.
258 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
259
260 // SkiaEnableCPURendering forces CPU rendering via WEBKIT_SKIA_ENABLE_CPU_RENDERING=1.
261 // Default: false
262 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
263
264 // --- Web process memory pressure ---
265 // WebProcessMemoryLimitMB sets memory limit in MB for web processes.
266 // Default: 0 (unset, uses WebKit default: system RAM capped at 3GB)
267 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
268
269 // WebProcessMemoryPollIntervalSec sets poll interval for memory checks.
270 // Default: 0 (unset, uses WebKit default: 30 seconds)
271 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
272
273 // WebProcessMemoryConservativeThreshold sets threshold for conservative memory release.
274 // Valid: (0, 1). Default: 0 (unset, uses WebKit default: 0.33)
275 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
276
277 // WebProcessMemoryStrictThreshold sets threshold for strict memory release.
278 // Valid: (0, 1). Default: 0 (unset, uses WebKit default: 0.5)
279 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
280
281 // --- Network process memory pressure ---
282 // NetworkProcessMemoryLimitMB sets memory limit in MB for network process.
283 // Default: 0 (unset)
284 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
285
286 // NetworkProcessMemoryPollIntervalSec sets poll interval for memory checks.
287 // Default: 0 (unset)
288 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
289
290 // NetworkProcessMemoryConservativeThreshold sets threshold for conservative memory release.
291 // Valid: (0, 1). Default: 0 (unset)
292 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
293
294 // NetworkProcessMemoryStrictThreshold sets threshold for strict memory release.
295 // Valid: (0, 1). Default: 0 (unset)
296 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
297}
298
299// SearchShortcut represents a search shortcut configuration.
300type SearchShortcut struct {
301 URL string `mapstructure:"url" toml:"url" yaml:"url" json:"url"`
302 Description string `mapstructure:"description" toml:"description" yaml:"description" json:"description"`
303}
304
305// ShortcutURLs returns a simple map of shortcut keys to URL templates.
306// This is useful for passing to url.BuildSearchURL.
307func (c *Config) ShortcutURLs() map[string]string {
308 result := make(map[string]string, len(c.SearchShortcuts))
309 for key, shortcut := range c.SearchShortcuts {
310 result[key] = shortcut.URL
311 }
312 return result
313}
314
315// DmenuConfig holds dmenu/rofi integration configuration.
316type DmenuConfig struct {
317 MaxHistoryDays int `mapstructure:"max_history_days" yaml:"max_history_days" toml:"max_history_days"`
318 ShowVisitCount bool `mapstructure:"show_visit_count" yaml:"show_visit_count" toml:"show_visit_count"`
319 ShowLastVisited bool `mapstructure:"show_last_visited" yaml:"show_last_visited" toml:"show_last_visited"`
320 HistoryPrefix string `mapstructure:"history_prefix" yaml:"history_prefix" toml:"history_prefix"`
321 ShortcutPrefix string `mapstructure:"shortcut_prefix" yaml:"shortcut_prefix" toml:"shortcut_prefix"`
322 URLPrefix string `mapstructure:"url_prefix" yaml:"url_prefix" toml:"url_prefix"`
323 DateFormat string `mapstructure:"date_format" yaml:"date_format" toml:"date_format"`
324 SortByVisitCount bool `mapstructure:"sort_by_visit_count" yaml:"sort_by_visit_count" toml:"sort_by_visit_count"`
325}
326
327// LoggingConfig holds logging configuration.
328type LoggingConfig struct {
329 Level string `mapstructure:"level" yaml:"level" toml:"level"`
330 Format string `mapstructure:"format" yaml:"format" toml:"format"`
331 MaxAge int `mapstructure:"max_age" yaml:"max_age" toml:"max_age"`
332 MaxFiles int `mapstructure:"max_files" yaml:"max_files" toml:"max_files"`
333
334 // File output configuration
335 LogDir string `mapstructure:"log_dir" yaml:"log_dir" toml:"log_dir"`
336 EnableFileLog bool `mapstructure:"enable_file_log" yaml:"enable_file_log" toml:"enable_file_log"`
337
338 // Capture browser console to logs
339 CaptureConsole bool `mapstructure:"capture_console" yaml:"capture_console" toml:"capture_console" json:"capture_console"`
340
341 // Capture GTK4/WebKitGTK6 messages to session logs
342 CaptureGTKLogs bool `mapstructure:"capture_gtk_logs" yaml:"capture_gtk_logs" toml:"capture_gtk_logs" json:"capture_gtk_logs"`
343}
344
345// ContentFilteringConfig holds content filtering and ad blocking preferences
346type ContentFilteringConfig struct {
347 // Enabled controls whether ad blocking is active (default: true)
348 Enabled bool `mapstructure:"enabled" yaml:"enabled" toml:"enabled"`
349 // AutoUpdate controls whether filters are automatically updated (default: true)
350 AutoUpdate bool `mapstructure:"auto_update" yaml:"auto_update" toml:"auto_update"`
351 // Note: Filters are downloaded from bnema/ublock-webkit-filters GitHub releases
352 // Note: Whitelist is managed via database (content_whitelist table)
353}
354
355// ClipboardConfig holds clipboard-related behavior preferences
356type ClipboardConfig struct {
357 // AutoCopyOnSelection automatically copies selected text to clipboard (zellij-style).
358 // When enabled, selecting text in a webview immediately copies it to clipboard.
359 // Does not apply to text selection in input fields or textareas.
360 // Default: true
361 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
362}
363
364// OmniboxConfig holds omnibox behavior preferences
365type OmniboxConfig struct {
366 // InitialBehavior controls what to show when omnibox opens with empty input
367 // Values: "recent" (recent visits), "most_visited" (most visited sites), "none" (nothing)
368 InitialBehavior OmniboxInitialBehavior `mapstructure:"initial_behavior" yaml:"initial_behavior" toml:"initial_behavior"`
369 // MostVisitedDays controls how many days of history are considered when initial behavior is most_visited.
370 // 0 means all history.
371 // Default: 30.
372 MostVisitedDays int `mapstructure:"most_visited_days" yaml:"most_visited_days" toml:"most_visited_days"`
373 // AutoOpenOnNewPane opens the omnibox automatically when a new pane is created.
374 // Default: false
375 AutoOpenOnNewPane bool `mapstructure:"auto_open_on_new_pane" yaml:"auto_open_on_new_pane" toml:"auto_open_on_new_pane"`
376}
377
378// DebugConfig holds debug and troubleshooting options
379type DebugConfig struct {
380 // Enable browser developer tools (F12, Inspect Element in context menu)
381 EnableDevTools bool `mapstructure:"enable_devtools" yaml:"enable_devtools" toml:"enable_devtools"`
382}
383
384// DownloadsConfig holds file download preferences.
385type DownloadsConfig struct {
386 // Path is the directory where downloads are saved.
387 // Empty string means use XDG_DOWNLOAD_DIR or ~/Downloads.
388 Path string `mapstructure:"path" yaml:"path" toml:"path"`
389}