mirror of
https://github.com/soywod/himalaya.git
synced 2024-07-05 09:05:13 +00:00
add idle_hook_cmds setting
This commit is contained in:
parent
b24ff24426
commit
366e0b72ed
|
@ -11,6 +11,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||||
|
|
||||||
- Default page size to config [#96]
|
- Default page size to config [#96]
|
||||||
- Custom config path [#86]
|
- Custom config path [#86]
|
||||||
|
- Setting idle-hook-cmds
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Improve config compatibility on Windows [#111](https://github.com/soywod/himalaya/pull/111)
|
||||||
|
|
||||||
## [0.2.6] - 2021-04-17
|
## [0.2.6] - 2021-04-17
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
use error_chain::error_chain;
|
use error_chain::error_chain;
|
||||||
use lettre::transport::smtp::authentication::Credentials as SmtpCredentials;
|
use lettre::transport::smtp::authentication::Credentials as SmtpCredentials;
|
||||||
|
use log::debug;
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
use std::{collections::HashMap, env, fs::File, io::Read, path::PathBuf};
|
use std::{collections::HashMap, env, fs::File, io::Read, path::PathBuf, thread};
|
||||||
use toml;
|
use toml;
|
||||||
|
|
||||||
use crate::output::utils::run_cmd;
|
use crate::output::utils::run_cmd;
|
||||||
|
@ -103,6 +104,9 @@ pub struct Config {
|
||||||
pub signature: Option<String>,
|
pub signature: Option<String>,
|
||||||
pub default_page_size: Option<usize>,
|
pub default_page_size: Option<usize>,
|
||||||
|
|
||||||
|
#[serde(default)]
|
||||||
|
pub idle_hook_cmds: Vec<String>,
|
||||||
|
|
||||||
#[serde(flatten)]
|
#[serde(flatten)]
|
||||||
pub accounts: HashMap<String, Account>,
|
pub accounts: HashMap<String, Account>,
|
||||||
}
|
}
|
||||||
|
@ -199,7 +203,7 @@ impl Config {
|
||||||
let cmd = self
|
let cmd = self
|
||||||
.notify_cmd
|
.notify_cmd
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.map(|s| format!(r#"{} "{}" "{}""#, s, subject, sender))
|
.map(|cmd| format!(r#"{} {:?} {:?}"#, cmd, subject, sender))
|
||||||
.unwrap_or(default_cmd);
|
.unwrap_or(default_cmd);
|
||||||
|
|
||||||
run_cmd(&cmd).chain_err(|| "Cannot run notify cmd")?;
|
run_cmd(&cmd).chain_err(|| "Cannot run notify cmd")?;
|
||||||
|
@ -224,4 +228,19 @@ impl Config {
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.to_owned()
|
.to_owned()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn exec_idle_hooks(&self) -> Result<()> {
|
||||||
|
let cmds = self.idle_hook_cmds.to_owned();
|
||||||
|
|
||||||
|
thread::spawn(move || {
|
||||||
|
debug!("batch execution of {} cmd(s)", cmds.len());
|
||||||
|
cmds.iter().for_each(|cmd| {
|
||||||
|
debug!("execute cmd {:?}", cmd);
|
||||||
|
let res = run_cmd(&cmd);
|
||||||
|
debug!("res: {:?}", res);
|
||||||
|
})
|
||||||
|
});
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -164,6 +164,7 @@ impl<'ic> ImapConnector<'ic> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
config.exec_idle_hooks()?;
|
||||||
debug!("[imap::model::idle] end loop");
|
debug!("[imap::model::idle] end loop");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,15 +33,15 @@ function! himalaya#msg#list_with(mbox, page, should_throw)
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! himalaya#msg#list()
|
function! himalaya#msg#list()
|
||||||
try
|
" try
|
||||||
let mbox = himalaya#mbox#curr_mbox()
|
let mbox = himalaya#mbox#curr_mbox()
|
||||||
let page = himalaya#mbox#curr_page()
|
let page = himalaya#mbox#curr_page()
|
||||||
call himalaya#msg#list_with(mbox, page, 0)
|
call himalaya#msg#list_with(mbox, page, 0)
|
||||||
catch
|
" catch
|
||||||
if !empty(v:exception)
|
" if !empty(v:exception)
|
||||||
redraw | call himalaya#shared#log#err(v:exception)
|
" redraw | call himalaya#shared#log#err(v:exception)
|
||||||
endif
|
" endif
|
||||||
endtry
|
" endtry
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! himalaya#msg#read()
|
function! himalaya#msg#read()
|
||||||
|
|
2
wiki
2
wiki
|
@ -1 +1 @@
|
||||||
Subproject commit dca48456982e1d214c0a21d5bf9bcf8b6fc1a759
|
Subproject commit a022c9580de7f4837cd1e6b028f8da7be96787b8
|
Loading…
Reference in a new issue