chore: clean debug code

master
blob42 1 month ago
parent b379a50762
commit 1fbff5c5e6

@ -59,10 +59,10 @@ fn main() -> anyhow::Result<()> {
logger.init(); logger.init();
let program_cfg = config::read_config(cli.config).context("missing config file")?; let program_cfg = config::read_config(cli.config).context("missing config file")?;
dbg!(program_cfg); // dbg!(program_cfg);
// let mut scheduler = Scheduler::from_profiles(program_cfg.profiles); let mut scheduler = Scheduler::from_profiles(program_cfg.profiles);
//TODO: own thread //TODO: own thread
// scheduler.run(); scheduler.run();
Ok(()) Ok(())
} }

@ -45,12 +45,10 @@ impl ProfileJob<Process> {
fn run_cmd(cmd: &mut CmdSchedule, matching: ProcessMatcher, exec_end: bool) { fn run_cmd(cmd: &mut CmdSchedule, matching: ProcessMatcher, exec_end: bool) {
let out = if exec_end && cmd.exec_end.is_some() { let out = if exec_end && cmd.exec_end.is_some() {
dbg!("run exec_end !");
Command::new(&cmd.exec_end.as_ref().unwrap()[0]).args(&cmd.exec_end.as_ref().unwrap()[1..]).output() Command::new(&cmd.exec_end.as_ref().unwrap()[0]).args(&cmd.exec_end.as_ref().unwrap()[1..]).output()
} else if exec_end && cmd.exec_end.is_none() { } else if exec_end && cmd.exec_end.is_none() {
return; return;
} else { } else {
dbg!("running command !");
Command::new(&cmd.exec[0]).args(&cmd.exec[1..]).output() Command::new(&cmd.exec[0]).args(&cmd.exec[1..]).output()
}; };
@ -84,12 +82,12 @@ impl Job for ProfileJob<Process> {
fn update(&mut self, sysinfo: &System, last_refresh: Instant) { fn update(&mut self, sysinfo: &System, last_refresh: Instant) {
let _ = self.object.update_state(sysinfo, last_refresh); let _ = self.object.update_state(sysinfo, last_refresh);
dbg!(&self.object); trace!("{:#?}", &self.object);
// run commands when entering match state `exec` // run commands when entering match state `exec`
self.profile.commands.iter_mut() self.profile.commands.iter_mut()
// only process enabled commands // only process enabled commands
.filter(|cmd| !cmd.disabled) .filter(|cmd| !cmd.disabled)
.filter(|cmd| dbg!(self.object.matches(cmd.condition.clone()))) .filter(|cmd| self.object.matches(cmd.condition.clone()))
.for_each(|cmd| { .for_each(|cmd| {
debug!("running exec cmd"); debug!("running exec cmd");

@ -21,12 +21,12 @@ exec_end = ["sh", "-c", "notify-send 'foo end'"]
run_once = true run_once = true
[[profiles]] [[profiles]]
matching = { cmdline = "^fo?", regex = true } matching = { cmdline = "^foo?", regex = true }
# regex = false # regex = false
[[profiles.commands]] [[profiles.commands]]
condition = {seen = "5s"} condition = {seen = "5s"}
# one off command # one off command
exec = ["sh", "-c", "notify-send 'foo senn'"] exec = ["sh", "-c", "notify-send 'foo seen'"]
exec_end = ["sh", "-c", "notify-send 'foo end'"] exec_end = ["sh", "-c", "notify-send 'foo end'"]

Loading…
Cancel
Save