Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 592
furtypajohn Avatar asked May 23 '12 12:05

furtypajohn


1 Answers

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.

like image 94
n. 1.8e9-where's-my-share m. Avatar answered Sep 27 '22 00:09

n. 1.8e9-where's-my-share m.