iced-pywal 0.1.1

Get iced theme from pywal color pallete.
Documentation
use std::io::Read;

fn colr(colors : &[Vec<u8>], id : usize) -> iced::Color{
    iced::Color::from_rgb8(colors[id][0], colors[id][1], colors[id][2])
}
fn pywal_palette(colors : &[Vec<u8>]) -> iced::theme::Palette{
    let mut pallete = iced::Theme::Dark.palette();
    {
        pallete.background = colr(colors, 0);
        pallete.primary = colr(colors, 4);
        pallete.success = colr(colors, 2);
        pallete.danger = colr(colors, 1);
    }
    pallete
}
fn get_pywal_colors() -> Result<Vec<Vec<u8>>, Box<dyn std::error::Error>>{
    let path = std::env::home_dir()
        .unwrap_or_default()
        .to_string_lossy()
        .to_string()
        + "/.cache/wal/colors-rgb";
    let mut colors = std::fs::File::open(&path)?;
    let mut colors_string = "".to_string();
    colors.read_to_string(&mut colors_string)?;
    Ok(colors_string
        .lines()
        .map(|line| {
            line.split(",")
                .map(|l| l.parse::<u8>().unwrap_or(0))
                .collect::<Vec<_>>()
        })
        .collect::<Vec<_>>())
}
pub fn color_cheme() -> Result<iced::Theme, Box<dyn std::error::Error>> {
    let colors = get_pywal_colors()?;
    let palette = pywal_palette(&colors);
    let theme = iced::Theme::custom("pywal".to_string(), palette);
    Ok(theme)
}