Set XKB Options based on current layout?

I’m trying to write a configuration to enable caps:escape only when on a specific layout. I use a laptop, and when its on its docking station is hooked up to a qmk keyboard that I have setup the way I want it. However when the laptop is undocked, I switch my keyboard layout. I would like to only use caps:escape when in one of the two layouts.

I believe most of this is simply done with a simple if/then, but I don’t know how to determine what the current layout is. Is there a currentLayout variable I can use? Or would the easier option be some sort of udev rule and two keyboard modules?

I had a similar issue: I wanted to use a apple wireless keyboard with the ctrl, fn, alt keys in their usual places.

My solution:
The wayland compositor I use (hyprland) allows one to specify kb options on a per-keyboard basis. It is also possible to define an entirely custom keymap via xkb file in which the options (e.g. caps:escape) can be incorporated (example: BENDI/xkb-keyboard-layout-util - Codeberg.org). Qtile and sway also expose a similar configuration interface.

I think someone on the qtile discord solved it on their end by deploying a custom per-user libinput configuration.