mirror of
https://github.com/ClementTsang/bottom
synced 2024-11-10 14:44:18 +00:00
Update documentation again, also change temp a bit
This commit is contained in:
parent
48107ac526
commit
238e0c88e0
3 changed files with 23 additions and 13 deletions
11
README.md
11
README.md
|
@ -92,7 +92,16 @@ Run using `btm`.
|
|||
|
||||
- `-R`, `--regex` will default to using regex.
|
||||
|
||||
- `-C`, `--config` takes in a file path leading to a TOML file, where one can set flags by default. The default path this will check is, on Linux, `~/.config/btm/btm.toml`. Options are the same as the long names as other flags (ie: `regex = true`). See the [sample config](./sample_config.toml) for an example.
|
||||
- `-C`, `--config` takes in a file path leading to a TOML file, where one can set flags to execute by default.
|
||||
|
||||
- Options are generally the same as the long names as other flags (ie: `case_sensitive = true`).
|
||||
- For temperature type, use `temperature_type = <kelvin|k|celsius|c|fahrenheit|f>`.
|
||||
- See the [sample config](./sample_config.toml) for an example.
|
||||
|
||||
bottom will check specific locations by default for a config file.
|
||||
|
||||
- For Unix-based systems: `~/.config/btm/btm.toml`.
|
||||
- For Windows: TBD.
|
||||
|
||||
### Keybindings
|
||||
|
||||
|
|
|
@ -6,8 +6,7 @@ pub const MAX_KEY_TIMEOUT_IN_MILLISECONDS: u128 = 1000;
|
|||
pub const NUM_COLOURS: i32 = 256;
|
||||
|
||||
// Config and flags
|
||||
pub const DEFAULT_CONFIG_FILE_PATH: &str = "~/.config/btm/btm.toml";
|
||||
pub const DEFAULT_UNIX_CONFIG_FILE_PATH: &str = "~/.config/btm/btm.toml";
|
||||
|
||||
pub const KELVIN: &str = "kelvin";
|
||||
pub const FAHRENHEIT: &str = "fahrenheit";
|
||||
pub const CELSIUS: &str = "celsius";
|
||||
// TODO: [CONF] Default windows path?
|
||||
pub const DEFAULT_WINDOWS_CONFIG_FILE_PATH: &str = "";
|
||||
|
|
18
src/main.rs
18
src/main.rs
|
@ -99,11 +99,13 @@ fn main() -> error::Result<()> {
|
|||
utils::logging::init_logger()?;
|
||||
}
|
||||
|
||||
let config_path = std::path::Path::new(
|
||||
matches
|
||||
.value_of("CONFIG_LOCATION")
|
||||
.unwrap_or(DEFAULT_CONFIG_FILE_PATH),
|
||||
);
|
||||
let config_path = std::path::Path::new(matches.value_of("CONFIG_LOCATION").unwrap_or(
|
||||
if cfg!(target_os = "windows") {
|
||||
DEFAULT_WINDOWS_CONFIG_FILE_PATH
|
||||
} else {
|
||||
DEFAULT_UNIX_CONFIG_FILE_PATH
|
||||
},
|
||||
));
|
||||
|
||||
let config_string = std::fs::read_to_string(config_path);
|
||||
let config_toml: Config = if let Ok(config_str) = config_string {
|
||||
|
@ -143,9 +145,9 @@ fn main() -> error::Result<()> {
|
|||
} else if let Some(temp_type) = config_toml.temperature_type {
|
||||
// Give lowest priority to config.
|
||||
match temp_type.as_str() {
|
||||
constants::FAHRENHEIT => data_harvester::temperature::TemperatureType::Fahrenheit,
|
||||
constants::KELVIN => data_harvester::temperature::TemperatureType::Kelvin,
|
||||
constants::CELSIUS => data_harvester::temperature::TemperatureType::Celsius,
|
||||
"fahrenheit" | "f" => data_harvester::temperature::TemperatureType::Fahrenheit,
|
||||
"kelvin" | "k" => data_harvester::temperature::TemperatureType::Kelvin,
|
||||
"celsius" | "c" => data_harvester::temperature::TemperatureType::Celsius,
|
||||
_ => data_harvester::temperature::TemperatureType::Celsius,
|
||||
}
|
||||
} else {
|
||||
|
|
Loading…
Reference in a new issue