package uoscconf import ( "gitgud.io/mike/mpv-manager/internal/scriptopts" ) // Value types for Option.ValueType. const ( TypeBool = scriptopts.TypeBool TypeInt = scriptopts.TypeInt TypeFloat = scriptopts.TypeFloat TypeString = scriptopts.TypeString TypeChoice = scriptopts.TypeChoice ) // Option describes a curated, editable uosc.conf option. type Option = scriptopts.Option // knownOptions is the curated set of editable uosc.conf options, based on // the default uosc.conf shipped by uOSC 5.12.0 (and installed by mpv-manager). // Bool options use the file's native yes/no values. var knownOptions = []Option{ {Key: "timeline_style", Default: "line", Description: "Display style of the current position indicator", ValueType: TypeChoice, Choices: []string{"line", "bar"}}, {Key: "timeline_size", Default: "40", Description: "Timeline size when fully expanded, in pixels (0 to disable)", ValueType: TypeInt, Min: 0, Max: 200}, {Key: "timeline_step", Default: "5", Description: "Seconds to seek when scrolling above the timeline (append '!' for exact seeks, e.g. '5!')", ValueType: TypeString}, {Key: "timeline_cache", Default: "yes", Description: "Render cache indicators for streaming content", ValueType: TypeBool}, {Key: "timeline_heatmap", Default: "overlay", Description: "Render a heatmap for YouTube videos", ValueType: TypeChoice, Choices: []string{"overlay", "above", "no"}}, {Key: "progress", Default: "windowed", Description: "When to display an always visible progress bar (minimized timeline)", ValueType: TypeChoice, Choices: []string{"windowed", "fullscreen", "always", "never"}}, {Key: "controls", Default: "menu,gap,subtitles,audio,video,editions,stream-quality,gap,space,speed,space,shuffle,loop-playlist,loop-file,gap,prev,items,next,gap,fullscreen", Description: "Comma delimited layout of controls above the timeline ('never' to disable)", ValueType: TypeString}, {Key: "controls_size", Default: "32", Description: "Size of the controls above the timeline, in pixels", ValueType: TypeInt, Min: 16, Max: 64}, {Key: "volume", Default: "right", Description: "Where to display volume controls", ValueType: TypeChoice, Choices: []string{"none", "left", "right"}}, {Key: "volume_size", Default: "40", Description: "Size of the volume slider, in pixels", ValueType: TypeInt, Min: 10, Max: 100}, {Key: "speed_step", Default: "0.1", Description: "Playback speed change per wheel scroll or drag step", ValueType: TypeFloat, Min: 0.01, Max: 10.0}, {Key: "speed_step_is_factor", Default: "no", Description: "Treat speed_step as a multiplication factor instead of an offset", ValueType: TypeBool}, {Key: "menu_type_to_search", Default: "yes", Description: "Typing any text starts a menu search (no '/' or 'ctrl+f' needed)", ValueType: TypeBool}, {Key: "top_bar", Default: "no-border", Description: "When to show the top bar with window controls and media title", ValueType: TypeChoice, Choices: []string{"never", "no-border", "always"}}, {Key: "top_bar_size", Default: "40", Description: "Size of the top bar, in pixels", ValueType: TypeInt, Min: 20, Max: 80}, {Key: "top_bar_controls", Default: "right", Description: "Where to place the window controls (min/max/close) on the top bar", ValueType: TypeChoice, Choices: []string{"no", "left", "right"}}, {Key: "autoload", Default: "no", Description: "Load the next file in the directory when the playlist ends", ValueType: TypeBool}, {Key: "shuffle", Default: "no", Description: "Enable uosc's playlist/directory shuffle mode", ValueType: TypeBool}, {Key: "scale", Default: "1", Description: "Interface scale factor when windowed", ValueType: TypeFloat, Min: 0.1, Max: 5.0}, {Key: "scale_fullscreen", Default: "1.3", Description: "Interface scale factor in fullscreen", ValueType: TypeFloat, Min: 0.1, Max: 5.0}, {Key: "color", Default: "", Description: "Comma delimited color overrides in RGB HEX (e.g. 'foreground=ffffff,background=000000')", ValueType: TypeString}, {Key: "opacity", Default: "", Description: "Comma delimited opacity overrides (e.g. 'timeline=0.9,thumbnail=1,curtain=0.8')", ValueType: TypeString}, {Key: "chapter_ranges", Default: "openings:30abf964,endings:30abf964,ads:c54e4e80", Description: "Chapter range indicators as 'type:color' pairs (openings, endings, intros, outros, ads)", ValueType: TypeString}, {Key: "autohide", Default: "no", Description: "Hide the UI when mpv autohides the cursor", ValueType: TypeBool}, } // spec configures the shared script-opts machinery with the uOSC file name // and the curated catalog. var spec = &scriptopts.Spec{Name: confFileName, Options: knownOptions} // KnownOptions returns the curated list of editable uosc.conf options. func KnownOptions() []Option { options := make([]Option, len(knownOptions)) for i, option := range knownOptions { options[i] = option options[i].Choices = append([]string(nil), option.Choices...) } return options } // ValidateValue checks value against the type and constraints of the known // option key. Unknown keys and values containing newlines are rejected. func ValidateValue(key, value string) error { return scriptopts.ValidateValue(spec, key, value) }