Warn when no active mpris player is found
previously would panic
This commit is contained in:
parent
2f325db170
commit
a4e63ae51a
1 changed files with 10 additions and 4 deletions
|
@ -1,3 +1,4 @@
|
|||
use log::warn;
|
||||
use mpris::Player;
|
||||
use mpris::PlayerFinder;
|
||||
use regex::Regex;
|
||||
|
@ -36,10 +37,15 @@ where
|
|||
{
|
||||
let player = PlayerFinder::new()
|
||||
.expect("Could not connect to D-Bus")
|
||||
.find_active()
|
||||
.expect("Could not find any player");
|
||||
|
||||
function(&player);
|
||||
.find_active();
|
||||
match player {
|
||||
Ok(p) => {
|
||||
function(&p);
|
||||
}
|
||||
Err(err) => {
|
||||
warn!("Could not find an active player: {err}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn exec_functionality<F>(player_id: Option<&str>, exec_closure: F)
|
||||
|
|
Loading…
Reference in a new issue