Configuration File
Thesettings.json file location varies by platform:
- Linux
- macOS
- Windows
$XDG_CONFIG_HOME if set.You can edit settings in the TUI by pressing
s or by directly modifying the JSON file. Changes take effect after restarting Surge.Directory Structure
Surge follows OS conventions for storing its files:| Directory | Purpose | Linux | macOS | Windows |
|---|---|---|---|---|
| Config | settings.json | ~/.config/surge/ | ~/Library/Application Support/surge/ | %APPDATA%\surge\ |
| State | Database (surge.db), auth token | ~/.local/state/surge/ | ~/Library/Application Support/surge/ | %APPDATA%\surge\ |
| Logs | Timestamped .log files | ~/.local/state/surge/logs/ | ~/Library/Application Support/surge/logs/ | %APPDATA%\surge\logs\ |
| Runtime | PID file, port file, lock | $XDG_RUNTIME_DIR/surge/¹ | $TMPDIR/surge-runtime/ | %TEMP%\surge\ |
¹ Falls back to
~/.local/state/surge/ when $XDG_RUNTIME_DIR is not set (e.g., Docker/headless environments).General Settings
These settings control application behavior:| Key | Type | Description | Default |
|---|---|---|---|
default_download_dir | string | Directory where new downloads are saved. If empty, defaults to ~/Downloads or current directory. | "" |
warn_on_duplicate | bool | Show a warning when adding a download that already exists in the list. | true |
extension_prompt | bool | Prompt for confirmation in the TUI when adding downloads via the browser extension. | false |
auto_resume | bool | Automatically resume paused downloads when Surge starts. | false |
skip_update_check | bool | Disable automatic check for new versions on startup. | false |
clipboard_monitor | bool | Watch the system clipboard for URLs and prompt to download them. | true |
theme | int | UI Theme (0=Adaptive, 1=Light, 2=Dark). | 0 |
log_retention_count | int | Number of recent log files to keep. | 5 |
Theme Values
internal/config/settings.go (excerpt)
Example Configuration
Connection Settings
These settings control network connections and download behavior:| Key | Type | Description | Default |
|---|---|---|---|
max_connections_per_host | int | Maximum concurrent connections allowed to a single host (1-64). | 32 |
max_concurrent_downloads | int | Maximum number of downloads running simultaneously (requires restart). | 3 |
user_agent | string | Custom User-Agent string for HTTP requests. Leave empty for default. | "" |
proxy_url | string | HTTP/HTTPS proxy URL (e.g., http://127.0.0.1:8080). Leave empty to use system settings. | "" |
sequential_download | bool | Download file pieces in strict order (Streaming Mode). Useful for previewing media but may be slower. | false |
min_chunk_size | int64 | Minimum size of a download chunk in bytes (e.g., 2097152 for 2MB). | 2097152 (2MB) |
worker_buffer_size | int | I/O buffer size per worker in bytes (e.g., 524288 for 512KB). | 524288 (512KB) |
Default Values from Code
internal/config/settings.go (excerpt)
Sequential Download (Streaming Mode)
Enable this for media files you want to preview while downloading:Performance Settings
These settings control performance tuning and optimization:| Key | Type | Description | Default |
|---|---|---|---|
max_task_retries | int | Number of times to retry a failed chunk before giving up. | 3 |
slow_worker_threshold | float | Restart workers slower than this fraction of the mean speed (0.0-1.0). | 0.3 |
slow_worker_grace_period | duration | Time to wait before checking a worker’s speed (e.g., 5s). | 5s |
stall_timeout | duration | Restart workers that haven’t received data for this duration (e.g., 3s). | 3s |
speed_ema_alpha | float | Exponential moving average smoothing factor for speed calculation (0.0-1.0). | 0.3 |
Default Values from Code
internal/config/settings.go (excerpt)
Work Stealing and Slow Workers
Surge automatically detects and restarts slow workers:- Slow Worker Threshold: Workers performing below 30% of the mean speed are restarted
- Grace Period: Workers get 5 seconds before speed checks begin
- Stall Timeout: Workers with no data for 3 seconds are restarted
Complete Configuration Example
Editing Settings
- TUI
- JSON File
Environment-Specific Configuration
Resetting to Defaults
To reset all settings to defaults:Migration (Linux XDG)
On Linux, Surge automatically migrates files from the old flat layout to XDG-compliant directories:internal/config/paths.go (excerpt)
On macOS and Windows, all files remain in the application support directory - no migration needed.
Advanced: Runtime Config
Surge converts user settings to a runtime configuration for the download engine:internal/config/settings.go (excerpt)
settings.json when Surge starts.