Application Templates: How To?

Hey there! I hope I’m in the right place with this. Application template support has been around a little while, but it seems the topic hasn’t really been touched yet. I found only a single example which just changed the splash screen and the view layout. Now I need help figuring out how to do some more advanced changes the right way and I’m looking for some best-practices-tips. I put all my related questions into this thread, so it could serve as a little FAQ on application templates. I’m using Blender 2.79 on Windows (sometimes on Linux).
On https://docs.blender.org/manual/en/dev/advanced/app_templates.html it’s stated that with application templates you could:

  • Customize configuration without disrupting existing settings & installation.
  • Modify and replace parts of the user-interface.
  • Define new menus, key-maps & tools.
  • Define a custom add-on path for template specific add-ons.

My first goal is to strip down the user-interface. Previously you had to change the scripts in C:\Program Files\Blender Foundation\Blender\2.79\scripts\startup\bl_ui</i> (or equivalent in Linux) to hide regions or panels. What’s the best way to do this within an application template?
I thought I’d have to set a custom script path in the userprefs that comes with the application template. But how to I set the path to point to the location of the installed template’s script directory, regardless of the installation location so I could distribute it?
For example, my template was installed to C:\Users\User\AppData\Roaming\Blender Foundation\Blender\2.79\scripts\startup\bl_app_templates_user\myTemplate</i> and it contains an add-ons folder that I’d like to add to the script path. At this time it looks like this:
[LIST=|INDENT=1]

  • myTemplate\

  • add-ons
    [LIST]

  • addons\

  • presets\

  • startup
    [LIST]

  • bl_ui
    [LIST]

  • space_view3d_toolbar.py

[/LIST]
[/LIST]
[/LIST]
[/LIST]

I put the space_view3d_toolbar.py in there in hopes that it might automagically override the default one, but I had no such luck. So my second question is: Is there a way to prevent some interface classes from even registering when blender starts up with an application template, or do I have to unregister the classes from my template’s init.py? Unregistering UI classes I can probably figure out by looking into the code of the fine CatHide addon, which does this at least for the tool shelf. When I used CatHide while my template was registered and switched back to the default, the hidden tabs didn’t turn back on, so I’d probably have to make sure all default classes are getting registered again? But what if someone is actually using e.g. CatHide in her default configuration and doesn’t want the tabs to switch on?

Third question: How can I hide/disable spaces/editors (Node Editor, Time Line, Dope Sheet etc.) with an application template? Remember, my goal is to simplify the user interface, so the unwanted editors shouldn’t show up in the header drop-down. Just like what’s been tried here: https://blenderartists.org/forum/showthread.php?362833-Simplifying-Blender-UI-from-python-addon-hiding-SpaceProperty-panels-other-Spaces

Fourth question: If I distribute addons with my template, should they already be unpacked or should I use bpy.ops.wm.addon_install and pack zip archives? I’m rooting for the first alternative, but maybe I’m wrong. What if an identical addon is already installed in the default configuration? Which one takes precedence? Or will there be collision errors?

I did learn python over the last 3 years, but I’m not yet familiar with the Blender Python API (I did read through https://docs.blender.org/api/current/#blender-python-documentation though). I hope some of you can help me out by pointing me in the right direction and spare me from a whole lot more of trial and error attempts.