Merge branch 'main' of https://github.com/djairoh/polybar-mpris-playing
Yeah basically i fucked up by not pushing these earlier; whoops
This commit is contained in:
commit
9874686595
|
|
@ -83,6 +83,14 @@ impl Config {
|
||||||
pub fn priorities_to_lower(&mut self) {
|
pub fn priorities_to_lower(&mut self) {
|
||||||
self.player_priorities = self.player_priorities.iter().map(|i| i.to_lowercase()).collect();
|
self.player_priorities = self.player_priorities.iter().map(|i| i.to_lowercase()).collect();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn find_player_priorities_idx(&self, name: &str) -> i32 {
|
||||||
|
match self.player_priorities.iter()
|
||||||
|
.position(|x| x.to_ascii_lowercase().eq(&name.to_ascii_lowercase())) {
|
||||||
|
Some(idx) => idx as i32,
|
||||||
|
None => i32::MAX,
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn ms(str: &str) -> String {
|
fn ms(str: &str) -> String {
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ fn update_prefix(cfg: &Config, data: &mut Data) {
|
||||||
data.display_prefix = char.clone();
|
data.display_prefix = char.clone();
|
||||||
trace!("updated prefix to {}", data.display_prefix);
|
trace!("updated prefix to {}", data.display_prefix);
|
||||||
} else {
|
} else {
|
||||||
data.display_prefix = cfg.player_prefixes.get("default").unwrap().clone(); //todo: error handling
|
data.display_prefix = cfg.player_prefixes.get("default").unwrap_or(&'>').clone();
|
||||||
trace!("set prefix to default ({})", data.display_prefix);
|
trace!("set prefix to default ({})", data.display_prefix);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ pub fn update_players(
|
||||||
cfg: &Config,
|
cfg: &Config,
|
||||||
mut data: &mut Data,
|
mut data: &mut Data,
|
||||||
) {
|
) {
|
||||||
let players = pf.find_all().unwrap(); //todo: error handling
|
let players = pf.find_all().unwrap_or(Vec::new());
|
||||||
if players.is_empty() {
|
if players.is_empty() {
|
||||||
data.current_player = None;
|
data.current_player = None;
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -14,13 +14,14 @@ pub fn update_players(
|
||||||
for player in players {
|
for player in players {
|
||||||
if cfg.player_priorities.contains(&player.identity().to_owned().to_ascii_lowercase()) {
|
if cfg.player_priorities.contains(&player.identity().to_owned().to_ascii_lowercase()) {
|
||||||
let name = player.identity();
|
let name = player.identity();
|
||||||
let idx = cfg.player_priorities.iter().position(|x| x.to_ascii_lowercase().eq(&name.to_ascii_lowercase())).unwrap() as i32; //todo: move to function in config; error handling
|
let idx = cfg.find_player_priorities_idx(name);
|
||||||
let status = player.get_playback_status().unwrap(); //todo: error handling
|
if let Ok(status) = player.get_playback_status() {
|
||||||
match status {
|
match status {
|
||||||
mpris::PlaybackStatus::Playing => active[0].push((idx, name.to_owned())),
|
mpris::PlaybackStatus::Playing => active[0].push((idx, name.to_owned())),
|
||||||
mpris::PlaybackStatus::Paused => active[1].push((idx, name.to_owned())),
|
mpris::PlaybackStatus::Paused => active[1].push((idx, name.to_owned())),
|
||||||
mpris::PlaybackStatus::Stopped => active[2].push((idx, name.to_owned())),
|
mpris::PlaybackStatus::Stopped => active[2].push((idx, name.to_owned())),
|
||||||
};
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if !active[0].is_empty() {
|
if !active[0].is_empty() {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue