From 5f41d5cc91de126391fd7aaddbef97f622a451ac Mon Sep 17 00:00:00 2001 From: jojii Date: Fri, 22 Jan 2021 11:44:00 +0100 Subject: [PATCH] improve arg handling --- Cargo.toml | 1 + src/main.rs | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/Cargo.toml b/Cargo.toml index a889167..6f9b03d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,6 +5,7 @@ license = "GPL-3.0" authors = ["jojii "] repository = "https://github.com/JojiiOfficial/MediaD" description = "A Simple and lightweight daemon to handle keyboard media buttons easily" +readme = "README.md" edition = "2018" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/src/main.rs b/src/main.rs index 4a99365..a66809e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -4,6 +4,15 @@ use mpris::PlayerFinder; use pulsectl::controllers::{DeviceControl, SinkController}; fn main() { + if std::env::args().count() < 2 { + println!( + "Usage: {} ", + std::env::args().nth(0).unwrap_or("mediad".to_owned()) + ); + + return; + } + let device_path = std::env::args().nth(1).unwrap().to_owned(); let mut device = evdev::Device::open(&Path::new("/dev/input/by-id").join(&device_path)).unwrap();