On Screen Display Xray mode
Make some visual overlay
Could not help but see the link between this and Bug in addon to Change header color dynamically  The addon there was to remind user they are in automatic keyframe mode.
Remember at the time thinking would make an interesting addon if given a generic way to link a property toggle with toggling a setting.  However have not returned until now
Similarly an edit to change the behaviour to instead change the bg color of the 3d view if in xray mode.
Consider this a &quot;proof of concept&quot; test script, a more subtle indicator could be used.
paste into text editor click run script.
import blf
import bpy

bl_info = {
    &quot;name&quot;: &quot;New Object&quot;,
    &quot;author&quot;: &quot;Your Name Here&quot;,
    &quot;version&quot;: (1, 0),
    &quot;blender&quot;: (2, 80, 0),
    &quot;location&quot;: &quot;View3D &gt; Add &gt; Mesh &gt; New Object&quot;,
    &quot;description&quot;: &quot;Adds a new Mesh Object&quot;,
    &quot;warning&quot;: &quot;&quot;,
    &quot;wiki_url&quot;: &quot;&quot;,
    &quot;category&quot;: &quot;Add Mesh&quot;,
}

highlight_color = (0.4, 0, 0)

class DrawingClass:
    def __init__(self, prop):
        from bpy import context
        self.prop = prop
        self.col = context.preferences.themes[0].view_3d.space.gradients.high_gradient[:] 
        self.handle = bpy.types.SpaceView3D.draw_handler_add(
            self.draw_text_callback, (), 'WINDOW', 'POST_PIXEL')

    def draw_text_callback(self):
        from bpy import context
        font_id = 0  # XXX, need to find out how best to get this.
        if not hasattr(context, &quot;scene&quot;):
            return None
        shading = context.space_data.shading
        if shading.show_xray:
            context.preferences.themes[0].view_3d.space.gradients.high_gradient = highlight_color
            # draw some text
            blf.position(font_id, 18, 50, 0)
            blf.size(font_id, 50, 72)
            blf.draw(font_id, f&quot;{self.prop}&quot;)

        else:
            context.preferences.themes[0].view_3d.space.gradients.high_gradient = self.col

    def remove_handle(self):
        from bpy import context
        context.preferences.themes[0].view_3d.space.gradients.high_gradient = self.col
        bpy.types.SpaceView3D.draw_handler_remove(self.handle, 'WINDOW')


dc = None


def register():
    global dc
    dc = DrawingClass(&quot;XRay Mode&quot;)

def unregister():
    global dc
    if dc:
        dc.remove_handle()
        dc = None

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

Leads to more questions.
An issue could be since a draw handler is defined for type,  could be an issue with syncing  when more than 1 view 3d is being drawn on the screen. Also setting the theme bg color  of the viewport is blend file wide.

A quick test confirmed my fears. Notice the text is correct but the theme bg color is not.
What is interesting is having what is like two themes active at once