diff --git a/README.md b/README.md index 35e022e..add45e8 100644 --- a/README.md +++ b/README.md @@ -109,10 +109,12 @@ the search view. Configuration is saved to `~/.config/ncspot/config.toml`. Possible configuration values are: -* `proxy`: Set an HTTP proxy * `use_nerdfont`: Turn nerdfont glyphs on/off * `theme`: Set a custom color palette (see below) +ncspot will respect system proxy settings defined via the `http_proxy` +environment variable. + ### Theming The color palette can be modified in the configuration. For instance, to have diff --git a/src/config.rs b/src/config.rs index 8dbbeaa..b26f511 100644 --- a/src/config.rs +++ b/src/config.rs @@ -13,7 +13,6 @@ pub struct Config { pub keybindings: Option>, pub theme: Option, pub use_nerdfont: Option, - pub proxy: Option, } #[derive(Serialize, Deserialize, Debug, Default, Clone)] diff --git a/src/spotify.rs b/src/spotify.rs index b86911c..9a0ad6b 100644 --- a/src/spotify.rs +++ b/src/spotify.rs @@ -37,6 +37,7 @@ use tokio_core::reactor::Core; use tokio_timer; use url::Url; +use std::env; use std::sync::atomic::{AtomicU16, Ordering}; use std::sync::RwLock; use std::thread; @@ -246,8 +247,12 @@ impl Spotify { pub fn session_config(cfg: &Config) -> SessionConfig { let mut session_config = SessionConfig::default(); - if let Some(ref proxy) = cfg.proxy { - session_config.proxy = Url::parse(&proxy).ok(); + match env::var("http_proxy") { + Ok(proxy) => { + info!("Setting HTTP proxy {}", proxy); + session_config.proxy = Url::parse(&proxy).ok(); + } + Err(_) => debug!("No HTTP proxy set"), } session_config }