mirror of
https://github.com/pcvolkmer/checkbar.git
synced 2025-04-19 19:16:50 +00:00
Code cleanup
This commit is contained in:
parent
bfb9e9b6cd
commit
5e9018112c
21
src/main.rs
21
src/main.rs
@ -1,7 +1,7 @@
|
|||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
use serde_json::json;
|
use serde_json::json;
|
||||||
use std::fmt::{Display, Formatter, Result};
|
|
||||||
use std::env;
|
use std::env;
|
||||||
|
use std::fmt::{Display, Formatter, Result};
|
||||||
use std::fs;
|
use std::fs;
|
||||||
use std::process;
|
use std::process;
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
@ -123,16 +123,22 @@ async fn print_states(check_configs: &[CheckConfig]) {
|
|||||||
for check_config in check_configs {
|
for check_config in check_configs {
|
||||||
entries.push(format!("{}", check_host(check_config).await));
|
entries.push(format!("{}", check_host(check_config).await));
|
||||||
}
|
}
|
||||||
entries.push(json!({
|
entries.push(
|
||||||
|
json!({
|
||||||
"full_text": chrono::Local::now().format("%H:%M").to_string()
|
"full_text": chrono::Local::now().format("%H:%M").to_string()
|
||||||
}).to_string());
|
})
|
||||||
|
.to_string(),
|
||||||
|
);
|
||||||
println!("{}],", entries.join(","));
|
println!("{}],", entries.join(","));
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_config_file() -> String {
|
fn get_config_file() -> String {
|
||||||
match env::args().nth(1) {
|
match env::args().nth(1) {
|
||||||
Some(config_file) => config_file,
|
Some(config_file) => config_file,
|
||||||
None => format!("{}/.checkbar.toml", dirs::home_dir().unwrap().to_str().unwrap_or(""))
|
None => format!(
|
||||||
|
"{}/.checkbar.toml",
|
||||||
|
dirs::home_dir().unwrap().to_str().unwrap_or("")
|
||||||
|
),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -175,10 +181,13 @@ async fn run_click_cmd(cmd: String) {
|
|||||||
|
|
||||||
#[tokio::main(flavor = "multi_thread", worker_threads = 2)]
|
#[tokio::main(flavor = "multi_thread", worker_threads = 2)]
|
||||||
async fn main() {
|
async fn main() {
|
||||||
println!("{}", json!({
|
println!(
|
||||||
|
"{}",
|
||||||
|
json!({
|
||||||
"version": 1,
|
"version": 1,
|
||||||
"click_events": true
|
"click_events": true
|
||||||
}));
|
})
|
||||||
|
);
|
||||||
println!("[");
|
println!("[");
|
||||||
|
|
||||||
let inputs = task::spawn(async {
|
let inputs = task::spawn(async {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user