Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Access X11 display from empty environment (bash)

Tags:

linux

bash

x11

Greetings!

I am implementing a backup solution, and I need to access the X11 display for getting a password from the user and displaying status information. I have tried setting $DISPLAY in the script to :0.0 (hardcoded), but xhost and misc complain that they cannot open the display. What should I do?

PS: The script is here: http://dpaste.com/109435/

like image 736
jeeger Avatar asked Mar 01 '23 02:03

jeeger


1 Answers

You need the X Authentication information. I do not believe that xhost can "break in" to an X session and allow access without it (you'd need to have the user do it for you) and if you have it, then there is no need to use xhost at all.

Try

export DISPLAY=:0.0
export XAUTHORITY=/home/user/.Xauthority

and then running your commands.

like image 87
Zan Lynx Avatar answered Mar 05 '23 14:03

Zan Lynx