Documentation ¶
Overview ¶
Package config contains application-wide configurations and constants. Parts of configuration are user-editable and per-instance and needs to be persisted. Others are static and meant for tuning the application. It also contains some helper methods to read and write config files and create directories when needed.
Index ¶
- Constants
- Variables
- func AppNameVersion() string
- func ConfigFromViper() error
- func NewConfigFile(location string) error
- func ReadUserInput(name string, mask bool) (string, error)
- func SaveConfig() error
- func UpdateViper()
- type AppColor
- type Backend
- type ColorModal
- type ColorNavBar
- type ColorStatus
- type Config
- type GlobalBindings
- type Gui
- type Jellyfin
- type KeyBindings
- type KeyValueProvider
- type MovingBindings
- type NavigationBarBindings
- type PanelBindings
- type Player
- type StdinConfigProvider
- type Subsonic
- type ViperStdConfigProvider
Constants ¶
const ( TextSecondary = tcell.Color179 TextDisabled = tcell.Color241 TextDisabled2 = tcell.Color247 )
const ( AppName = "Jellycli" AppNameLower = "jellycli" Version = "0.9.1" )
const ( // AudioSamplingRate is default sampling rate. This may vary depending on song being played. AudioSamplingRate = 44100 // Volume range in decibels AudioMinVolumedB = -6 AudioMaxVolumedB = 0 AudioMinVolume = 0 AudioMaxVolume = 100 // Audio volume is logarithmic, which base to use AudioVolumeLogBase = 2 CacheTimeout = time.Minute * 5 )
audio configuration
Variables ¶
var ( // PageSize controls paging and is read from config file PageSize = 100 LimitRecentlyPlayed = false // how many recent song to show, if limited LimitedRecentlyPlayedCount = 24 AudioBufferPeriod = time.Millisecond * 100 VolumeStepSize = 5 )
var Color = defaultColors()
var ConfigFile string
ConfigFile is absolute location for configuration file
var (
KeyBinds = DefaultKeyBindings()
)
var LogFile string
LogFile is log file location
Functions ¶
func AppNameVersion ¶ added in v0.2.0
func AppNameVersion() string
AppNameVersion returns string containing application name and current version
func ConfigFromViper ¶ added in v0.8.0
func ConfigFromViper() error
ConfigFromViper reads full application configuration from viper.
func NewConfigFile ¶ added in v0.8.0
NewConfigFile creates new config file in given location. If path contains directory that does not exist, create that as well. If locatin is empty, use default user directory ~/.config/jellycli.
func ReadUserInput ¶
ReadUserInput reads value from stdin. Name is printed like 'Enter <name>. If mask is true, input is masked.
func SaveConfig ¶ added in v0.2.0
func SaveConfig() error
func UpdateViper ¶ added in v0.8.0
func UpdateViper()
Types ¶
type AppColor ¶
type AppColor struct { Background tcell.Color Border tcell.Color BorderFocus tcell.Color ButtonBackground tcell.Color ButtonBackgroundSelected tcell.Color ButtonLabel tcell.Color ButtonLabelSelected tcell.Color Text tcell.Color TextSecondary tcell.Color TextDisabled tcell.Color TextDisabled2 tcell.Color BackgroundSelected tcell.Color TextSelected tcell.Color TextSongPlaying tcell.Color Status ColorStatus Modal ColorModal }
type ColorModal ¶
type ColorNavBar ¶
type ColorNavBar struct {}
func (*ColorNavBar) ToWidgetsNavBar ¶
func (c *ColorNavBar) ToWidgetsNavBar() *twidgets.NavBarColors
type ColorStatus ¶
type Config ¶ added in v0.2.0
type Config struct { Jellyfin Jellyfin `yaml:"jellyfin"` Subsonic Subsonic `yaml:"subsonic"` Player Player `yaml:"player"` Gui Gui `yaml:"gui"` }
var AppConfig *Config
AppConfig is a configuration loaded during startup
type GlobalBindings ¶
type GlobalBindings struct { PlayPause tcell.Key Stop tcell.Key Next tcell.Key Previous tcell.Key Forward tcell.Key Backward tcell.Key VolumeUp tcell.Key VolumeDown tcell.Key MuteUnmute tcell.Key Shuffle tcell.Key }
GlobalBindings can have only one action since they override all others
type Gui ¶ added in v0.8.0
type Gui struct { PageSize int `yaml:"page_size"` DebugMode bool `yaml:"debug_mode"` LimitRecentlyPlayed bool `yaml:"limit_recent_songs"` MouseEnabled bool `yaml:"enable_mouse"` DoubleClickMs int `yaml:"mouse_double_click_interval_ms"` // valid types: artist,album,song,playlist,genre SearchTypes []models.ItemType `yaml:"search_types"` SearchResultsLimit int `yaml:"search_results_limit"` VolumeSteps int `yaml:"volume_steps"` // EnableSorting enables sorting on remote server EnableSorting bool `yaml:"enable_sorting"` // EnableFiltering enables filtering on remote server EnableFiltering bool `yaml:"enable_filtering"` // EnableResultsFiltering enables filtering existing results, 'search inside results'. EnableResultsFiltering bool `yaml:"enable_results_filtering"` }
type Jellyfin ¶ added in v0.8.0
type Jellyfin struct { Url string `yaml:"server_url"` Token string `yaml:"token"` UserId string `yaml:"user_id"` DeviceId string `yaml:"device_id"` ServerId string `yaml:"server_id"` MusicView string `yaml:"music_view"` }
func (*Jellyfin) DumpConfig ¶ added in v0.8.0
func (j *Jellyfin) DumpConfig() interface{}
type KeyBindings ¶
type KeyBindings struct { Global GlobalBindings Moving MovingBindings Panel PanelBindings }
func DefaultKeyBindings ¶
func DefaultKeyBindings() KeyBindings
type KeyValueProvider ¶ added in v0.8.0
type KeyValueProvider interface { // Get returns value for key. Sensitive flags key as hidden. // Key is of format block.value from config file. Label is user-friendly label. Get(key string, sensitive bool, label string) (string, error) }
KeyValueProvider provides means to request new values for outdated values, to request new password or url.
type MovingBindings ¶
type MovingBindings struct { Up tcell.Key Down tcell.Key Left tcell.Key Right tcell.Key UpAlt tcell.Key DownAlt tcell.Key LeftAlt tcell.Key RightAlt tcell.Key }
MovingBindings control moving cursor inside panel
type NavigationBarBindings ¶
type NavigationBarBindings struct {}
NavigationBarBindings also override every other key
type PanelBindings ¶
type PanelBindings struct {
MovingBindings
}
PanelBindings moving between panels
type Player ¶ added in v0.3.0
type Player struct { Server string `yaml:"server"` LogFile string `yaml:"log_file"` LogLevel string `yaml:"log_level"` AudioBufferingMs int `yaml:"audio_buffering_ms"` HttpBufferingS int `yaml:"http_buffering_s"` // memory limit in MiB HttpBufferingLimitMem int `yaml:"http_buffering_limit_mem"` EnableRemoteControl bool `yaml:"enable_remote_control"` EnableLocalCache bool `yaml:"enable_local_cache"` LocalCacheDir string `yaml:"local_cache_dir"` }
type StdinConfigProvider ¶ added in v0.8.0
type StdinConfigProvider struct{}
StdinConfigProvider reads config keys from stdin.
type Subsonic ¶ added in v0.8.0
type Subsonic struct { Url string `yaml:"server_url"` Username string `yaml:"username"` Salt string `yaml:"salt"` Token string `yaml:"token"` }
func (*Subsonic) DumpConfig ¶ added in v0.8.0
func (s *Subsonic) DumpConfig() interface{}
type ViperStdConfigProvider ¶ added in v0.8.0
type ViperStdConfigProvider struct{}
ViperStdConfigProvider reads key first from viper (config file & env) and after that reads from stdin.