use environment variable for MPD_PORT and MPD_HOST
This commit is contained in:
parent
59eed99c85
commit
255687be7c
|
|
@ -177,14 +177,10 @@ pub fn handle_key_events(key_event: KeyEvent, app: &mut App) -> AppResult<()> {
|
||||||
|
|
||||||
// Playback controls
|
// Playback controls
|
||||||
// Toggle Pause
|
// Toggle Pause
|
||||||
KeyCode::Char('p') => {
|
KeyCode::Char('p') => app.conn.toggle_pause(),
|
||||||
app.conn.toggle_pause();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Pause
|
// Pause
|
||||||
KeyCode::Char('s') => {
|
KeyCode::Char('s') => app.conn.pause(),
|
||||||
app.conn.pause();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Toggle rpeat
|
// Toggle rpeat
|
||||||
KeyCode::Char('r') => {
|
KeyCode::Char('r') => {
|
||||||
|
|
@ -199,41 +195,10 @@ pub fn handle_key_events(key_event: KeyEvent, app: &mut App) -> AppResult<()> {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Dmenu prompt
|
// Dmenu prompt
|
||||||
KeyCode::Char('D') => {
|
KeyCode::Char('D') => app.conn.play_dmenu()?,
|
||||||
app.conn.play_dmenu()?;
|
|
||||||
}
|
|
||||||
|
|
||||||
// add to queue
|
// add to queue
|
||||||
KeyCode::Char('a') => {
|
KeyCode::Char('a') => app.playlist_popup = true,
|
||||||
// let list = app
|
|
||||||
// .conn
|
|
||||||
// .songs_filenames
|
|
||||||
// .iter()
|
|
||||||
// .map(|f| f.as_str())
|
|
||||||
// .collect::<Vec<&str>>();
|
|
||||||
//
|
|
||||||
// let files: Vec<String> = app
|
|
||||||
// .browser
|
|
||||||
// .filetree
|
|
||||||
// .clone()
|
|
||||||
// .into_iter()
|
|
||||||
// .map(|(_, f)| f)
|
|
||||||
// .collect();
|
|
||||||
//
|
|
||||||
// let (filename, _) = rust_fuzzy_search::fuzzy_search_sorted(
|
|
||||||
// &files.get(app.browser.selected).unwrap(),
|
|
||||||
// &list,
|
|
||||||
// )
|
|
||||||
// .get(0)
|
|
||||||
// .unwrap()
|
|
||||||
// .clone();
|
|
||||||
//
|
|
||||||
// let song = app.conn.get_song_with_only_filename(filename);
|
|
||||||
//
|
|
||||||
// app.conn.conn.push(&song)?;
|
|
||||||
|
|
||||||
app.playlist_popup = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
KeyCode::Right => {
|
KeyCode::Right => {
|
||||||
app.conn
|
app.conn
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@ use rmptui::event::EventHandler;
|
||||||
use rmptui::handler;
|
use rmptui::handler;
|
||||||
use rmptui::song::RSong;
|
use rmptui::song::RSong;
|
||||||
use rmptui::tui;
|
use rmptui::tui;
|
||||||
|
use std::env;
|
||||||
use std::io;
|
use std::io;
|
||||||
|
|
||||||
use crossterm::event::{self, KeyCode, KeyEvent, KeyEventKind};
|
use crossterm::event::{self, KeyCode, KeyEvent, KeyEventKind};
|
||||||
|
|
@ -25,7 +26,9 @@ pub type Error = Box<dyn std::error::Error>;
|
||||||
|
|
||||||
fn main() -> AppResult<()> {
|
fn main() -> AppResult<()> {
|
||||||
let args = Args::parse();
|
let args = Args::parse();
|
||||||
let mut app = App::builder("127.0.0.1:6600")?;
|
let env_host = env::var("MPD_HOST").unwrap_or_else(|_| "127.0.0.1".to_string());
|
||||||
|
let env_port = env::var("MPD_PORT").unwrap_or_else(|_| "6600".to_string());
|
||||||
|
let mut app = App::builder(format!("{}:{}", env_host, env_port).as_str())?;
|
||||||
|
|
||||||
if !args.tui {
|
if !args.tui {
|
||||||
handle_tui(&mut app)?;
|
handle_tui(&mut app)?;
|
||||||
|
|
|
||||||
Reference in New Issue