bayleeadamoss / zazu-clipboard

A clipboard manager for Zazu.
The Unlicense
14 stars 12 forks source link

Make monitor interval customizable #16

Closed twang2218 closed 7 years ago

twang2218 commented 7 years ago

1 second interval will cause high CPU usage on Linux system, with this PR, the interval has been increased to 3 seconds, which reduced the CPU usage in this case, however, more frequent clipboard register will be missed.

Fixes https://github.com/tinytacoteam/zazu/issues/189

Signed-off-by: Tao Wang twang2218@gmail.com

avaly commented 7 years ago

Could this interval be customizable from the .zazurc.json file? It should give more control to users.

twang2218 commented 7 years ago

@avaly That's a good idea, currently I don't think it's possible to customize the plugin block's configuration.

@blainesch WDYT, should we add such feature?

bayleedev commented 7 years ago

We could kind of customize it. We could set up the service like this:

const realFunc = () => {
  console.log('the real work')
}

module.exports = (pluginContext) => {
  let interval = null
  return (env = {}) => {
    if (!interval) {
      interval = setInterval(realFunc, env.timeout || 3000)
    }
    Promise.resolve('ping')
  }
}

What do you think? We could also find a way to make this a core feature, but I'm not sure how useful it would be for most cases.

twang2218 commented 7 years ago

Yeah, I was just thinking about this way, I will update this PR in this approach.

I'm not quite sure we need put this into the core feature either, we can decide it later if there are more request like this.

twang2218 commented 7 years ago

Updated the PR to enable the customized update interval, and also increased the default interval.

twang2218 commented 7 years ago

Updated this PR with unified time unit in the documents, and removed the extra catch/console/throw section. I submitted a PR fix for the log issue in zazu project instead: https://github.com/tinytacoteam/zazu/pull/224

twang2218 commented 7 years ago

@blainesch , could you review this PR? Thanks.

bayleedev commented 7 years ago

Looks great. I'll merge after that last comment! [: