i3status_rs/blocks/packages/
xbps.rs

1use tokio::process::Command;
2
3use super::*;
4
5#[derive(Default)]
6pub struct Xbps;
7
8impl Xbps {
9    pub fn new() -> Self {
10        Default::default()
11    }
12}
13
14#[async_trait]
15impl Backend for Xbps {
16    fn name(&self) -> Cow<'static, str> {
17        "xbps".into()
18    }
19
20    async fn get_updates_list(&self) -> Result<Vec<String>> {
21        let stdout = Command::new("xbps-install")
22            .env("LC_LANG", "C")
23            .args(["-M", "-u", "-n"])
24            .output()
25            .await
26            .error("Problem running xbps-install command")?
27            .stdout;
28
29        let updates = String::from_utf8(stdout).expect("xbps-install produced non-UTF8 output");
30        let updates_list: Vec<String> = updates
31            .lines()
32            .filter(|line| line.len() > 1)
33            .map(|line| line.to_string())
34            .collect();
35
36        Ok(updates_list)
37    }
38}