I've been having an issue with a program I use heavily every day, where it it acts like it is recovering from a crash even when it was quit properly and all files saved. The app is FontLab Studio, not that it should matter. What happens is that it loads all the files I've worked on recently, which can be several dozen, and even if I click out of them all, it happens several more times throughout the day. Or, something causes it to crash as I'm exiting these files so that I have to relaunch and it starts all over.
What I've been doing to avoid this, is to run AppCleaner, the free uninstaller, and delete everything but the App itself and the license info. This works great, but given the frequency this is becoming necessary, I'd like to be able to create something I could access really fast, like an Applescript that I could put in my dock. Or an Automator service located in the contextual menu items.
I don't know any Applescript, but I tried to make an Automator workflow. The first step, "Get Selected Finder Items."
One has a static location, the second may change, I'm not sure.
~/Library/Saved Application State/com.fontlab.studio5.savedState
/var/db/BootCaches/34D6C504-2F5B-416F-9C91-0C9D019BF446/app.com.fontlab.studio5.playlist
The second step in the workflow is to move to the trash, and that's where it fails. I suspect because these require a password? If possible, it would be great if I could enter it once and it remember, otherwise, how I'll need it to prompt me to enter my passkey. I don't know the best way to do any of this.
I just had another thought, though it may not work as it would require FontLab to be open at the time, would be to accomplish this with a Python script, because FontLab is partially built in python and can install third party scripts. I am open to whatever help anyone could offer.
Thanks in advance!
Best Answer
I do not have FontLab Studio installed however for the purpose of providing a solution to your situation, under OS X El Capitan 10.11.5, I did the following:
In a Terminal at
/private/var/db/BootCaches
, usingsudo
,mkdir
andtouch
I created a directory named34D6C504-2F5B-416F-9C91-0C9D019BF446
and in that directory a file namedapp.com.fontlab.studio5.playlist
.In Finder, in my Home folder's Library > Saved Application State folder, I duplicated a folder and renamed the copy to: "com.fontlab.studio5.savedState"
In doing so this replicated the target locations and files with appropriate privileges to then test the following AppleScript application on.
In Script Editor I used the following code to create the Reset FontLab Studio.app and saved it in the Applications folder of the Macintosh HD and then dragged it to the Dock so as to have it readily available to click on.
When I click on the Reset FontLab Studio Dock Tile it showed the password dialog box, as shown below, for me to type in my password. I typed in my password and pressed enter. That's it, the app did what it was programmed to do.
Notes:
As this code is tested I'd suggest copying and pasting it as is into Script Editor and then saving it as an application of whatever name you desire.
$HOME
is being used because~
can/will at times error out in AppleScript and or Automator, depending on its specific use. Normally~
is expanded to the value of Environment Variable ofHOME
and thus I typically use$HOME
over~
to avoid errors that it can/will generate at times.The substitution of
*
for34D6C504-2F5B-416F-9C91-0C9D019BF446
is intensional, so as to accommodate the possible name change.The
try
command is used so as to avoid an error if you run the Reset FontLab Studio app again before the target files are recreated and or if one or the other doesn't exist, it still deletes the other./var
is a symbolic link to/private/var
however I prefer using the absolute path over the symlink in cases such as this.The use of the
rm
command is inherently dangerous, especially when used with elevated privileges and or wildcards, so to that end make absolutely sure there are no typos in your command line and that the targets are the intended targets. This is why I tested my code before posting it. You can also preface therm
command withecho
, e.gecho rm ...
and then review the output in the Script Editor's Events/Results pane and then removeecho
before saving the script.The image below it to show syntactical highlighting and to see the full command line of the
do shell script
commandIf you're the only user of the computer and you like not to have to type in your password when the Reset FontLab Studio app runs, then modify the
do shell script
command using the following syntax:Example:
Note that when the script's code is saved the value of
user name
andpassword
are saved in readable text within the application bundle's "main.script" binary file. So use this method at your own risk as it is considered to be a security risk storing user names and passwords that are stored in an unencrypted manner.