improve configuration layout

This commit is contained in:
Penelope Gwen 2025-09-21 01:24:38 -07:00
parent 9b7306ef5f
commit 7faced1b8c
2 changed files with 5 additions and 13 deletions

View file

@ -7,17 +7,10 @@ pub struct WindowIcon {
pub substring: String pub substring: String
} }
#[derive(Serialize,Deserialize,Clone,Debug)] #[derive(Serialize,Deserialize,Clone,Debug)]
pub struct BrowserConf {
pub profile: String,
pub startpage: String
}
#[derive(Serialize,Deserialize,Clone,Debug)]
pub struct Profile { pub struct Profile {
pub name: String, pub name: String,
pub icon: String, pub icon: String,
pub browser: BrowserConf, pub program_args: Option<HashMap<String, Vec<String>>>,
pub directory: String,
// pub index: u32
} }
#[derive(Serialize,Deserialize,Clone,Debug)] #[derive(Serialize,Deserialize,Clone,Debug)]
pub struct Programs { pub struct Programs {
@ -27,6 +20,7 @@ pub struct Programs {
} }
#[derive(Serialize,Deserialize,Clone,Debug,Default)] #[derive(Serialize,Deserialize,Clone,Debug,Default)]
pub struct LockConf { pub struct LockConf {
pub wallpaper_path: String,
pub blur: f32, pub blur: f32,
pub scale: f32, pub scale: f32,
} }
@ -34,9 +28,7 @@ pub struct LockConf {
pub struct Config { pub struct Config {
pub title_length: usize, pub title_length: usize,
pub window_icons: Vec<WindowIcon>, pub window_icons: Vec<WindowIcon>,
pub wallpaper_path: String,
pub programs: HashMap<String, Programs>, pub programs: HashMap<String, Programs>,
pub lock: LockConf, pub lock: LockConf,
//pub profiles: HashMap<String, Profile> pub profiles: Vec<Profile>
pub profiles: Vec<Profile>// HashMap<u32,Profile>
} }

View file

@ -32,7 +32,7 @@ pub fn generate_image(orig_img_data: DynamicImage,gen_image_path: PathBuf, lock_
} }
pub fn lock_screen(config: &Config, mut sway_connection: Connection, force_bg_render: bool) -> Result<Vec<Result<(), swayipc::Error>>, swayipc::Error> { pub fn lock_screen(config: &Config, mut sway_connection: Connection, force_bg_render: bool) -> Result<Vec<Result<(), swayipc::Error>>, swayipc::Error> {
let wallpaper_root_path = tilde(&config.wallpaper_path).to_string(); let wallpaper_root_path = tilde(&config.lock.wallpaper_path).to_string();
let wallpaper_root_path = Path::new(&wallpaper_root_path); let wallpaper_root_path = Path::new(&wallpaper_root_path);
let cache_dir = BaseDirectories::with_prefix("sway-profiles-rs").cache_home; let cache_dir = BaseDirectories::with_prefix("sway-profiles-rs").cache_home;
let wp_cache_dir = cache_dir.clone().unwrap().join("sway-profiles-rs/lock/"); let wp_cache_dir = cache_dir.clone().unwrap().join("sway-profiles-rs/lock/");
@ -89,7 +89,7 @@ pub fn lock_screen(config: &Config, mut sway_connection: Connection, force_bg_re
} }
let new_json = json!(wp_hash_array); let new_json = json!(wp_hash_array);
let _ = write(hashes_json_path, new_json.to_string()); let _ = write(hashes_json_path, new_json.to_string());
let mut gtklock_command = "exec echo gtklock".to_owned(); let mut gtklock_command = "exec gtklock".to_owned();
for a in gtklock_args { for a in gtklock_args {
gtklock_command = gtklock_command + " " + &a; gtklock_command = gtklock_command + " " + &a;
} }