fix: remove no-op timeout on poll-vars

This commit is contained in:
elkowar 2021-09-11 14:02:28 +02:00
parent df1168d6d0
commit 5a581a5974
No known key found for this signature in database
GPG key ID: E321AD71B1D1F27F
3 changed files with 3 additions and 11 deletions

View file

@ -116,6 +116,7 @@ pub fn parse_scss_from_file(path: &Path) -> Result<String> {
grass::from_string(file_content, &grass_config).map_err(|err| anyhow!("Encountered SCSS parsing error: {:?}", err))
}
#[ext(pub, name = StringExt)]
impl<T: AsRef<str>> T {
/// check if the string is empty after removing all linebreaks and trimming

View file

@ -36,7 +36,7 @@ impl ScriptVarDefinition {
pub fn command_span(&self) -> Option<Span> {
match self {
ScriptVarDefinition::Poll(x) => match x.command {
VarSource::Shell(span, _) => Some(span),
VarSource::Shell(span, ..) => Some(span),
VarSource::Function(_) => None,
},
ScriptVarDefinition::Listen(x) => Some(x.command_span),
@ -70,11 +70,6 @@ impl FromAstElementContent for PollScriptVar {
let mut attrs = iter.expect_key_values()?;
let initial_value = Some(attrs.primitive_optional("initial")?.unwrap_or_else(|| DynVal::from_string(String::new())));
let interval = attrs.primitive_required::<DynVal, _>("interval")?.as_duration()?;
let timeout = attrs
.primitive_optional::<DynVal, _>("timeout")?
.map(|x| x.as_duration())
.transpose()?
.unwrap_or_else(|| std::time::Duration::from_millis(200));
let (script_span, script) = iter.expect_literal()?;
iter.expect_done()?;
Self {

View file

@ -155,8 +155,7 @@ They may also be useful to have buttons within eww change what is shown within y
```lisp
(defpoll time :interval "1s"
:timeout "0.1s" ; setting timeout is optional
:initial "initial-value" ; setting timeout is optional
:initial "initial-value" ; setting initial is optional
`date +%H:%M:%S`)
```
@ -166,9 +165,6 @@ This may be the most commonly used type of variable.
They are useful to access any quickly retrieved value repeatedly,
and thus are the perfect choice for showing your time, date, as well as other bits of information such as your volume.
Optionally, you can specify a timeout, after which the provided script will be aborted.
This helps to avoid accidentally launching thousands of never-ending processes on your system.
You can also specify an initial-value, this should prevent eww from waiting for the result of a give command during startup, thus,
making the startup time faster.