12

I want to use xdotool via SSH but get the following error:

Error: Can't open display: (default)

I found this solution:

export DISPLAY='0:0'

Still get nearly the same error :(. I also tried:

export DISPLAY=:0; or: export DISPLAY="0:0", ...

Always a error like that:

Error: Can't open display: (0:0)

Is thera a alternative (working) solution for xdotool?

I don' know whether It work lokal. I've only got a SSH-connection.

Franklin84
  • 463
  • 1
  • 6
  • 20
  • How is SSH involved here? Are you trying to use SSH's X forwarding feature? How did you run ssh to log into the server where you're trying to run xdotool? – Kenster Jun 28 '14 at 17:21

3 Answers3

10
export DISPLAY=:0.0 && xdotool key a

Try this =)

funivan
  • 3,323
  • 1
  • 14
  • 19
5

You did the right thing export DISPLAY='0:0'
But you should also set XAUTHORITY like this:
export XAUTHORITY="/home/username/.Xauthority"

Ofcourse the username is an account which has logged in via gnome.

Don't forget to change username with your right account name.

Arash
  • 400
  • 4
  • 11
  • 1
    [This](https://stackoverflow.com/a/26841554/2777965) answer worked. Perhaps you could mark it as accepted. – 030 Dec 17 '18 at 18:21
-2

I have found a useful link for this problem please refer the below post Accessing the X Display for Ubuntu GDM login screen

It says

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

try with

export XAUTHORITY=/var/run/gdm/auth-for-gdm-[whatever-it-is]/database

Hope it helps

Community
  • 1
  • 1
Hope
  • 1
  • 1