On Sun, May 02, 2004 at 02:41:47PM +0200, Konstantin Kletschke wrote:
> function mpc_status_osd()
>
> os.execute("mpc | osd_cat -u red -s 2 -p middle -A left -o 30 -f \
> '-b&h-lucida-bold-r-normal-*-*-240-*-*-p-*-*-*' -c rgb:ff/00/00 -d 2")
Don't use os.execute, it blocks and the environment isn't set up
properly. Use 'exec' provided by Ion.
> -- kpress(SECOND_MOD.."F10", mpc_status_osd()),
You shouldn't call the function here, simply provide a reference to it.
kpress(SECOND_MOD.."F10", mpc_status_osd),
> But ion2 thinks, its an global function (when -- removed):
> Ion startup error log:
> >> /home/konsti/.ion2/ion-bindings.lua:112: attempt to call global
Lua gives this error when it can't find the symbol within local variables
or the globals table.
Are you using Lua 5.0.2? 5.0 used to have a bug that caused functions to
go missing at times.
> When executing lua code (kpress(SECOND_MOD.."F3",
> querylib.query_lua),)
> the osd appears as expected, so the funktion seems to be included...
> How do I call it?
mpc_status_osd()
> When pressing SECOND_MOD.."F10" I want to execute the "mpc blorgh"
> and after that the mpc_osd_status function, how do I achieve this?
If you use os.execute (unrecommended as it blocks), the mpc program
should have finished once it returns. Otherwise, a kludge could be
written using popen_bgread, as the handler given to this gets called
with a nil parameter when the pipe has been closed.
--
Tuomo