minor improvements, added README.md
parent
d26fdffbda
commit
2199e8e2d6
|
@ -0,0 +1,15 @@
|
|||
# Waybar Module Monitor
|
||||
|
||||
Small icon for your waybar, showing system information when mouseover.
|
||||
Returned in JSON format.
|
||||
|
||||
## Example Usage
|
||||
|
||||
"custom/mon": {
|
||||
"exec": "~/paht/to/bin",
|
||||
"interval": 10,
|
||||
"format": " ",
|
||||
"tooltip": true,
|
||||
"return-type": "json",
|
||||
}
|
||||
|
14
src/main.rs
14
src/main.rs
|
@ -10,6 +10,7 @@ struct WaybarModule {
|
|||
text: String,
|
||||
alt: String,
|
||||
}
|
||||
|
||||
fn main() {
|
||||
// Please note that we use "new_all" to ensure that all list of
|
||||
// components, network interfaces, disks and users are already
|
||||
|
@ -22,7 +23,7 @@ fn main() {
|
|||
|
||||
// We display all disks' information:
|
||||
let mut disks_string = String::try_from("\n=> disks ").unwrap();
|
||||
disks_string += &("-".repeat(120 - disks_string.len()) + "\n");
|
||||
disks_string += &("-".repeat(120 - disks_string.chars().count()) + "\n");
|
||||
|
||||
for disk in sys.disks() {
|
||||
if !disk.mount_point().to_str().unwrap().contains("/efi") {
|
||||
|
@ -43,7 +44,7 @@ fn main() {
|
|||
|
||||
// Network interfaces name, data received and data transmitted:
|
||||
let mut networks = String::try_from("\n=> networks ").unwrap();
|
||||
networks += &("-".repeat(120 - networks.len()) + "\n");
|
||||
networks += &("-".repeat(120 - networks.chars().count()) + "\n");
|
||||
for (interface_name, data) in sys.networks() {
|
||||
if interface_name.contains("wlan") {
|
||||
let inter = format!(
|
||||
|
@ -62,13 +63,13 @@ fn main() {
|
|||
|
||||
// Components temperature:
|
||||
let mut comp = String::try_from("\n=> components ").unwrap();
|
||||
comp += &("-".repeat(120 - comp.len()) + "\n");
|
||||
comp += &("-".repeat(120 - comp.chars().count()) + "\n");
|
||||
for component in sys.components() {
|
||||
comp += &format!("{:?}\n", component);
|
||||
}
|
||||
|
||||
let mut system = String::try_from("\n=> system ").unwrap();
|
||||
system += &("-".repeat(120 - system.len()) + "\n");
|
||||
system += &("-".repeat(120 - system.chars().count()) + "\n");
|
||||
// RAM information:
|
||||
system += &format!(
|
||||
"total memory: {}\n",
|
||||
|
@ -83,6 +84,9 @@ fn main() {
|
|||
.format(1)
|
||||
);
|
||||
|
||||
// Number of CPUs:
|
||||
system += &format!("Number of CPUs: {}\n", sys.cpus().len());
|
||||
|
||||
// Display system information:
|
||||
system += &format!("System name: {:?}\n", sys.name().unwrap());
|
||||
system += &format!(
|
||||
|
@ -92,7 +96,7 @@ fn main() {
|
|||
system += &format!("System OS version: {:?}\n", sys.os_version().unwrap());
|
||||
system += &format!("System host name: {:?}\n", sys.host_name().unwrap());
|
||||
system += &format!(
|
||||
"Load Average: 1min {} 5min {} 15min {}\n",
|
||||
"Load Average (1/5/15 min): {} {} {}\n",
|
||||
sys.load_average().one,
|
||||
sys.load_average().five,
|
||||
sys.load_average().fifteen
|
||||
|
|
Loading…
Reference in New Issue