v1cont / yad

Yet Another Dialog
GNU General Public License v3.0
654 stars 58 forks source link

typo in wiki example script #211

Closed step- closed 1 year ago

step- commented 1 year ago

In https://github.com/v1cont/yad/wiki/Frontend-for-find(1) I think the first line of function run_find should be echo "6:@disabled@" with a final d.

v1cont commented 1 year ago

thanks, fixed

step- commented 1 year ago

Even with the correct @disabled@ spelling, there's still something wrong - the button stays disabled only briefly - but I can't figure out why. Here, running a long find task shows clearly that the button is made sensitive way before the task has finished running. In fact, if I click the button several times I end up with multiple find processes running at the same time.

Misko-2083 commented 1 year ago

Eval does not fork only when the command is built-in. I think find isn't a built-in. Try setting a trap in that function to enable the button on exit.

step- commented 1 year ago

Well, I changed run_find and moved echo to the top, like this, which makes the enable/disable concept more readable, but it didn't help: the button still doesn't stay disabled long enough.

function run_find
{
    trap "echo \"@yad-search:$find_cmd\"" EXIT
    echo "@yad-search:@disabled@"

Tracing which processes get started, If I click the button twice I can see that the second find runs with null arguments.

5602 date '--date=09/01/2022' +%s
5603 date '--date=@1661983200' +%Y-%m-%d
5604 touch -d 2022-09-01 /tmp/find-ts.8KXqQ1d2
5605 find /mnt/s -name '*' -newer /tmp/find-ts.8KXqQ1d2 -printf '%p\n%s\n%M\n%TD %TH:%TM\n%u/%g\n'
5607 bash -c run_find '*' FALSE /mnt/s 09/01/2022 ''
5608 find -name '' -printf '%p\n%s\n%M\n%TD %TH:%TM\n%u/%g\n'
Misko-2083 commented 1 year ago
function run_find
{
    trap "echo \"@yad-search:$find_cmd\"" EXIT
    echo "@yad-search:@disabled@"

What is "@yad-search"? It should be field number 6 in the script.

step- commented 1 year ago

Sorry, I was testing the script attached to https://github.com/v1cont/yad/pull/213#issuecomment-1380468456, just read 6 for @yad-search in my comment above

step- commented 1 year ago

I think I understand this issue better now. The button should be re-enabled when yad LIST has finished displaying the results, not when yad FORM has finished running find. Find is very quick to output all files, but yad list can't keep pace with find.

Misko-2083 commented 1 year ago

Does it makes difference if output of command is unbuffered?

stdbuf -oL find ...

The button should be re-enabled when yad LIST has finished displaying the results, not when yad FORM has finished running.

Bidirectional communication between the function and the list dialog would have to exist. First the shell function would have to notify list about the last line and wait for the return message. Then the list would have to return a message when the last row was loaded so that function enables the button.

Logic would be: If (echo -e "\f\f" > LIST) ---> then the LIST dialog prints "loaded" to stdout when \f\f is read from stdin.

Not only a new feature would have to be added, it would also need another named pipe in bash for the list dialog to write to and for the function to keep an eye on and wait.