-
-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow configuration through a TOML file (#156).
- Loading branch information
Showing
10 changed files
with
476 additions
and
247 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
use std::{error::Error, path::PathBuf}; | ||
|
||
use serde::Deserialize; | ||
|
||
use crate::Greeter; | ||
|
||
#[derive(Debug, Default, Deserialize)] | ||
pub struct FileConfig { | ||
#[serde(default)] | ||
pub defaults: Defaults, | ||
#[serde(default)] | ||
pub sessions: Sessions, | ||
#[serde(default)] | ||
pub remember: Remember, | ||
#[serde(default)] | ||
pub ui: Ui, | ||
} | ||
|
||
#[derive(Debug, Default, Deserialize)] | ||
pub struct Defaults { | ||
pub debug: Option<String>, | ||
pub command: Option<String>, | ||
pub env: Option<Vec<String>>, | ||
pub user_min_uid: Option<u16>, | ||
pub user_max_uid: Option<u16>, | ||
#[serde(default)] | ||
pub power_no_setsid: bool, | ||
pub shutdown_command: Option<String>, | ||
pub reboot_command: Option<String>, | ||
} | ||
|
||
#[derive(Debug, Default, Deserialize)] | ||
pub struct Sessions { | ||
pub wayland_paths: Option<Vec<PathBuf>>, | ||
pub wayland_wrapper: Option<String>, | ||
pub x11_paths: Option<Vec<PathBuf>>, | ||
pub x11_wrapper: Option<String>, | ||
#[serde(default)] | ||
pub x11_wrapper_disabled: bool, | ||
} | ||
|
||
#[derive(Debug, Default, Deserialize)] | ||
pub struct Remember { | ||
#[serde(default)] | ||
pub last_user: bool, | ||
#[serde(default)] | ||
pub last_session: bool, | ||
#[serde(default)] | ||
pub last_user_session: bool, | ||
} | ||
|
||
#[derive(Debug, Default, Deserialize)] | ||
pub struct Ui { | ||
pub greeting: Option<String>, | ||
#[serde(default)] | ||
pub use_issue: bool, | ||
#[serde(default)] | ||
pub show_time: bool, | ||
pub time_format: Option<String>, | ||
#[serde(default)] | ||
pub show_user_menu: bool, | ||
#[serde(default)] | ||
pub show_asterisks: bool, | ||
pub asterisks_char: Option<char>, | ||
pub width: Option<u64>, | ||
pub window_padding: Option<u64>, | ||
pub container_padding: Option<u64>, | ||
pub prompt_padding: Option<u64>, | ||
pub command_f_key: Option<u8>, | ||
pub sessions_f_key: Option<u8>, | ||
pub power_f_key: Option<u8>, | ||
} | ||
|
||
impl Greeter { | ||
pub fn parse_config_file(&mut self, file: &str) -> Result<FileConfig, Box<dyn Error>> { | ||
Ok(toml::from_str::<FileConfig>(file)?) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
pub mod file; | ||
pub mod parser; |
Oops, something went wrong.