v0.6.0 5c50dd3

defaults.go RawHistoryFolder

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
30// getDefaultLogDir returns the default log directory, falls back to empty string on error
31func getDefaultLogDir() string {
32	logDir, err := GetLogDir()
33	if err != nil {
34		return ""
35	}
36	return logDir
37}
38
39// DefaultConfig returns the default configuration values for dumber.
40func DefaultConfig() *Config {
41	return &Config{
42		Database: DatabaseConfig{
43			MaxConnections: 1,
44			MaxIdleTime:    time.Minute * defaultMaxIdleTimeMin,
45			QueryTimeout:   time.Second * defaultQueryTimeoutSec,
46		},
47		History: HistoryConfig{
48			MaxEntries:          defaultMaxHistoryEntries,
49			RetentionPeriodDays: defaultRetentionDays, // 1 year
50			CleanupIntervalDays: 1,                    // daily cleanup
51		},
52		SearchShortcuts: map[string]SearchShortcut{
53			"g": {
54				URL:         "https://www.google.com/search?q=%s",
55				Description: "Google search",
56			},
57			"gh": {
58				URL:         "https://github.com/search?q=%s",
59				Description: "GitHub search",
60			},
61			"yt": {
62				URL:         "https://www.youtube.com/results?search_query=%s",
63				Description: "YouTube search",
64			},
65			"w": {
66				URL:         "https://en.wikipedia.org/wiki/%s",
67				Description: "Wikipedia search",
68			},
69		},
70		Dmenu: DmenuConfig{
71			MaxHistoryItems:  defaultMaxHistoryItems,
72			ShowVisitCount:   true,
73			ShowLastVisited:  true,
74			HistoryPrefix:    "🕒",
75			ShortcutPrefix:   "🔍",
76			URLPrefix:        "🌐",
77			DateFormat:       "2006-01-02 15:04",
78			SortByVisitCount: true,
79		},
80		Logging: LoggingConfig{
81			Level:          "info",
82			Format:         "text",              // text or json
83			Filename:       "",                  // empty means stdout
84			MaxSize:        defaultMaxLogSizeMB, // MB
85			MaxBackups:     defaultMaxBackups,
86			MaxAge:         defaultMaxLogAgeDays, // days
87			Compress:       true,
88			LogDir:         getDefaultLogDir(),
89			EnableFileLog:  true,
90			CaptureStdout:  false,
91			CaptureStderr:  false,
92			CaptureCOutput: false, // Disabled by default to avoid performance impact
93			DebugFile:      "debug.log",
94			VerboseWebKit:  false,
95		},
96		Appearance: AppearanceConfig{
97			SansFont:        "Fira Sans",
98			SerifFont:       "Fira Sans",
99			MonospaceFont:   "Fira Code",
100			DefaultFontSize: defaultFontSize,
101		},
102		VideoAcceleration: VideoAccelerationConfig{
103			EnableVAAPI:      true,
104			AutoDetectGPU:    true,
105			VAAPIDriverName:  "", // Will be auto-detected
106			EnableAllDrivers: true,
107			LegacyVAAPI:      false,
108		},
109		CodecPreferences: CodecConfig{
110			PreferredCodecs:           "av1,h264",                                                                                              // AV1 first, but allow VP9 fallback for higher resolutions
111			ForceAV1:                  false,                                                                                                   // Use smart AV1 negotiation instead of forcing
112			BlockVP9:                  false,                                                                                                   // Allow VP9 for higher resolutions
113			BlockVP8:                  true,                                                                                                    // Still block VP8 as it's outdated
114			AV1HardwareOnly:           false,                                                                                                   // Allow software AV1 fallback
115			DisableVP9Hardware:        false,                                                                                                   // Allow VP9 hardware for high res content
116			VideoBufferSizeMB:         16,                                                                                                      // Larger buffer for AV1 streams
117			QueueBufferTimeSec:        10,                                                                                                      // More buffering time for smooth playback
118			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
119			AV1MaxResolution:          "1080p",                                                                                                 // Optimal AV1 up to 1080p, fallback to VP9 for higher res
120			DisableTwitchCodecControl: true,                                                                                                    // Disable codec control on Twitch by default (prevents theater/fullscreen freezing)
121		},
122		RenderingMode: RenderingModeAuto,
123	}
124}
125
126// GetDefaultSearchShortcuts returns the default search shortcuts.
127func GetDefaultSearchShortcuts() map[string]SearchShortcut {
128	return map[string]SearchShortcut{
129		"g": {
130			URL:         "https://www.google.com/search?q=%s",
131			Description: "Google search",
132		},
133		"gh": {
134			URL:         "https://github.com/search?q=%s",
135			Description: "GitHub search",
136		},
137		"yt": {
138			URL:         "https://www.youtube.com/results?search_query=%s",
139			Description: "YouTube search",
140		},
141		"w": {
142			URL:         "https://en.wikipedia.org/wiki/%s",
143			Description: "Wikipedia search",
144		},
145		"ddg": {
146			URL:         "https://duckduckgo.com/?q=%s",
147			Description: "DuckDuckGo search",
148		},
149		"so": {
150			URL:         "https://stackoverflow.com/search?q=%s",
151			Description: "Stack Overflow search",
152		},
153		"r": {
154			URL:         "https://www.reddit.com/search?q=%s",
155			Description: "Reddit search",
156		},
157		"npm": {
158			URL:         "https://www.npmjs.com/search?q=%s",
159			Description: "npm package search",
160		},
161		"go": {
162			URL:         "https://pkg.go.dev/search?q=%s",
163			Description: "Go package search",
164		},
165		"mdn": {
166			URL:         "https://developer.mozilla.org/en-US/search?q=%s",
167			Description: "MDN Web Docs search",
168		},
169	}
170}
171
172// Note: We build our own browser, so no external browser commands needed

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 8

Tags 42

↑↓ moveenter openesc close