refactor(config)!: use $HOME/.config/television by default for macOS (#124)

This commit is contained in:
Alexandre Pasmantier 2024-12-15 12:23:31 +01:00 committed by GitHub
parent 7b114b7cb6
commit a7064c18c8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 14 additions and 4 deletions

View File

@ -3,7 +3,7 @@
# Defaults:
# ---------
# Linux: `$HOME/.config/television/config.toml`
# macOS: `$HOME/Library/Application Support/television/config.toml`
# macOS: `$HOME/.config/television/config.toml`
# Windows: `%APPDATA%\television\config.toml`
#
# XDG dirs:

View File

@ -194,7 +194,7 @@ Default (may be overriden) locations where `television` expect the configuration
|Platform|Value|
|--------|:-----:|
|Linux|`$HOME/.config/television/config.toml`|
|macOS|`$HOME/Library/Application Support/com.television/config.toml`|
|macOS|`$HOME/.config/television/config.toml`|
|Windows|`{FOLDERID_LocalAppData}\television\config`|
Or, if you'd rather use the XDG Base Directory Specification, tv will look for the configuration file in

View File

@ -92,7 +92,7 @@ pub enum ParsedCliChannel {
}
fn channel_parser(channel: &str) -> Result<ParsedCliChannel> {
let cable_channels = cable::load_cable_channels()?;
let cable_channels = cable::load_cable_channels().unwrap_or_default();
CliTvChannel::try_from(channel)
.map(ParsedCliChannel::Builtin)
.or_else(|_| {

View File

@ -139,8 +139,18 @@ pub fn get_data_dir() -> PathBuf {
pub fn get_config_dir() -> PathBuf {
let directory = if let Some(s) = CONFIG_FOLDER.clone() {
debug!("Using config directory: {:?}", s);
debug!("Config directory: {:?}", s);
s
} else if cfg!(unix) {
// default to ~/.config/television for unix systems
if let Some(base_dirs) = directories::BaseDirs::new() {
let cfg_dir =
base_dirs.home_dir().join(".config").join("television");
debug!("Config directory: {:?}", cfg_dir);
cfg_dir
} else {
PathBuf::from("../../../../..").join(".config")
}
} else if let Some(proj_dirs) = project_directory() {
debug!("Falling back to default config dir");
proj_dirs.config_local_dir().to_path_buf()