Unable to open X server

I try to take a screenshot of a firefox window in my terminal, but I get an error all the time:

root@host [~]# DISPLAY=:1 firefox http://www.cnn.com & sleep 5 && DISPLAY=:1 import -window root -crop 1264x948+0+25 -quality 90 /usr/local/apache/htdocs/screenshot1.jpg && pkill firefox
[1] 30200
import: unable to open X server `:1' @ import.c/ImportImageCommand/364.

Why is this happening? How can i fix this?

+5
source share
3 answers

Maybe try DISPLAY=:0for example?

+4
source

It looks like you used root substitution in the terminal after it started (or did you log in to X as root?). If in this case the display cannot be opened because it belongs to another user and you cannot just go and show what someone else is showing.

, , , . , , "man xhost".

0

Can you tell us what the result is as you type

ls -la /tmp/ | grep X

and

ps | grep X

Also, I had some problems using the DISPLAY =: 1 syntax, so instead I use:

firefox --display=:1 URL_OF_SITE
import -display :1 -window root etc...
0
source

All Articles