config

package
v0.9.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 28, 2021 License: GPL-3.0 Imports: 13 Imported by: 0

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

View Source
const (
	TextSecondary = tcell.Color179
	TextDisabled  = tcell.Color241
	TextDisabled2 = tcell.Color247
)
View Source
const (
	AppName      = "Jellycli"
	AppNameLower = "jellycli"
	Version      = "0.9.1"
)
View Source
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

View Source
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
)
View Source
var Color = defaultColors()
View Source
var ConfigFile string

ConfigFile is absolute location for configuration file

View Source
var (
	KeyBinds = DefaultKeyBindings()
)
View Source
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

func NewConfigFile(location string) error

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

func ReadUserInput(name string, mask bool) (string, error)

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
	NavBar                   ColorNavBar
	Status                   ColorStatus
	Modal                    ColorModal
}

type Backend added in v0.8.0

type Backend interface {
	DumpConfig() interface{}
	GetType() string
}

type ColorModal

type ColorModal struct {
	Background tcell.Color
	Text       tcell.Color
	Headers    tcell.Color
}

type ColorNavBar

type ColorNavBar struct {
	Background       tcell.Color
	Text             tcell.Color
	ButtonBackground tcell.Color
	Shortcut         tcell.Color
}

func (*ColorNavBar) ToWidgetsNavBar

func (c *ColorNavBar) ToWidgetsNavBar() *twidgets.NavBarColors

type ColorStatus

type ColorStatus struct {
	Background       tcell.Color
	Border           tcell.Color
	ProgressBar      tcell.Color
	Text             tcell.Color
	ButtonBackground tcell.Color
	ButtonLabel      tcell.Color
	Shortcuts        tcell.Color
	TextPrimary      tcell.Color
	TextSecondary    tcell.Color
	VolumeMuted      tcell.Color
}

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{}

func (*Jellyfin) GetType added in v0.8.0

func (j *Jellyfin) GetType() string

type KeyBindings

type KeyBindings struct {
	Global        GlobalBindings
	NavigationBar NavigationBarBindings
	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 struct {
	Quit     tcell.Key
	Help     tcell.Key
	View     tcell.Key
	Search   tcell.Key
	Queue    tcell.Key
	History  tcell.Key
	Settings tcell.Key
	Dump     tcell.Key
}

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.

func (*StdinConfigProvider) Get added in v0.8.0

func (s *StdinConfigProvider) Get(key string, sensitive bool, label string) (string, error)

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{}

func (*Subsonic) GetType added in v0.8.0

func (s *Subsonic) GetType() string

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.

func (*ViperStdConfigProvider) Get added in v0.8.0

func (s *ViperStdConfigProvider) Get(key string, sensitive bool, label string) (string, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL