Documentation ¶
Overview ¶
Package config provides configuration management for the Immich Kiosk application.
It includes structures and methods for loading, parsing, and managing configuration settings from various sources including YAML files, environment variables, and URL query parameters.
The package offers functionality to: - Define default configuration values - Load configuration from files and environment variables - Override configuration with URL query parameters - Validate and process configuration settings
Key types: - Config: The main configuration structure - KioskSettings: Settings specific to kiosk mode
Key functions: - New: Creates a new Config instance with default values - Load: Loads configuration from a file and environment variables - ConfigWithOverrides: Applies overrides from URL queries to the configuration
Index ¶
Constants ¶
const (
DefaultDateLayout = "02/01/2006"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { // V is the viper instance used for configuration management V *viper.Viper // ReloadTimeStamp timestamp for when the last client reload was called for ReloadTimeStamp string // ImmichApiKey Immich key to access assets ImmichApiKey string `mapstructure:"immich_api_key" default:""` // ImmichUrl Immuch base url ImmichUrl string `mapstructure:"immich_url" default:""` // DisableUi a shortcut to disable ShowTime, ShowDate, ShowImageTime and ShowImageDate DisableUi bool `mapstructure:"disable_ui" query:"disable_ui" form:"disable_ui" default:"false"` // Frameless remove border on frames Frameless bool `mapstructure:"frameless" query:"frameless" form:"frameless" default:"false"` // ShowTime whether to display clock ShowTime bool `mapstructure:"show_time" query:"show_time" form:"show_time" default:"false"` // TimeFormat whether to use 12 of 24 hour format for clock TimeFormat string `mapstructure:"time_format" query:"time_format" form:"time_format" default:""` // ShowDate whether to display date ShowDate bool `mapstructure:"show_date" query:"show_date" form:"show_date" default:"false"` // DateFormat format for date DateFormat string `mapstructure:"date_format" query:"date_format" form:"date_format" default:""` // Refresh time between fetching new image Refresh int `mapstructure:"refresh" query:"refresh" form:"refresh" default:"60"` // DisableScreensaver asks browser to disable screensaver DisableScreensaver bool `mapstructure:"disable_screensaver" query:"disable_screensaver" form:"disable_screensaver" default:"false"` // HideCursor hide cursor via CSS HideCursor bool `mapstructure:"hide_cursor" query:"hide_cursor" form:"hide_cursor" default:"false"` // FontSize the base font size as a percentage FontSize int `mapstructure:"font_size" query:"font_size" form:"font_size" default:"100"` // Theme which theme to use Theme string `mapstructure:"theme" query:"theme" form:"theme" default:"fade" lowercase:"true"` // Layout which layout to use Layout string `mapstructure:"layout" query:"layout" form:"layout" default:"single" lowercase:"true"` // SleepStart when to start sleep mode SleepStart string `mapstructure:"sleep_start" query:"sleep_start" form:"sleep_start" default:""` // SleepEnd when to exit sleep mode SleepEnd string `mapstructure:"sleep_end" query:"sleep_end" form:"sleep_end" default:""` // ShowArchived allow archived image to be displayed ShowArchived bool `mapstructure:"show_archived" query:"show_archived" form:"show_archived" default:"false"` // Person ID of person to display Person []string `mapstructure:"person" query:"person" form:"person" default:"[]"` // Album ID of album(s) to display Album []string `mapstructure:"album" query:"album" form:"album" default:"[]"` // ImageFit the fit style for main image ImageFit string `mapstructure:"image_fit" query:"image_fit" form:"image_fit" default:"contain" lowercase:"true"` // ImageEffect which effect to apply to image (if any) ImageEffect string `mapstructure:"image_effect" query:"image_effect" form:"image_effect" default:"" lowercase:"true"` // ImageEffectAmount the amount of effect to apply ImageEffectAmount int `mapstructure:"image_effect_amount" query:"image_effect_amount" form:"image_effect_amount" default:"120"` // UseOriginalImage use the original image UseOriginalImage bool `mapstructure:"use_original_image" query:"use_original_image" form:"use_original_image" default:"false"` // BackgroundBlur whether to display blurred image as background BackgroundBlur bool `mapstructure:"background_blur" query:"background_blur" form:"background_blur" default:"true"` // BackgroundBlur which transition to use none|fade|cross-fade Transition string `mapstructure:"transition" query:"transition" form:"transition" default:"" lowercase:"true"` // FadeTransitionDuration sets the length of the fade transition FadeTransitionDuration float32 `mapstructure:"fade_transition_duration" query:"fade_transition_duration" form:"fade_transition_duration" default:"1"` // CrossFadeTransitionDuration sets the length of the cross-fade transition CrossFadeTransitionDuration float32 `` /* 134-byte string literal not displayed */ // ShowProgress display a progress bar ShowProgress bool `mapstructure:"show_progress" query:"show_progress" form:"show_progress" default:"false"` // CustomCSS use custom css file CustomCSS bool `mapstructure:"custom_css" query:"custom_css" form:"custom_css" default:"true"` // ShowImageTime whether to display image time ShowImageTime bool `mapstructure:"show_image_time" query:"show_image_time" form:"show_image_time" default:"false"` // ImageTimeFormat whether to use 12 of 24 hour format ImageTimeFormat string `mapstructure:"image_time_format" query:"image_time_format" form:"image_time_format" default:""` // ShowImageDate whether to display image date ShowImageDate bool `mapstructure:"show_image_date" query:"show_image_date" form:"show_image_date" default:"false"` // ImageDateFormat format for image date ImageDateFormat string `mapstructure:"image_date_format" query:"image_date_format" form:"image_date_format" default:""` // ShowImageDescription isplay image description ShowImageDescription bool `mapstructure:"show_image_description" query:"show_image_description" form:"show_image_description" default:"false"` // ShowImageExif display image exif data (f number, iso, shutter speed, Focal length) ShowImageExif bool `mapstructure:"show_image_exif" query:"show_image_exif" form:"show_image_exif" default:"false"` // ShowImageLocation display image location data ShowImageLocation bool `mapstructure:"show_image_location" query:"show_image_location" form:"show_image_location" default:"false"` // HideCountries hide country names in location information HideCountries []string `mapstructure:"hide_countries" query:"hide_countries" form:"hide_countries" default:"[]"` // ShowImageID display image ID ShowImageID bool `mapstructure:"show_image_id" query:"show_image_id" form:"show_image_id" default:"false"` WeatherLocations []WeatherLocation `mapstructure:"weather" default:"[]"` // Kiosk settings that are unable to be changed via URL queries Kiosk KioskSettings `mapstructure:"kiosk"` // History past shown images History []string `form:"history" default:"[]"` // contains filtered or unexported fields }
Config represents the main configuration structure for the Immich Kiosk application. It contains all the settings that control the behavior and appearance of the kiosk, including connection details, display options, image settings, and various feature toggles.
The structure supports configuration through YAML files, environment variables, and URL query parameters. Many fields can be dynamically updated through URL queries during runtime.
Tags used in the configuration structure: ¶
- mapstructure: field name from yaml file
- query: enables URL query parameter binding
- form: enables form parameter binding
- default: sets default value
- lowercase: converts string value to lowercase
func (*Config) ConfigWithOverrides ¶
ConfigWithOverrides overwrites base config with ones supplied via URL queries
func (*Config) Load ¶
load loads yaml config file into memory, then loads ENV vars. ENV vars overwrites yaml settings.
func (*Config) String ¶ added in v0.7.0
String returns a string representation of the Config structure. If debug_verbose is not enabled, it returns a message prompting to enable it. Otherwise, it returns a JSON-formatted string of the entire Config structure.
This method is useful for debugging and logging purposes, providing a detailed view of the current configuration when verbose debugging is enabled.
Returns:
- A string containing either a prompt to enable debug_verbose or the JSON representation of the Config structure.
func (*Config) WatchConfig ¶ added in v0.11.2
func (c *Config) WatchConfig()
WatchConfig sets up a configuration file watcher that monitors for changes and reloads the configuration when necessary.
type KioskSettings ¶ added in v0.5.0
type KioskSettings struct { // Port which port to use Port int `mapstructure:"port" default:"3000"` // WatchConfig if kiosk should watch config file for changes WatchConfig bool `mapstructure:"watch_config" default:"false"` // FetchedAssetsSize the size of assets requests from Immich. min=1 max=1000 FetchedAssetsSize int `mapstructure:"fetched_assets_size" default:"1000"` // HTTPTimeout time in seconds before an http request will timeout HTTPTimeout int `mapstructure:"http_timeout" default:"20"` // Cache enable/disable api call and image caching Cache bool `mapstructure:"cache" default:"true"` // PreFetch fetch and cache an image in the background PreFetch bool `mapstructure:"prefetch" default:"true"` // Password the password used to add authentication to the frontend Password string `mapstructure:"password" default:""` // AssetWeighting use weighting when picking assets AssetWeighting bool `mapstructure:"asset_weighting" default:"true"` // debug modes Debug bool `mapstructure:"debug" default:"false"` DebugVerbose bool `mapstructure:"debug_verbose" default:"false"` }