rmptui255687b
use environment variable for MPD_PORT and MPD_HOST
+8 −40
2 files changed
- M src/handler.rs +4 −39
- M src/main.rs +4 −1
| @@ -177,14 +177,10 @@ pub fn handle_key_events(key_event: KeyEvent, app: &mut App) -> AppResult<()> { | |||
| 177 | 177 | ||
| 178 | 178 | // Playback controls | |
| 179 | 179 | // Toggle Pause | |
| 180 | − | KeyCode::Char('p') => { | |
| 181 | − | app.conn.toggle_pause(); | |
| 182 | − | } | |
| 180 | + | KeyCode::Char('p') => app.conn.toggle_pause(), | |
| 183 | 181 | ||
| 184 | 182 | // Pause | |
| 185 | − | KeyCode::Char('s') => { | |
| 186 | − | app.conn.pause(); | |
| 187 | − | } | |
| 183 | + | KeyCode::Char('s') => app.conn.pause(), | |
| 188 | 184 | ||
| 189 | 185 | // Toggle rpeat | |
| 190 | 186 | KeyCode::Char('r') => { | |
| @@ -199,41 +195,10 @@ pub fn handle_key_events(key_event: KeyEvent, app: &mut App) -> AppResult<()> { | |||
| 199 | 195 | } | |
| 200 | 196 | ||
| 201 | 197 | // Dmenu prompt | |
| 202 | − | KeyCode::Char('D') => { | |
| 203 | − | app.conn.play_dmenu()?; | |
| 204 | − | } | |
| 198 | + | KeyCode::Char('D') => app.conn.play_dmenu()?, | |
| 205 | 199 | ||
| 206 | 200 | // add to queue | |
| 207 | − | KeyCode::Char('a') => { | |
| 208 | − | // let list = app | |
| 209 | − | // .conn | |
| 210 | − | // .songs_filenames | |
| 211 | − | // .iter() | |
| 212 | − | // .map(|f| f.as_str()) | |
| 213 | − | // .collect::<Vec<&str>>(); | |
| 214 | − | // | |
| 215 | − | // let files: Vec<String> = app | |
| 216 | − | // .browser | |
| 217 | − | // .filetree | |
| 218 | − | // .clone() | |
| 219 | − | // .into_iter() | |
| 220 | − | // .map(|(_, f)| f) | |
| 221 | − | // .collect(); | |
| 222 | − | // | |
| 223 | − | // let (filename, _) = rust_fuzzy_search::fuzzy_search_sorted( | |
| 224 | − | // &files.get(app.browser.selected).unwrap(), | |
| 225 | − | // &list, | |
| 226 | − | // ) | |
| 227 | − | // .get(0) | |
| 228 | − | // .unwrap() | |
| 229 | − | // .clone(); | |
| 230 | − | // | |
| 231 | − | // let song = app.conn.get_song_with_only_filename(filename); | |
| 232 | − | // | |
| 233 | − | // app.conn.conn.push(&song)?; | |
| 234 | − | ||
| 235 | − | app.playlist_popup = true; | |
| 236 | − | } | |
| 201 | + | KeyCode::Char('a') => app.playlist_popup = true, | |
| 237 | 202 | ||
| 238 | 203 | KeyCode::Right => { | |
| 239 | 204 | app.conn | |
| @@ -11,6 +11,7 @@ use rmptui::event::EventHandler; | |||
| 11 | 11 | use rmptui::handler; | |
| 12 | 12 | use rmptui::song::RSong; | |
| 13 | 13 | use rmptui::tui; | |
| 14 | + | use std::env; | |
| 14 | 15 | use std::io; | |
| 15 | 16 | ||
| 16 | 17 | use crossterm::event::{self, KeyCode, KeyEvent, KeyEventKind}; | |
| @@ -25,7 +26,9 @@ pub type Error = Box<dyn std::error::Error>; | |||
| 25 | 26 | ||
| 26 | 27 | fn main() -> AppResult<()> { | |
| 27 | 28 | let args = Args::parse(); | |
| 28 | − | let mut app = App::builder("127.0.0.1:6600")?; | |
| 29 | + | let env_host = env::var("MPD_HOST").unwrap_or_else(|_| "127.0.0.1".to_string()); | |
| 30 | + | let env_port = env::var("MPD_PORT").unwrap_or_else(|_| "6600".to_string()); | |
| 31 | + | let mut app = App::builder(format!("{}:{}", env_host, env_port).as_str())?; | |
| 29 | 32 | ||
| 30 | 33 | if !args.tui { | |
| 31 | 34 | handle_tui(&mut app)?; | |