I'm not sure it is possible. It seems that the mode line is updated only when its window is selected (testing using calls to
message bears this out). And the code that does this is C code, not Lisp.
You can use a conditional expression in the definition of
mode-line-buffer-identification, so that the face to use is computed dynamically. But I don't know of any function or variable that you can use to test whether a given window has an inactive mode-line.
You cannot use
selected-window, for example, because that always points to the window with the active mode-line.
Here is an example of dynamic updating that is based on the buffer name. It is not what you want, but it at least shows you what you can do. If you can come up with a way to test whether the window being updated is selected then you could substitute that for the buffer-name test. (But my impression is that only the selected window gets its mode-line updated.)
(list (propertize "%b"
'face (if ;; NOPE (eq (selected-window) (get-buffer-window (current-buffer)))
(eq (current-buffer) (get-buffer "some-buffer"))
'help-echo "Buffer name mouse-1: Previous buffer\nmouse-3: Next buffer"
Another thing you might try is advising function
format-mode-line. It does apparently distinguish a window with an active mode-line from one with an inactive mode-line. But it too is coded in C, so I doubt you will get very far with advising it. It tests C variable
I'd suggest asking this question on one of the Emacs mailing lists (e.g.
firstname.lastname@example.org), if you don't get a satisfactory answer here. Seems like it could be good to be able to do what you request. +1 for the question, in any case.