I have a method that is basically doing the following:
command = 'xkbcomp -i {id} {file} $DISPLAY'.format(id=id, file=self.xkb)
subprocess.Popen(command, shell=True)
When I directly call the method the keyboard map is applied correctly to the device without issue. However when I call the method as the result of a signal ('activate' signal on a gtk MenuItem) the command executes but the map isn't applied and gives no error. I've tried manually specifying $DISPLAY without any change in behaviour.
Turns out it was a bug related to xkbcomp: https://bugs.freedesktop.org/show_bug.cgi?id=91571