~jshsj/subl_i3

ref: 5272bd1e3a31da6c4b9406928b920a270889c1da subl_i3/src/main.rs -rw-r--r-- 1.6 KiB
5272bd1eJoshua initial commit 1 year, 9 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
use std::fs;
use std::io::Write;

const COLORS_PATH: &str = "/home/josh/.cache/wal/colors";

fn main() {
    load_colors();
}


fn load_colors() {
	let colors_string = fs::read_to_string(COLORS_PATH).expect("Colors file doesn't exist.");
	let mut colors: Vec<&str> = colors_string.split("\n").collect();
	colors.remove(colors.len() - 1);

	let mut theme_template_string = fs::read_to_string("template/Mariana.sublime-color-scheme").expect("Theme couldn't load");
	theme_template_string = theme_template_string.replace("{background}", colors[0]);
	theme_template_string = theme_template_string.replace("{foreground}", colors[8]);
	theme_template_string = theme_template_string.replace("{color0}", colors[0]);
	theme_template_string = theme_template_string.replace("{color1}", colors[1]);
	theme_template_string = theme_template_string.replace("{color2}", colors[2]);
	theme_template_string = theme_template_string.replace("{color3}", colors[3]);
	theme_template_string = theme_template_string.replace("{color4}", colors[4]);
	theme_template_string = theme_template_string.replace("{color5}", colors[5]);
	theme_template_string = theme_template_string.replace("{color6}", colors[6]);
	theme_template_string = theme_template_string.replace("{color7}", colors[7]);
	theme_template_string = theme_template_string.replace("{color8}", colors[8]);
	theme_template_string = theme_template_string.replace("{color9}", colors[9]);


	let mut output_file = fs::File::create("output/Mariana.sublime-color-scheme").expect("Couldn't create file");
	output_file.write_all(&theme_template_string.as_bytes()).expect("Couldn't write file");

}