Disabler 0.5b1 Shareware $10 )1994 Flash Sheridan 180A Hamilton Avenue #601 Palo Alto, California 94301-1682 FlaSheridn@aol.com Summary: Heuristically adjusts the clock on startup, reclaims up to 10K of system memory, and allows the user to disable all InstallScripts, or just InstallScripts on a card. Disabling InstallScripts may help avoid (temporarily) conflicts and Out of Memory errors. Some features require or prefer that Disabler be installed internally; i.e., not on a memory card. Disabling InstallScripts requires that Disabler be installed internally. Disabling internal InstallScripts requires that it be the first package installed internally. The clock adjustment heuristic may not work well unless the package is installed internally, but should still be better than nothing. Reclaiming memory should work fine anywhere. Changes in 0.5b1: Added an option to clean out InstallScripts after theyUve run; this saves 10K of system memory on my Newton. Changed the interface for disabling startup InstallScripts. Slightly more sophisticated heuristic for adjusting the clock. HEURISTICALLY ADJUSTING THE CLOCK If you restart your Newton as often as I do, youUll have noticed that its clock loses, not milliseconds a day, not seconds a day, but *minutes* a day. This is obviously unacceptable behavior for an alarm clock. Furthermore, setting the clock ahead loses some time, too; my rough calculations on the number of seconds resetting and then adjusting loses indicate that the answer is roughly forty-two. But there seems to be no way to set the Newton ahead by forty-two seconds (the Newton Toolkit insists that time is _heavily_ quantized). Instead I set the clock ahead by one minute, about forty-two restarts out of sixty. This obviously isnUt perfect, but my experience indicates that itUs considerably better than nothing. It by no means solves the problem, but it does take the square root of it: it reduces a unidirectional progression to a random walk, which is generally off by about the square root of the number of steps. If youUre a programmer (and possibly if youUre not), every week or so you may have to brainwipe your Newton and restore it from a backup. When you do this, your Newton decides that itUs January first, 1993. My rule of thumb is that itUs not, and it is unlikely ever to be again. So if youUve checked the RAdjust ClockS box, and your Newton claims that itUs January first, 1993, Disabler over-rules it and says that itUs January second, 1994. This is likely to be false as well, but adjusting the clock a few months ahead is quicker than adjusting it a year or more. INSTALLSCRIPTS An InstallScript is what on a Macintosh is called an Extension, i.e., code run at startup, not under the userUs control. Unlike Macintosh System 7, on the Newton thereUs no uniform way for the user to disable (or even see) an InstallScript. Any application may contain an extension, and thereUs no way for the ordinary user to tell whether he wants it to run, or to stop it if he doesnUt. Cleaning Out InstallScripts After They Run An InstallScript is designed to run once. ThereUs no reason for the operating system to keep the InstallScript itself (as opposed to its effects) around in system memory afterwards, but it does, at least for now; I suspect Apple will fix this. Apple now recommends that the InstallScripts remove themselves after running; not all of them do yet, so Disabler has an option to do it for them. I donUt know of any package which refers to its InstallScript after itUs run, and it would be wasteful to do so, but there may be something out there which does. Presumably such a package will also break in future operating systems. To clear out all InstallScripts after startup, check the RClear InstallScripts On StartupS box; it should run at least thirty seconds after the InstallScripts have run. To do it manually (e.g., after youUve inserted a card), open the Disabler package from the Extras Drawer and press the RClear InstallScripts NowS button. In either case, Disabler will tell the system notification log how much memory it saved. (It rapidly got boring having Disabler brag every time it ran.) To see the log message, either run my package Any Messages?, or press Undo three times, then the Up Arrow. On my Newton, the savings vary, but are generally 10K or so; your savings will depend on what packages you have installed. Disabling InstallScripts Whatever an InstallScript does probably uses up system memory, which is a disaster under System 1.04 and before, and is sometimes still a problem under 1.05. Things may get even more chaotic as more and more packages become available and start doing more and more interesting things. Pretty soon it may become like the Macintosh world, where sometimes you have to disable all extensions just to get some work done. There are already rumors of InstallScript conflicts; this is probably only a problem with large packages which only fit on a card, but just in case (and because it was an interesting challenge), I also give you the option of disabling all InstallScripts (except mine, of course, which is what disables the others.). To do either, you must install Disabler internally (i.e., not on a memory card). Beyond that, the two forms of disabling are done quite differently. Note that some new packages (e.g., MobileMath) are smart enough to ask you whether to run their InstallScripts; Disabler wonUt disable MobileMathUs InstallScript. Disabling Card InstallScripts If you only want to disable InstallScripts on your memory card, start up your Newton without the card, open the Extras drawer, press the Disabler icon, press the large RDisable Card InstallScriptsS button, and insert the card within five seconds. ThatUs it; you donUt have to worry about the next section. The one gotcha which always applies is that if you attempt to remove your card (or a package) when youUve disabled its InstallScript, it may crash the Newton. This seems to be fairly harmless, but you may want to avoid doing it; instead, restart the Newton, *donUt* disable, and then remove it. There seems to be no way around this problem, since until now it was reasonable for a packageUs RemoveScript to assume that its InstallScript had run. Since this is now sometimes false, a RemoveScript may be trying to remove something that wasnUt actually installed, though most packages seem smart enough not to do this. Disabling Internal InstallScripts (not for the timid) I advise against doing this, since it requires your Newton to run *my* InstallScript. The only legitimate situation I can think of for doing this is before you install internally a package you donUt trust. If you insist on disabling *all* your InstallScripts automatically, you must check the RDisable Startup ScriptsS checkbox, and remove and reinstall all the other packages youUve installed internally on your Newton. [Actually, you donUt have to remove and reinstall *all* the packages; Disabler just wonUt disable a particular packageUs InstallScript unless the other package was installed after Disabler. Got that?] Next time you restart your Newton, the InstallScripts wonUt run; ten seconds or so after theyUve finished not running, they will be silently restored, and will later get cleaned out if youUve set that option. Re-running InstallScripts If you change your mind later, there is a button which runs all InstallScripts. But remember that it runs *all* InstallScripts, whether theyUve run already or not. So, for instance, if a package installs a button in your NotepadUs status bar, running its InstallScript again will install a *second* button there, which looks odd but seems to do no harm. Of course, if an InstallScript has been cleaned out, it canUt be run. WARNING This is the second release of beta software. In my testing, other packages sometimes got confused, leading to error messages and crashes, but IUve seen no data loss. Your mileage may vary. As always, ensure you have at least one backup of anything important, and preferably several backups made independently onto locked optical disks stored in a safe deposit box on the opposite coast. I do. Thanks to Capps for not doing it himself, Mike Engber for the soup, and Zandr for the randomness. DEVELOPERSU NOTES I am setting a bad example; Disabler works by briefly patching TotalClone. This may be the first trap patch for the Newton, and I hope itUs the last. If I could have gotten doing it the right way to work, I would have. If the OS grows up a bit, or more packages become considerate about their InstallScripts (like MobileMath), this sort of thing will become unnecessary. Until then, to reduce the chance of conflicts, hereUs how I did it. The soup is public; you can read my slots and add your own. HereUs the interesting bit of the source: defconst('kPatchTotalClone, func() BEGIN // if not functions.totalCloneOriginal exists then functions.totalCloneOriginal := functions.totalClone; functions.totalClone := func(argy) begin if debugOn and argy.app exists then print(argy.app); RETURN call kRenameSlot with (totalCloneOriginal(argy), 'devInstallScript, 'devInstallScriptDisabled); end; defconst('kRestoreTotalClone, func() functions.totalClone := functions.totalCloneOriginal); defconst('kRenameSlot, func(frame, oldName, newName) if frame.(newName) or not frame.(oldName) then return frame else BEGIN if debugOn and frame.text exists then print(frame.text); frame.(newName) := frame.(oldName); return removeSlot(frame, oldName); END); DefConst('kSignatureFlash,"FlaSheridn"); DefConst('kSoupEntryName, "DisableInstallScripts" & $: & kSignatureFlash); I if (prefsEntry AND StrEqual(prefsEntry.tag, kSoupEntryName) AND time() < ExpirationDate) then BEGin if prefsEntry.DisableStartupInstallScripts then Begin call kPatchTotalClone with () ; PlaySoundSync(ROM_poof); I If prefsEntry.AdjustClockRandomly then Begin if time() < StringToDate("1/2/1993") then begin SetTime(StringToDate("1/2/1994")); PlaySoundSync(ROM_alarmwakeup); PlaySoundSync(ROM_alarmwakeup); PlaySoundSync(ROM_alarmwakeup); end; if Random(0,59) < 42 then // begin setTime( time() + 1); PlaySoundSync(ROM_click);