Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possible copy-paste errors in documentation for ExecClient #199

Open
jjramsey opened this issue Jul 7, 2024 · 3 comments
Open

Possible copy-paste errors in documentation for ExecClient #199

jjramsey opened this issue Jul 7, 2024 · 3 comments

Comments

@jjramsey
Copy link

jjramsey commented Jul 7, 2024

There are two indications of problems with the documentation for ExecClient.

First, it has the sentence "The id is used to address the socket ..." even though ExecClient doesn't appear to involve sockets, at least not explicitly. (Indeed, it looks like the only difference between the documentation for ExecClient and the documentation for SocketClient is that the former contains the words "command to execute" instead of "a socket address"

Second, it seems to imply that the command to execute will somehow cause a trigger event, but there's no indication of how this happens. If I look at the example configs for "alsa.widget" and "rfkill.source", they superficially look similar to a waybar custom module or yambar script module running in continuous mode. Apparently, the executable causes a trigger event by flushing to standard output, but this isn't clear from the documentation at all.

@LBCrion
Copy link
Owner

LBCrion commented Jul 7, 2024 via email

@jjramsey
Copy link
Author

jjramsey commented Jul 8, 2024

It helps, but I'd recommend a couple things.

First, I'd amend, "The id can be used to write to the standard input of the executable" to "The id can be used to write to the standard input of the executable (provided that the executable takes standard input)". That would make clearer that an ExecClient doesn't have to take standard input.

Second, I'd add an example such as this:

scanner ExecClient("stdbuf -oL foo.sh BAR BAZ", "foo") {
  Foo_foo = Json(".foo")
  Foo_bar = Json(".bar")
}

where foo.sh is:

#!/bin/sh

. ~/foo_funcs.sh # Defines example funcs "do_something" &
                 # "do_something_else".

while true
do
    foo=`do_something "$1"`
    bar=`do_something_else "$2"`
    echo "{\"foo\": \"$foo\", \"bar\": \"$bar\"}"
    sleep 1
done

This would not only show what ExecClient does, but also show the kind of strings that Json() works on.

Then you can mention sfwbar files that use ExecClient, such as alsa.widget and rfkill.source, and suggest to the reader that they can look at those files for further examples.

I would also recommend explaining what $ is doing in the exec("getweather.sh") that you already have, presuming that isn't a typo.

@LBCrion
Copy link
Owner

LBCrion commented Jul 9, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants