Note: This question was already posted in the Wolfram community.
In a terminal math
session, we can start a front end (FE) easily by launching it though LinkLaunch
or by using functions provided in the Developer`
context (thanks to Oleksandr for telling me about this). Here is a very basic example that starts a FE and opens a new notebook for you:
< lnk = Developer`InstallFrontEnd["Server"->False];
LinkWrite[lnk,FrontEndToken["New"]]
Unfortunately, the started FE starts the default kernel which is usually a good idea, but here I want to be in control of everything. This means, I would like to provide the Kernel for the FE so that it can connect to it and use it for calculation. So what I really want to have is a Mathematica MathLink program (or JLink) that starts a kernel and an FE, connects both so that the front end uses the kernel as evaluator but all communication goes through my program.
If you are familiar with LinkSnooper, then you see the difference because there, the FE starts the LinkSnooper as special kernel. What I want (not only for snooping, but for a more general problem) is similar but more problematic, because I want to control the kernel starting behavior of the FE from a link and not as user.
Question: Is there any direct way to do it? For instance by giving options to Developer`InstallFrontEnd
and using specific FrontEndToken
.
Appendix: One way that I haven't tested and which might work is modify the init.m
of the FE (usually located it $UserBaseDirectory/FrontEnd/init.m
), because there are the settings for the kernel:
EvaluatorNames->{
"Local" -> {"AutoStartOnLaunch" -> True},
"LinkSnooper" -> {...}
}
So I could theoretically alter the settings there (hopefully on the fly during startup of the FE) and force the FE to connect to my specific kernel.
Comments
Post a Comment