Xdotool 在 Raspberry Pi 上失败

Min*_*t40 1 linux keystroke simulate raspberry-pi xdotool

我正在我的 Raspberry Pi 上运行 retropie,我想找出一种使用 GPIO 来模拟击键的方法。Xdotool 似乎是我最好的选择,但它不能在本地或通过 ssh 运行。当我输入时,xdotool key 'd'我收到错误:
Error: Can't open display: (null) Failed creating new xdo instance
到目前为止,每个答案都声称要解决这个问题,我必须做一些变体,export DISPLAY=":0" xdotool key 'd'但这并没有做任何事情,它只是转到下一行。我对 linux 很陌生,所以提前致谢。

小智 5

我偶然发现了一个对我有用的答案。只需在命令行中以 Pi 身份运行“xauth”即可告诉我 xauthority 正在使用哪个文件(在本例中为 /home/pi/.Xauthority。)

希望这可以帮助

export XAUTHORITY=/home/pi/.Xauthority; export DISPLAY=:0; xdotool key Return
Run Code Online (Sandbox Code Playgroud)