shdown / luastatus

universal status bar content generator
GNU General Public License v3.0
293 stars 12 forks source link

Interconnection with sinx stats aggregator #58

Open Arteneko opened 4 years ago

Arteneko commented 4 years ago

I built sinx a while ago, to simplify scheduled stats collection.

It's backed by a redis storage and a pretty simple UX, and I wanted to know your thoughts about providing a plugin to extract data from sinx right away.

shdown commented 4 years ago

Yes, that would be a nice example for out-of-tree plugin.

Sorry if I missed something, but how is that different from, well, querying redis directly (using, say, this library)?

Or do you want it to interact with sinx via the HTTP API? If so, we already have an example of such a widget.

Arteneko commented 4 years ago

I'm thinking about a module that interacts with redis but natively reads the configuration for the sinx tools, e.g. To auto-handle the user-configured sinx prefix.

On Tuesday, 24 December 2019, Victor wrote:

Yes, that would be a nice example for out-of-tree plugin.

Sorry if I missed something, but how is that different from, well, querying redis directly (using, say, this library)?

Or do you want it to interact with sinx via the HTTP API? If so, we already have an example of such a widget.

-- You are receiving this because you authored the thread. Reply to this email directly or view it on GitHub: https://github.com/shdown/luastatus/issues/58#issuecomment-56879288

shdown commented 4 years ago

OK, so do you have a command to get the prefix? Are there any other configuration variables that need to be read?

Arteneko commented 4 years ago

The prefix can be set in the configuration file, which can be found at the paths described here.

By default, the prefix is sinx.

The full key in redis is <prefix>::<key>.

On Tuesday, 24 December 2019, Victor wrote:

OK, so do you have a command to get the prefix? Are there any other configuration variables that need to be read?

-- You are receiving this because you authored the thread. Reply to this email directly or view it on GitHub: https://github.com/shdown/luastatus/issues/58#issuecomment-56880486

shdown commented 4 years ago

Okay, so we can just parse the config file(s) using lua-toml, and then query redis using redis-lua.

You can implement this yourself if you want, or wait until I do it.

Arteneko commented 4 years ago

I may look into implementing this, but never really worked with Lua.

If I start a poc before you do, I'll submit it for review so you can use it as a base to implement a clean version, I guess.

On Tuesday, 24 December 2019, Victor wrote:

Okay, so we can just parse the config file(s) using lua-toml, and then query redis using redis-lua.

You can implement this yourself if you want, or wait until I do it.

-- You are receiving this because you authored the thread. Reply to this email directly or view it on GitHub: https://github.com/shdown/luastatus/issues/58#issuecomment-56880666

shdown commented 4 years ago

Yeah, that would be nice.

Arteneko commented 4 years ago

I have some issue with directly interacting with Redis, especially in the case in which the sinx instance is remote (I have this case).

I'm thinking of two things:

How does this library handle lua dependencies on modules? Is it up to the user to handle that?

shdown commented 4 years ago

How does this library handle lua dependencies on modules?

luastatus is no library; rather, it is a platform.

Is it up to the user to handle that?

It’s up to Lua to handle that:

Lua uses the package library to manage modules.

package.path (for modules written in Lua) and package.cpath (for modules written in C) are the places where Lua looks for modules. They are semicolon-separated lists, and each entry can have a ? in it that's replaced with the module name.

luastatus just does not interfere with this, nor should it.

As for popen vs. lua http library, I would go for the http library — it’s quite easy to install it via luarocks.

Take a look at the following btc-price widget example: https://github.com/shdown/luastatus/blob/master/examples/i3/btc-price.lua

And at the imap plugin: https://github.com/shdown/luastatus/blob/master/plugins/imap/imap.lua

Arteneko commented 4 years ago

Thanks for the info about libraries, I'm still not familiar with the lua tool environment, but trying to learn.

As a side-note, using luastatus right now on my work laptop, it integrates nicely with i3!

shdown commented 4 years ago

As a side-note, using luastatus right now on my work laptop, it integrates nicely with i3!

Hearing such things is the ultimate reason to do open-source development :)