1
0
mirror of https://github.com/pcvolkmer/checkbar.git synced 2025-07-02 14:22:54 +00:00

Show cursor after exit in terminal mode

This commit is contained in:
2023-12-11 16:45:44 +01:00
parent fea1d3f650
commit b75a1218bd
3 changed files with 30 additions and 0 deletions

View File

@ -1,6 +1,7 @@
use checkbar::{get_click_cmd, print_states, read_click_event, run_click_cmd, Config, MouseButton};
use console::Term;
use serde_json::json;
use std::process::exit;
use tokio::task;
use tokio::time::sleep;
@ -8,6 +9,11 @@ use tokio::time::sleep;
async fn main() {
if Term::stdout().is_term() {
let _ = Term::stdout().hide_cursor();
let _ = ctrlc::set_handler(|| {
let _ = Term::stdout().show_cursor();
println!();
exit(1);
});
} else {
println!(
"{}",
@ -37,6 +43,7 @@ async fn main() {
loop {
let config = Config::read();
print_states(&config).await;
let _ = Term::stdout().hide_cursor();
let _ = sleep(config.interval).await;
}
});