Trying to to run xdotool but getting 'Can't open display: (null)'
Asked Answered
I

1

7

I am sorry to reporting this well known error message again.

Nothing works for me. I am running on MacOS Catalina, if it is important.

I installed xdotool with brew on my Mac and try to run

xdotool getmouselocation

The error message that follows is

Error: Can't open display: (null)
Failed creating new xdo instance

I was searching for a solution for a long time, found plenty of answers that said. Run export DISPLAY=:0 and everything is fine. But this didn't work for me.

PS: For better understanding: What does DISPLAY means exactly? It is the monitor of my computer?

Impasse answered 1/12, 2019 at 21:17 Comment(4)
xdotool is an automation tool for the X11 window system. macOS doesn't use X11 - although it can be installed, it is unlikely to give the results you are looking for. This seems like an XY problem - what exactly is the issue you're trying to solve with xdotool?Tenishatenn
See wikipedia, specifically the "Key Terms" section for a good description of what DISPLAY is in X11Tenishatenn
Did you figure out a way?Mardellmarden
I had a similar issue on ubuntu 23.04, this solved it https://mcmap.net/q/1621827/-cron-xdotool-doesn-39-t-runCapreolate
I
8

According to official notice by apple

X11 is no longer included with Mac, but X11 server and client libraries are available from the XQuartz project.

why X11 matters in this case ?

xdotool - command-line X11 automation tool.

So Alongside setting export DISPLAY=:0

install xquartz.

What does DISPLAY means exactly?

according x manual

From the user's perspective, every X server has a display name of the form:

               hostname:displaynumber.screennumber

This information is used by the application to determine how it should connect to the server and which screen it should use by default (on displays with multiple monitors):

  1. hostname The hostname specifies the name of the machine to which the display is physically connected. If the hostname is not given, the most efficient way of communicating to a server on the same machine will be used.

  2. displaynumber The phrase "display" is usually used to refer to collection of monitors that share a common keyboard and pointer (mouse, tablet, etc.). Most workstations tend to only have one keyboard, and therefore, only one display. Larger, multi-user systems, however, frequently have several displays so that more than one person can be doing graphics work at once. To avoid confusion, each display on a machine is assigned a display number (beginning at 0) when the X server for that display is started. The display number must always be given in a display name.

  3. screennumber Some displays share a single keyboard and pointer among two or more monitors. Since each monitor has its own set of windows, each screen is assigned a screen number (beginning at 0) when the X server for that display is started. If the screen number is not given, screen 0 will be used.

there is simpler description found here

A display consists (simplified) of:

  • a keyboard
  • a mouse
  • a screen

i.e. when you connect over ssh you are using different sets of these 3.

Instigate answered 6/12, 2019 at 5:29 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.