How to install an add-on from a workspace template init file? How do I make a workspace-template-file execute a script?
In this case I would like to make the Video_Editing template run a script, which will add some buttons to the header.
That is in playback_functions.py which is located in the same folder as init.py
bin\Release\2.91\scripts\startup\bl_app_templates_system\Video_Editing\__init__.py

This is how to init file is looking with the two lines added:
import bpy
from bpy.app.handlers import persistent


@persistent
def load_handler(dummy):
    import os
    from bpy import context
    screen = context.screen
    for area in screen.areas:
        if area.type == 'FILE_BROWSER':
            space = area.spaces.active
            params = space.params
            params.use_filter_folder = True

    filename = os.path.join(os.path.dirname(bpy.data.filepath), &quot;playback_functions.py&quot;)
    exec(compile(open(filename).read(), filename, 'exec'))


def register():
    bpy.app.handlers.load_factory_startup_post.append(load_handler)


def unregister():
    bpy.app.handlers.load_factory_startup_post.remove(load_handler)

playback_functions.py:
https://pasteall.org/Of5O
EDIT:
This works for getting the template installing add-ons, but only when running the script in the Text Editor, and not run as template, so do I do this?
# ##### BEGIN GPL LICENSE BLOCK #####
#
#  This program is free software; you can redistribute it and/or
#  modify it under the terms of the GNU General Public License
#  as published by the Free Software Foundation; either version 2
#  of the License, or (at your option) any later version.
#
#  This program is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU General Public License for more details.
#
#  You should have received a copy of the GNU General Public License
#  along with this program; if not, write to the Free Software Foundation,
#  Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# ##### END GPL LICENSE BLOCK #####

import bpy
from bpy.app.handlers import persistent
import os

@persistent
def load_handler(dummy):
    #import os
    from bpy import context
    screen = context.screen
    for area in screen.areas:
        if area.type == 'FILE_BROWSER':
            space = area.spaces.active
            params = space.params
            params.use_filter_folder = True

    path_to_script_dir = bpy.app.binary_path.replace('blender.exe','')+&quot;/2.91/scripts/startup/bl_app_templates_system/Script_Editing&quot;
    file_list = sorted(os.listdir(path_to_script_dir))

    script_list =[]
    for item in file_list:
        if item.endswith('.zip'):
            script_list.append(item)

    for file in file_list:
        path_to_file = os.path.join(path_to_script_dir, item)
        bpy.ops.preferences.addon_install(overwrite=True, target='DEFAULT', filepath=path_to_file, filter_folder=True, filter_python=False, filter_glob=&quot;*.py;*.zip&quot;)

    enableTheseAddons = ['textension', 'code_editor']

    for string in enableTheseAddons:
        name = enableTheseAddons
        bpy.ops.preferences.addon_enable(module = string)


def register():
    bpy.app.handlers.load_factory_startup_post.append(load_handler)


def unregister():
    bpy.app.handlers.load_factory_startup_post.remove(load_handler)


if __name__ == &quot;__main__&quot;:
    register() 

Updated template folder: Script_Editing.zip (212.1 KB)
This folder should be unzipped and placed in bin\Release\2.91\scripts\startup\bl_app_templates_system\
The init.py file inside the template folder will only be loaded when the user is selecting File - Defaults - Load Factory Settings, and not the the workspace template is selected at start up.
The process is shown in this video tutorial:
https://www.youtube.com/watch?v=ufSyony6eRE