Skip to content

Commit

Permalink
improve arg handling
Browse files Browse the repository at this point in the history
  • Loading branch information
JojiiOfficial committed Jan 22, 2021
1 parent 7448dc0 commit 5f41d5c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ license = "GPL-3.0"
authors = ["jojii <jojii@gmx.net>"]
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
Expand Down
9 changes: 9 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,15 @@ use mpris::PlayerFinder;
use pulsectl::controllers::{DeviceControl, SinkController};

fn main() {
if std::env::args().count() < 2 {
println!(
"Usage: {} <device-id>",
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();
Expand Down

0 comments on commit 5f41d5c

Please sign in to comment.