How can I change the 3D View's background color to something different for each mode?

I am wondering if there is a way that I can change the background color and possibly the color of other elements slightly, for each mode (Object, Edit, Sculpt, Vertex, Weight, Texture) so that it is easier to tell visually which mode I am in aside from the mode selector as an indicator.

Could it be done with some python scripting? Is there an add-on out there that would do it?

Example: Object Mode = slight blue background, Edit Mode = slight green background, etc.

• I am mostly sure that this is not possible, but at a longer thought I think it is a great idea. Try maybe posting it here: blender.community/c/rightclickselect – cgslav Feb 10 '18 at 9:25
• I'm pretty hopeful it's doable with python. – Haunt_House Feb 10 '18 at 11:55

Set World Background on and run this script via Blender text editor.

import bpy

Modes = {'OBJECT':(1, 0, 0),
'EDIT':(0, 1, 0),
'SCULPT':(0, 0, 1),
'VERTEX_PAINT':(1, 1, 0),
'WEIGHT_PAINT':(1, 0, 1),
'TEXTURE_PAINT':(0, 1, 1)}

def my_handler(scene):
mode = bpy.context.object.mode
scene.world.horizon_color = Modes[mode]

def register():
bpy.app.handlers.scene_update_post.append(my_handler)

def unregister():
bpy.app.handlers.scene_update_post.remove(my_handler)

if __name__ == "__main__":
register()

• I don't understand what you mean by "Set World Background on". Isn't it enabled by default? When I go into the World tab>Surface>Surface it is set to background and has a color. I ran the script but nothing changed. – Bryson Jack Feb 12 '18 at 22:55
• Okay, I was able to get your script to work if Viewport Shading mode is set to rendered. How difficult would it be to modify that script to alter the theme background color based on the different modes? – Bryson Jack Feb 13 '18 at 23:04
• Thanks for explaining that. I appreciate you offering a working solution. I can get it to work with factory settings but in my startup file it doesn't work. Some add-on must be interfering with the script. I guess I am still looking for a solution. – Bryson Jack Feb 22 '18 at 19:51
• How would one get the script to also enable Paper Sky and Blend Sky? Also, how would one get the script to load on startup? – Bryson Jack Feb 22 '18 at 20:43