1// Package config provides default configuration values for dumber.
2package config
3
4import (
5 "time"
6)
7
8// Default configuration constants
9const (
10 // Database defaults
11 defaultMaxIdleTimeMin = 5 // minutes
12 defaultQueryTimeoutSec = 30 // seconds
13
14 // History defaults
15 defaultMaxHistoryEntries = 10000 // entries
16 defaultRetentionDays = 365 // 1 year
17
18 // Dmenu defaults
19 defaultMaxHistoryItems = 20 // items
20
21 // Logging defaults
22 defaultMaxLogSizeMB = 100 // MB
23 defaultMaxBackups = 3 // backup files
24 defaultMaxLogAgeDays = 7 // days
25
26 // Appearance defaults
27 defaultFontSize = 16 // points
28
29 // Workspace defaults
30 defaultPaneActivationShortcut = "cmdorctrl+p"
31 defaultPaneTimeoutMilliseconds = 3000
32 defaultPopupPlacement = "right"
33
34 // Workspace styling defaults
35 defaultBorderWidth = 2
36 defaultBorderColor = "@theme_selected_bg_color"
37 defaultTransitionDuration = 120
38 defaultBorderRadius = 0
39)
40
41// getDefaultLogDir returns the default log directory, falls back to empty string on error
42func getDefaultLogDir() string {
43 logDir, err := GetLogDir()
44 if err != nil {
45 return ""
46 }
47 return logDir
48}
49
50// DefaultConfig returns the default configuration values for dumber.
51func DefaultConfig() *Config {
52 return &Config{
53 Database: DatabaseConfig{
54 MaxConnections: 1,
55 MaxIdleTime: time.Minute * defaultMaxIdleTimeMin,
56 QueryTimeout: time.Second * defaultQueryTimeoutSec,
57 },
58 History: HistoryConfig{
59 MaxEntries: defaultMaxHistoryEntries,
60 RetentionPeriodDays: defaultRetentionDays, // 1 year
61 CleanupIntervalDays: 1, // daily cleanup
62 },
63 SearchShortcuts: map[string]SearchShortcut{
64 "g": {
65 URL: "https://www.google.com/search?q=%s",
66 Description: "Google search",
67 },
68 "gh": {
69 URL: "https://github.com/search?q=%s",
70 Description: "GitHub search",
71 },
72 "yt": {
73 URL: "https://www.youtube.com/results?search_query=%s",
74 Description: "YouTube search",
75 },
76 "w": {
77 URL: "https://en.wikipedia.org/wiki/%s",
78 Description: "Wikipedia search",
79 },
80 },
81 Dmenu: DmenuConfig{
82 MaxHistoryItems: defaultMaxHistoryItems,
83 ShowVisitCount: true,
84 ShowLastVisited: true,
85 HistoryPrefix: "🕒",
86 ShortcutPrefix: "🔍",
87 URLPrefix: "🌐",
88 DateFormat: "2006-01-02 15:04",
89 SortByVisitCount: true,
90 },
91 Logging: LoggingConfig{
92 Level: "info",
93 Format: "text", // text or json
94 Filename: "", // empty means stdout
95 MaxSize: defaultMaxLogSizeMB, // MB
96 MaxBackups: defaultMaxBackups,
97 MaxAge: defaultMaxLogAgeDays, // days
98 Compress: true,
99 LogDir: getDefaultLogDir(),
100 EnableFileLog: true,
101 CaptureStdout: false,
102 CaptureStderr: false,
103 CaptureCOutput: false, // Disabled by default to avoid performance impact
104 CaptureConsole: false, // Disabled by default
105 DebugFile: "debug.log",
106 VerboseWebKit: false,
107 },
108 Appearance: AppearanceConfig{
109 SansFont: "Fira Sans",
110 SerifFont: "Fira Sans",
111 MonospaceFont: "Fira Code",
112 DefaultFontSize: defaultFontSize,
113 },
114 VideoAcceleration: VideoAccelerationConfig{
115 EnableVAAPI: true,
116 AutoDetectGPU: true,
117 VAAPIDriverName: "", // Will be auto-detected
118 EnableAllDrivers: true,
119 LegacyVAAPI: false,
120 },
121 CodecPreferences: CodecConfig{
122 PreferredCodecs: "av1,h264", // AV1 first, but allow VP9 fallback for higher resolutions
123 ForceAV1: false, // Use smart AV1 negotiation instead of forcing
124 BlockVP9: false, // Allow VP9 for higher resolutions
125 BlockVP8: true, // Still block VP8 as it's outdated
126 AV1HardwareOnly: false, // Allow software AV1 fallback
127 DisableVP9Hardware: false, // Allow VP9 hardware for high res content
128 VideoBufferSizeMB: 16, // Larger buffer for AV1 streams
129 QueueBufferTimeSec: 10, // More buffering time for smooth playback
130 CustomUserAgent: "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36", // Chrome UA with AV1 support
131 AV1MaxResolution: "1080p", // Optimal AV1 up to 1080p, fallback to VP9 for higher res
132 DisableTwitchCodecControl: true, // Disable codec control on Twitch by default (prevents theater/fullscreen freezing)
133 },
134 WebkitMemory: WebkitMemoryConfig{
135 CacheModel: "web_browser", // Aggressive caching for fast page loads
136 EnablePageCache: true, // Instant back/forward navigation
137 MemoryLimitMB: 0, // Use system default
138 ConservativeThreshold: 0.4, // Start cleanup at 40%
139 StrictThreshold: 0.6, // Strict cleanup at 60%
140 KillThreshold: 0.8, // Kill processes at 80%
141 PollIntervalSeconds: 45.0, // Check every 45 seconds
142 EnableGCInterval: 120, // GC every 2 minutes
143 ProcessRecycleThreshold: 50, // Recycle after 50 page loads
144 EnableMemoryMonitoring: true, // Monitor for production tuning
145 },
146 Debug: DebugConfig{
147 EnableWebKitDebug: false,
148 WebKitDebugCategories: "Network:preconnectTo,ContentFilters",
149 EnableFilteringDebug: false,
150 EnableWebViewDebug: false,
151 LogWebKitCrashes: true, // Always log crashes
152 EnableScriptDebug: false,
153 EnableGeneralDebug: false,
154 },
155 APISecurity: APISecurityConfig{
156 Token: "",
157 RequireToken: false,
158 },
159 RenderingMode: RenderingModeGPU,
160 UseDomZoom: false,
161 Workspace: WorkspaceConfig{
162 EnableZellijControls: true,
163 PaneMode: PaneModeConfig{
164 ActivationShortcut: defaultPaneActivationShortcut,
165 TimeoutMilliseconds: defaultPaneTimeoutMilliseconds,
166 ActionBindings: map[string]string{
167 "arrowright": "split-right",
168 "arrowleft": "split-left",
169 "arrowup": "split-up",
170 "arrowdown": "split-down",
171 "r": "split-right",
172 "l": "split-left",
173 "u": "split-up",
174 "d": "split-down",
175 "x": "close-pane",
176 "enter": "confirm",
177 "escape": "cancel",
178 },
179 },
180 Tabs: TabKeyConfig{
181 NewTab: "cmdorctrl+t",
182 CloseTab: "cmdorctrl+w",
183 NextTab: "cmdorctrl+tab",
184 PreviousTab: "cmdorctrl+shift+tab",
185 },
186 Popups: PopupBehaviorConfig{
187 Placement: defaultPopupPlacement,
188 OpenInNewPane: true,
189 FollowPaneContext: true,
190 BlankTargetBehavior: "pane", // Default to pane, future: "tab"
191 EnableSmartDetection: true, // Use WindowProperties to detect popup vs tab
192 OAuthAutoClose: true, // Auto-close OAuth popups on success
193 },
194 Styling: WorkspaceStylingConfig{
195 BorderWidth: defaultBorderWidth,
196 BorderColor: defaultBorderColor,
197 TransitionDuration: defaultTransitionDuration,
198 BorderRadius: defaultBorderRadius,
199 },
200 },
201 }
202}
203
204// GetDefaultSearchShortcuts returns the default search shortcuts.
205func GetDefaultSearchShortcuts() map[string]SearchShortcut {
206 return map[string]SearchShortcut{
207 "g": {
208 URL: "https://www.google.com/search?q=%s",
209 Description: "Google search",
210 },
211 "gh": {
212 URL: "https://github.com/search?q=%s",
213 Description: "GitHub search",
214 },
215 "yt": {
216 URL: "https://www.youtube.com/results?search_query=%s",
217 Description: "YouTube search",
218 },
219 "w": {
220 URL: "https://en.wikipedia.org/wiki/%s",
221 Description: "Wikipedia search",
222 },
223 "ddg": {
224 URL: "https://duckduckgo.com/?q=%s",
225 Description: "DuckDuckGo search",
226 },
227 "so": {
228 URL: "https://stackoverflow.com/search?q=%s",
229 Description: "Stack Overflow search",
230 },
231 "r": {
232 URL: "https://www.reddit.com/search?q=%s",
233 Description: "Reddit search",
234 },
235 "npm": {
236 URL: "https://www.npmjs.com/search?q=%s",
237 Description: "npm package search",
238 },
239 "go": {
240 URL: "https://pkg.go.dev/search?q=%s",
241 Description: "Go package search",
242 },
243 "mdn": {
244 URL: "https://developer.mozilla.org/en-US/search?q=%s",
245 Description: "MDN Web Docs search",
246 },
247 }
248}
249
250// Note: We build our own browser, so no external browser commands needed