mirror of
https://github.com/alexpasmantier/television.git
synced 2025-06-07 12:05:34 +00:00
refactor(config)!: use $HOME/.config/television
by default for macOS (#124)
This commit is contained in:
parent
7b114b7cb6
commit
a7064c18c8
@ -3,7 +3,7 @@
|
|||||||
# Defaults:
|
# Defaults:
|
||||||
# ---------
|
# ---------
|
||||||
# Linux: `$HOME/.config/television/config.toml`
|
# 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`
|
# Windows: `%APPDATA%\television\config.toml`
|
||||||
#
|
#
|
||||||
# XDG dirs:
|
# XDG dirs:
|
||||||
|
@ -194,7 +194,7 @@ Default (may be overriden) locations where `television` expect the configuration
|
|||||||
|Platform|Value|
|
|Platform|Value|
|
||||||
|--------|:-----:|
|
|--------|:-----:|
|
||||||
|Linux|`$HOME/.config/television/config.toml`|
|
|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`|
|
|Windows|`{FOLDERID_LocalAppData}\television\config`|
|
||||||
|
|
||||||
Or, if you'd rather use the XDG Base Directory Specification, tv will look for the configuration file in
|
Or, if you'd rather use the XDG Base Directory Specification, tv will look for the configuration file in
|
||||||
|
@ -92,7 +92,7 @@ pub enum ParsedCliChannel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn channel_parser(channel: &str) -> Result<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)
|
CliTvChannel::try_from(channel)
|
||||||
.map(ParsedCliChannel::Builtin)
|
.map(ParsedCliChannel::Builtin)
|
||||||
.or_else(|_| {
|
.or_else(|_| {
|
||||||
|
@ -139,8 +139,18 @@ pub fn get_data_dir() -> PathBuf {
|
|||||||
|
|
||||||
pub fn get_config_dir() -> PathBuf {
|
pub fn get_config_dir() -> PathBuf {
|
||||||
let directory = if let Some(s) = CONFIG_FOLDER.clone() {
|
let directory = if let Some(s) = CONFIG_FOLDER.clone() {
|
||||||
debug!("Using config directory: {:?}", s);
|
debug!("Config directory: {:?}", s);
|
||||||
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() {
|
} else if let Some(proj_dirs) = project_directory() {
|
||||||
debug!("Falling back to default config dir");
|
debug!("Falling back to default config dir");
|
||||||
proj_dirs.config_local_dir().to_path_buf()
|
proj_dirs.config_local_dir().to_path_buf()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user