Accessing the X Display for Ubuntu GDM login screen [closed]

孤者浪人 提交于 2019-12-07 04:46:46

问题


Overall I am trying to inject key presses into the Ubuntu login screen from a separate shell. I have the machine (running Ubuntu 10.04) at the standard login screen and I am SSH'd into the machine as well. I've tried the following (from the SSH shell):

$ ps ax | grep X
 2844 tty8     Ss+    0:01 /usr/bin/X :0 -br -verbose -auth /var/run/gdm/auth-for-gdm-Gp2Rlq/database
$ export DISPLAY=:0
$ xdotool key Return
No protocol specified
Error: Can't open display: :0
Failed creating new xdo instance

This exact same method works once the machine is logged into Ubuntu, but it does not work for the login screen.

Ideally, I want to be able to finish the login from another shell. I do NOT want to use automatic login. I just want to be able to grab the correct display, and execute the key presses necessary to login.

Any help would be greatly appreciated.

Edited:

Thanks to the tip from n.m. I was able to get this working with:

export DISPLAY=:0
sudo xdotool key Return

This accomplishes what I wanted, but now I am wondering if there is a way to accomplish this without 'sudo'? Is there a flag I can enable/disable to get around this?

Thanks again for the help.


回答1:


You need authority to connect to the display. Note the -auth parameter to the X command. That's where the authority is.

Try this:

export XAUTHORITY=/var/run/gdm/auth-for-gdm-<whatever-it-is>/database 
export DISPLAY=:0 
xdotool key Return

You need to be root to be able to access the authority file.

See man xauth for (a lot) more information.



来源:https://stackoverflow.com/questions/10719987/accessing-the-x-display-for-ubuntu-gdm-login-screen

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!