How to modify the default keymap at Add-on registration time?

I have put the question together already over on Blender StackExchange, but maybe someone here can give me a hint too:

I’m trying to deactivate a hotkey from the Default Keymap. While there is ways to do this during runtime, I cannot access the keymap item bpy.context.window_manager.keyconfigs.default.keymaps['3D View'].keymap_items.get('view3d.move') in the register() function of my Add-on when Blender loads. That is, when the user has enabled my Add-on, and saved the Startup file, the next time Blender opens my keymap access code fails because keymap_items is an empty list.

Any ideas / gotchas?

What is your use case for this? Without knowing more context, it’s hard for us to put us in your shoes and come up with a suitable solution.

The above code is just an example of course. In general I sometimes run into situations where I’d like to deactivate or change keymap items that users accidentally press when learning Blender, especially when coming from other software packages. So my initial take was to utilize an Add-on that can be loaded at startup time and does this for every user. If users prefer Blender as is, they simply don’t use said Add-on.

I propably have to re-check the situation with the Template system. There was a bug that prevented templates from being found when using the BLENDER_USER_XXX environment variables, and I use them for the server side distribution of Blender in our company. But I recall Campbell had mentioned a fix in that area, maybe this could now be a valid path to go for me.

Yup, that’s what I was thinking too. This is exactly the kind of thing the template system was made for. Not saying that it works 100%, just that it was aimed to work for this :wink: