mirror of
https://github.com/Wojtek242/rwmstatus.git
synced 2024-11-21 15:15:25 +01:00
Create config file
This commit is contained in:
parent
daf7ade015
commit
f8f1b0f7e1
13
src/config.rs
Normal file
13
src/config.rs
Normal 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"];
|
16
src/main.rs
16
src/main.rs
@ -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![];
|
||||
|
Loading…
Reference in New Issue
Block a user