On Thu, 2006-11-30 at 20:50 +0100, Marco Gerards wrote: > Actually, what I would prefer is something hooks. It would be nice if > the C code in GRUB and perhaps also scripts can be hooked anywhere. > We have to be very careful about this, so perhaps limit the sets of > commands that can be used this way. But I think it will make GRUB > more flexible while it is not too much effort.
I like this idea. > I am thinking of the following functions: > > One to install a hook: > grub_err_t grub_hook_register (const char *name, (*hook) (...)); > > To trigger the hook (for example, when the user types something, > selects another menu entry, etc. > void grub_hook_call (const char *name, ...); > > How to pass arguments to functions and to scripts is something that we > have to think about. For example, scripting functions have to get > strings, while in other cases we just want to deal with regular > function calls. Perhaps a printf-like mechanism can help us with > this. I do not think it's important that we be able to hook C functions directly. In other words, the argument passed to --function (below) should be a script command (or script function), and not a C function name. > In that case your problem can be solved by using: > > function handlemenu { > beep depending on menuentry selected, the index is passed to this function > } > > hook --install --hook=select-menu-entry --function=handlemenu Defining the set of useful hooks, the arguments passed to each, and documenting them will be critical. Also, just like with commands, once we implement a hook we can't remove or change it without breaking config files. -Hollis _______________________________________________ Grub-devel mailing list Grub-devel@gnu.org http://lists.gnu.org/mailman/listinfo/grub-devel