aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkrolxon <krolyxon@tutanota.com>2024-04-27 11:38:59 +0530
committerkrolxon <krolyxon@tutanota.com>2024-04-27 11:38:59 +0530
commit255687be7cb6e6314f2c6f56c098d5113c1c091a (patch)
tree117d844d91114b68f59ddc0dbeeefd7e58649b4c
parent59eed99c85957c193dba53e7311f960a6b8e916c (diff)
use environment variable for MPD_PORT and MPD_HOST
-rwxr-xr-xsrc/handler.rs43
-rwxr-xr-xsrc/main.rs5
2 files changed, 8 insertions, 40 deletions
diff --git a/src/handler.rs b/src/handler.rs
index c74a3a8..c3b001e 100755
--- a/src/handler.rs
+++ b/src/handler.rs
@@ -177,14 +177,10 @@ pub fn handle_key_events(key_event: KeyEvent, app: &mut App) -> AppResult<()> {
// Playback controls
// Toggle Pause
- KeyCode::Char('p') => {
- app.conn.toggle_pause();
- }
+ KeyCode::Char('p') => app.conn.toggle_pause(),
// Pause
- KeyCode::Char('s') => {
- app.conn.pause();
- }
+ KeyCode::Char('s') => app.conn.pause(),
// Toggle rpeat
KeyCode::Char('r') => {
@@ -199,41 +195,10 @@ pub fn handle_key_events(key_event: KeyEvent, app: &mut App) -> AppResult<()> {
}
// Dmenu prompt
- KeyCode::Char('D') => {
- app.conn.play_dmenu()?;
- }
+ KeyCode::Char('D') => app.conn.play_dmenu()?,
// add to queue
- KeyCode::Char('a') => {
- // 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::Char('a') => app.playlist_popup = true,
KeyCode::Right => {
app.conn
diff --git a/src/main.rs b/src/main.rs
index 1a13a1a..9984c06 100755
--- a/src/main.rs
+++ b/src/main.rs
@@ -11,6 +11,7 @@ use rmptui::event::EventHandler;
use rmptui::handler;
use rmptui::song::RSong;
use rmptui::tui;
+use std::env;
use std::io;
use crossterm::event::{self, KeyCode, KeyEvent, KeyEventKind};
@@ -25,7 +26,9 @@ pub type Error = Box<dyn std::error::Error>;
fn main() -> AppResult<()> {
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 {
handle_tui(&mut app)?;