Documentation
¶
Index ¶
- Constants
- func CategoryNames(categories []Category) []string
- func CategoryOrder() []string
- func EnsureDirs() error
- func GetDocumentsDir() string
- func GetDownloadsDir() string
- func GetLogsDir() string
- func GetMusicDir() string
- func GetPicturesDir() string
- func GetRuntimeDir() string
- func GetSettingsMetadata() map[string][]SettingMeta
- func GetSettingsPath() string
- func GetStateDir() string
- func GetSurgeDir() string
- func GetVideosDir() string
- func ResolveCategoryPath(cat *Category, defaultDownloadDir string) string
- func SaveSettings(s *Settings) error
- type Category
- type CategorySettings
- type ExtensionSettings
- type GeneralSettings
- type NetworkSettings
- type PerformanceSettings
- type RuntimeConfig
- type SettingMeta
- type Settings
Constants ¶
const ( ThemeAdaptive = 0 ThemeLight = 1 ThemeDark = 2 )
const ( KB = 1 << 10 MB = 1 << 20 )
Variables ¶
This section is empty.
Functions ¶
func CategoryNames ¶
CategoryNames returns a slice of category names.
func CategoryOrder ¶
func CategoryOrder() []string
CategoryOrder returns the order of categories for UI tabs.
func GetDocumentsDir ¶
func GetDocumentsDir() string
func GetDownloadsDir ¶
func GetDownloadsDir() string
func GetMusicDir ¶
func GetMusicDir() string
func GetPicturesDir ¶
func GetPicturesDir() string
func GetRuntimeDir ¶
func GetRuntimeDir() string
func GetSettingsMetadata ¶
func GetSettingsMetadata() map[string][]SettingMeta
GetSettingsMetadata returns metadata for all settings organized by category.
func GetSettingsPath ¶
func GetSettingsPath() string
GetSettingsPath returns the path to the settings JSON file.
func GetStateDir ¶
func GetStateDir() string
func GetSurgeDir ¶
func GetSurgeDir() string
GetSurgeDir returns the directory for configuration files (settings.json). Linux: $XDG_CONFIG_HOME/surge or ~/.config/surge macOS: ~/Library/Application Support/surge Windows: %APPDATA%/surge
func GetVideosDir ¶
func GetVideosDir() string
func ResolveCategoryPath ¶
ResolveCategoryPath returns the Path of a category.
func SaveSettings ¶
SaveSettings saves settings to disk atomically.
Types ¶
type Category ¶
type Category struct {
Name string `json:"name"`
Description string `json:"description,omitempty"`
Pattern string `json:"pattern"`
Path string `json:"path"`
}
Category defines a download category for auto-sorting.
func DefaultCategories ¶
func DefaultCategories() []Category
DefaultCategories returns the default set of download categories.
func GetCategoryForFile ¶
GetCategoryForFile returns the last matching category so user-added rules can override broader defaults that appear earlier in the list.
type CategorySettings ¶ added in v0.8.0
type CategorySettings struct {
CategoryEnabled bool `` /* 145-byte string literal not displayed */
Categories []Category `json:"categories" ui_ignored:"true"`
}
CategorySettings holds options specifically for categorizing files.
type ExtensionSettings ¶ added in v0.8.0
type ExtensionSettings struct {
ExtensionPrompt bool `` /* 130-byte string literal not displayed */
ChromeExtensionURL string `json:"chrome_extension_url" ui_label:"Get Chrome Extension" ui_type:"link" ui_desc:"Open the Surge Chrome extension page."`
FirefoxExtensionURL string `json:"firefox_extension_url" ui_label:"Get Firefox Extension" ui_type:"link" ui_desc:"Open the Surge Firefox extension page."`
AuthToken string `` /* 140-byte string literal not displayed */
InstructionsURL string `` /* 151-byte string literal not displayed */
}
ExtensionSettings contains settings for the browser extension.
type GeneralSettings ¶
type GeneralSettings struct {
DefaultDownloadDir string `` /* 144-byte string literal not displayed */
WarnOnDuplicate bool `json:"warn_on_duplicate" ui_label:"Warn on Duplicate" ui_desc:"Show warning when adding a download that already exists."`
DownloadCompleteNotification bool `` /* 140-byte string literal not displayed */
AllowRemoteOpenActions bool `` /* 184-byte string literal not displayed */
AutoResume bool `json:"auto_resume" ui_label:"Auto Resume" ui_desc:"Automatically resume paused downloads on startup."`
SkipUpdateCheck bool `json:"skip_update_check" ui_label:"Skip Update Check" ui_desc:"Disable automatic check for new versions on startup."`
ClipboardMonitor bool `json:"clipboard_monitor" ui_label:"Clipboard Monitor" ui_desc:"Watch clipboard for URLs and prompt to download them."`
Theme int `json:"theme" ui_label:"App Theme" ui_desc:"UI Theme (System, Light, Dark)."`
LogRetentionCount int `json:"log_retention_count" ui_label:"Log Retention Count" ui_desc:"Number of recent log files to keep."`
LiveSpeedGraph bool `json:"live_speed_graph" ui_label:"Live Speed Graph" ui_desc:"Use live speed for graph instead of EMA smoothed speed."`
}
GeneralSettings contains application behavior settings.
type NetworkSettings ¶
type NetworkSettings struct {
MaxConnectionsPerHost int `json:"max_connections_per_host" ui_label:"Max Connections/Host" ui_desc:"Maximum concurrent connections per host (1-64)."`
MaxConcurrentDownloads int `` /* 147-byte string literal not displayed */
MaxConcurrentProbes int `` /* 159-byte string literal not displayed */
UserAgent string `json:"user_agent" ui_label:"User Agent" ui_desc:"Custom User-Agent string for HTTP requests. Leave empty for default."`
ProxyURL string `` /* 133-byte string literal not displayed */
CustomDNS string `` /* 132-byte string literal not displayed */
SequentialDownload bool `json:"sequential_download" ui_label:"Sequential Download" ui_desc:"Download pieces in order (Streaming Mode). May be slower."`
MinChunkSize int64 `json:"min_chunk_size" ui_label:"Min Chunk Size" ui_desc:"Minimum download chunk size in MB (e.g., 2)."`
WorkerBufferSize int `json:"worker_buffer_size" ui_label:"Worker Buffer Size" ui_desc:"I/O buffer size per worker in KB (e.g., 512)."`
}
NetworkSettings contains network connection parameters.
type PerformanceSettings ¶
type PerformanceSettings struct {
MaxTaskRetries int `json:"max_task_retries" ui_label:"Max Task Retries" ui_desc:"Number of times to retry a failed chunk before giving up."`
SlowWorkerThreshold float64 `` /* 138-byte string literal not displayed */
SlowWorkerGracePeriod time.Duration `json:"slow_worker_grace_period" ui_label:"Slow Worker Grace" ui_desc:"Grace period before checking worker speed (e.g., 5s)."`
StallTimeout time.Duration `json:"stall_timeout" ui_label:"Stall Timeout" ui_desc:"Restart workers with no data for this duration (e.g., 5s)."`
SpeedEmaAlpha float64 `json:"speed_ema_alpha" ui_label:"Speed EMA Alpha" ui_desc:"Exponential moving average smoothing factor (0.0-1.0)."`
}
PerformanceSettings contains performance tuning parameters.
type RuntimeConfig ¶
type RuntimeConfig struct {
MaxConnectionsPerHost int
MaxConcurrentProbes int
UserAgent string
ProxyURL string
CustomDNS string
SequentialDownload bool
MinChunkSize int64
WorkerBufferSize int
MaxTaskRetries int
SlowWorkerThreshold float64
SlowWorkerGracePeriod time.Duration
StallTimeout time.Duration
SpeedEmaAlpha float64
}
ToRuntimeConfig converts Settings to a downloader RuntimeConfig This is used to pass user settings to the download engine
type SettingMeta ¶
type SettingMeta struct {
Key string // JSON key name
Label string // Human-readable label
Description string // Help text displayed in right pane
Type string // "string", "int", "int64", "bool", "duration", "float64", "auth_token", "link"
}
SettingMeta provides metadata for a single setting (for UI rendering).
type Settings ¶
type Settings struct {
General GeneralSettings `json:"general" ui_label:"General"`
Network NetworkSettings `json:"network" ui_label:"Network"`
Performance PerformanceSettings `json:"performance" ui_label:"Performance"`
Categories CategorySettings `json:"categories" ui_label:"Categories"`
Extension ExtensionSettings `json:"extension" ui_label:"Extension"`
}
Settings holds all user-configurable application settings organized by category.
func DefaultSettings ¶
func DefaultSettings() *Settings
DefaultSettings returns a new Settings instance with sensible defaults.
func LoadSettings ¶
LoadSettings loads settings from disk. Returns defaults if file doesn't exist or if the JSON is corrupt, so the application can always start.
func (*Settings) ToRuntimeConfig ¶
func (s *Settings) ToRuntimeConfig() *RuntimeConfig
ToRuntimeConfig creates a RuntimeConfig from user Settings