Script to change background color upon mode


I’ve “developed” a script to change background color depending on what mode I’m working with. I.E: gray when object mode, red-ish when edit mode… I don’t what to move eyes to know what mode I’m currently working… you know :slight_smile:

It’s a very primitive script, and I do know it’s causing some caos with other add-ons, but it’s my script and I like it.

Since sharing is caring, and I do know this board is full of people talented with these endeavours, I´d like to sharing it here to hear some suggestions and mods, and, why not, lets put this elsewhere to a broad audience if someone wants to give it a try, or just make its own… whatever! This script is serving me well since 2.80, and I found it a vital part of my daily work. I only want this bloody thing works better! (i.e. have a proper color picker at preferences) DISCLAIMER: I’ve almost ZERO idea on python coding. I do know the basics of programming, but nothing more, right? don’t roast me :smiley:

bl_info = {
    "name": "Active Background",
    "author": "Dspazio",
    "version": (1, 0),
    "blender": (2, 80, 0),
    "location": "View3D",
    "description": "Changes background gradient color for each mode.",
    "warning": "",
    "doc_url": "",
    "category": "Themes",

import bpy
from import persistent

Modes = {'OBJECT':(0.30, 0.30, 0.30),
        'EDIT':(0.30, 0.20, 0.20),
        'SCULPT':(0.05, 0.05, 0.05),
        'VERTEX_PAINT':(0.05, 0.05, 0.05),
        'WEIGHT_PAINT':(0.05, 0.05, 0.05),
        'TEXTURE_PAINT':(0.05, 0.05, 0.05)}

def my_handler(scene):
    mode = bpy.context.object.mode
    bpy.context.preferences.themes[0] = Modes[mode]
class addActiveBackgroundPreferences(bpy.types.AddonPreferences):
      bl_idname = __name__
      edit_mode_color: bpy.props.FloatVectorProperty(name="Edit Mode Color", subtype='COLOR', default=Modes['EDIT'], size=3, min=0, max=1)
      def draw(self, context):
          layout = self.layout
          layout.label(text='Edit Mode :')
          row = layout.row()
          row.prop(self, 'edit_mode_color', expand=True)
def register():

def unregister():

if __name__ == "__main__":