Skip to content

Commit

Permalink
improv: filter firefox player
Browse files Browse the repository at this point in the history
  • Loading branch information
wiiznokes authored and mmstick committed Sep 12, 2024
1 parent c8d91a8 commit 6b8d3dc
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions cosmic-applet-audio/src/mpris_subscription.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,15 @@ struct State {
any_player_state_stream: futures::stream::SelectAll<zbus::PropertyStream<'static, String>>,
}

fn filter_firefox_players(players: &mut Vec<MprisPlayer>) {
if players
.iter()
.any(|e| e.name() == "org.mpris.MediaPlayer2.plasma-browser-integration")
{
players.retain(|e| !e.name().starts_with("org.mpris.MediaPlayer2.firefox."));
}
}

impl State {
async fn new() -> Result<Self, zbus::Error> {
let conn = Connection::session().await?;
Expand All @@ -154,6 +163,7 @@ impl State {
}
}
}
filter_firefox_players(&mut players);

// pre-sort by path so that the same player is always selected
players.sort_by(|a, b| a.name().cmp(&b.name()));
Expand All @@ -180,6 +190,7 @@ impl State {
}
};
self.players.push(player);
filter_firefox_players(&mut self.players);
self.players.sort_by(|a, b| a.name().cmp(&b.name()));
self.update_any_player_state_stream().await;
}
Expand Down

0 comments on commit 6b8d3dc

Please sign in to comment.