Add 'New Login' button to unlock dialog

This commit is contained in:
2022-05-04 00:22:00 -07:00
parent 832b381421
commit 92504d279a
7 changed files with 68 additions and 28 deletions

View File

@ -1,4 +1,5 @@
use std::{ffi::CStr, io};
use std::{ffi::CStr, fs::File, io::{self, Read}};
use toml::Value;
use xcb::x;
pub const BSCREENSAVER_WM_CLASS: &[u8] = b"bscreensaver\0Bscreensaver\0";
@ -10,6 +11,21 @@ pub fn init_logging(env_name: &str) {
.init();
}
pub fn load_configuration() -> anyhow::Result<Option<Value>> {
match xdg::BaseDirectories::new()?.find_config_file("bscreensaver.toml") {
None => Ok(None),
Some(config_path) => {
let mut f = File::open(config_path)?;
let mut config = String::new();
f.read_to_string(&mut config)?;
drop(f);
let config_toml = config.parse::<Value>()?;
Ok(Some(config_toml))
},
}
}
pub fn create_atom(conn: &xcb::Connection, name: &[u8]) -> xcb::Result<x::Atom> {
let cookie = conn.send_request(&x::InternAtom {
only_if_exists: false,