I recommend that instead of your approach, combine all the scripts into one and debug first without the participation of launchd, in the editor. Also, after the execution of each specific task, enter a check that it has completely completed.
For example, a web page takes a long time to load, so a time delay loop is needed until the page is fully loaded. Every task takes time, especially when you open so many apps.
on the line preceding your code. The problem persists. I have removed this line.
Seeing how the code does change the Snap to Grid setting, as I desire it, we can turn this lemon into lemonade.
The script problem occurs, only when the desktop Snap to Grid setting is false. Therefore, I will observe the problem rarely. If the script problem does occur, then, that will indicate that the Snap to Grid setting became false, without my having done so, and, your script just set it to true. This script problem will serve to notify me that the setting changed.
This will prompt me to check on Icon Size, Grid Spacing, Text Size, in the event that their value settings changed, as well.
I modified your script above in post 7, so it wonāt restart finder if it doesnāt change the āarrangementā
tell application "Finder"
if (arrangement of icon view options of window of desktop) is not snap to grid then
set arrangement of icon view options of window of desktop to snap to grid
quit
repeat while running
delay 0.2
end repeat
activate
end if
end tell
Yes, I noticed this earlier and corrected it. See posts above. There is another fix. But still, @kurt has some other problems that I find it difficult to fix from a distance.
Iāll repeat here the final one, which I think is the best option, because it also saves all open windows in the Finder and other applications:
.
tell application "Finder"
if arrangement of icon view options of container window of desktop is not snap to grid then
set arrangement of icon view options of container window of desktop to snap to grid
tell scripting additions to do shell script "killall 'Finder'"
end if
end tell
You might want to try my sweeping solution for creating your own grid and automatically snapping your icons to it. Iāve checked the solution recently and it does appear to be usable, although it requires a couple of ancillary packages (Pashua and PrefsStorageLib). It also can pose some interesting issues with sandboxing that require careful attention to granting accessibility (assistive access). Iād be interested to know if you have any luck with it, if you give it a shot (Iāll certainly try to help).