Create config file

This commit is contained in:
Wojciech Kozlowski 2018-12-26 02:59:22 +05:30
parent daf7ade015
commit f8f1b0f7e1
2 changed files with 17 additions and 12 deletions

13
src/config.rs Normal file
View File

@ -0,0 +1,13 @@
//! # rwmstatus configuration
/// Path to monitors.
pub const HWMON_PATH: &'static str = "/sys/devices/virtual/hwmon";
/// Array of monitors to use.
pub const HWMONS: [&'static str; 3] = ["hwmon0", "hwmon2", "hwmon4"];
/// Path to power supply information.
pub const BATT_PATH: &'static str = "/sys/class/power_supply";
/// Batteries to display.
pub const BATTS: [&'static str; 2] = ["BAT0", "BAT1"];

View File

@ -27,6 +27,10 @@ use std::fs::File;
use x11::xlib::Display;
use x11::xlib::{XDefaultRootWindow, XOpenDisplay, XStoreName, XSync};
// Internal module imports
mod config;
use config::*;
/// Convert a Rust string to a CString and panic if it fails.
#[inline]
fn cstring(string: &str) -> CString {
@ -42,12 +46,6 @@ fn read_file(base: &str, filename: &str) -> io::Result<String> {
Ok(contents)
}
/// Path to monitors.
const HWMON_PATH: &'static str = "/sys/devices/virtual/hwmon";
/// Array of monitors to use.
const HWMONS: [&'static str; 3] = ["hwmon0", "hwmon2", "hwmon4"];
/// Return temperature reads from all monitors.
fn get_temperatures() -> String {
let mut temp_strs: Vec<String> = vec![];
@ -86,12 +84,6 @@ fn get_load_avgs() -> String {
format!("{:.2} {:.2} {:.2}", avgs[0], avgs[1], avgs[2])
}
/// Path to power supply information.
const BATT_PATH: &'static str = "/sys/class/power_supply";
/// Batteries to display.
const BATTS: [&'static str; 2] = ["BAT0", "BAT1"];
/// Return battery status for all batteries.
fn get_batteries() -> String {
let mut batt_strs: Vec<String> = vec![];