forked from InfoshockTech/xcrab
setting up for greatness (almost not partially)
This commit is contained in:
parent
fd132ccaba
commit
3f989278c7
14
Cargo.lock
generated
14
Cargo.lock
generated
|
@ -374,6 +374,20 @@ name = "serde"
|
|||
version = "1.0.137"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "61ea8d54c77f8315140a05f4c7237403bf38b72704d031543aa1d16abbf517d1"
|
||||
dependencies = [
|
||||
"serde_derive",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde_derive"
|
||||
version = "1.0.137"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1f26faba0c3959972377d3b2d306ee9f71faee9714294e41bb777f83f88578be"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "signal-hook-registry"
|
||||
|
|
|
@ -7,4 +7,4 @@ edition = "2021"
|
|||
breadx = { version = "2.0.0", features = ["async"] }
|
||||
tokio = { version = "1.19.2", features = ["full"] }
|
||||
toml = "0.5.9"
|
||||
serde = "1.0.137"
|
||||
serde = { version = "1.0.137", features = ["derive"]}
|
||||
|
|
|
@ -1,26 +1,39 @@
|
|||
use serde::{Serialize, Deserialize};
|
||||
use std::fs::{read,File};
|
||||
use serde::{Deserialize,Serialize};
|
||||
use std::fs;
|
||||
use std::path::Path;
|
||||
use toml::de::from_slice
|
||||
use toml::de::from_slice;
|
||||
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
pub struct XcrabConfig {
|
||||
border-color: String,
|
||||
border-size: i32,
|
||||
gap-width: i32,
|
||||
border_color: String,
|
||||
border_size: i32,
|
||||
gap_width: i32,
|
||||
}
|
||||
|
||||
|
||||
impl XcrabConfig{
|
||||
pub fn load_config () -> {
|
||||
pub fn load_config() -> XcrabConfig{
|
||||
if Path::new("~/.config/xcrab").is_dir(){
|
||||
if Path::new("~/.config/xcrab/config.toml").is_file(){
|
||||
let mut config_slice = read("~/.config/xcrab/config.toml");
|
||||
let de_config = from_slice(config_slice);
|
||||
}else{
|
||||
unimplemented!;
|
||||
let mut config_slice = fs::read("~/.config/xcrab/config.toml");
|
||||
let de_config:XcrabConfig = from_slice(&config_slice.unwrap()).unwrap(); //got that shiz
|
||||
return de_config
|
||||
}
|
||||
else{
|
||||
fs::write("~/.config/xcrab/config.toml", "border_color = 'ffffff'\nborder_size = 1\ngap_width = 1");
|
||||
//add stuff
|
||||
let mut config_slice = fs::read("~/.config/xcrab/config.toml");
|
||||
let de_config:XcrabConfig = from_slice(&config_slice.unwrap()).unwrap(); //got that shiz
|
||||
return de_config
|
||||
}
|
||||
}else{
|
||||
fs::create_dir_all("~/.config/xcrab");
|
||||
fs::write("~/.config/xcrab/config.toml", "border_color = 'ffffff'\nborder_size = 1\ngap_width = 1");
|
||||
//add stuff
|
||||
let mut config_slice = fs::read("~/.config/xcrab/config.toml");
|
||||
let de_config:XcrabConfig = from_slice(&config_slice.unwrap()).unwrap(); //got that shiz
|
||||
return de_config
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ use breadx::{
|
|||
};
|
||||
|
||||
mod x11;
|
||||
|
||||
mod config;
|
||||
use x11::client::XcrabClient;
|
||||
|
||||
const BORDER_WIDTH: u16 = 5;
|
||||
|
|
Loading…
Reference in a new issue