从 python 脚本调用 xkbcomp,通过信号调用时应用失败

Calling xkbcomp from python script, fails to apply when called via signal

我有一个方法,基本上是执行以下操作:

command = 'xkbcomp -i {id} {file} $DISPLAY'.format(id=id, file=self.xkb)
subprocess.Popen(command, shell=True)

当我直接调用该方法时,键盘映射正确地应用于设备,没有问题。但是,当我作为信号(gtk MenuItem 上的 'activate' 信号)的结果调用该方法时,命令执行但未应用地图并且没有给出错误。我试过手动指定 $DISPLAY 而没有任何行为改变。

原来这是一个与 xkbcomp 相关的错误:https://bugs.freedesktop.org/show_bug.cgi?id=91571