FelixKratz / SbarLua

A Lua API for SketchyBar
GNU General Public License v3.0
139 stars 11 forks source link

For sbar.exec(<cmd>, <callback>), <callback> is not called when <cmd> prints nothing #24

Closed WantToLearnJapanese closed 2 months ago

WantToLearnJapanese commented 6 months ago

Currently, the simple workaround is appending && echo 1 to the \<cmd\>

curiosusJR commented 5 months ago

Hi, I meet a problem with the function too. It can not recive argument from , I think. I executed the example command

sbar.exec("sleep 5 && echo TEST", function(result)
  print(result)
end)

and return nothing. I wonder what's wrong with it. Can you test if it return "TEST" or nothing plz? plus, I'm using lua 5.4.6. Does it matter?

WantToLearnJapanese commented 5 months ago

@curiosusJR Sorry for the late reply. I can't access the macOS right now. But I am sure appending && echo 1 works. Since I actually used that for my scripts.

XavierChanth commented 5 months ago

I am checking for the built-in display which yields empty string if it doesn't find, so I appended: grep -q 'Built-in' && echo 'true' || echo 'false' works like a charm.

FelixKratz commented 2 months ago

Should be fixed. Exit code is now additionally send to the callback function: https://github.com/FelixKratz/SbarLua/commit/5cfb488806006230712e87da74d8e767072c5c29