<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Fri, Nov 4, 2016 at 1:47 PM, Cecil Westerhof <span dir="ltr"><<a href="mailto:cldwesterhof@gmail.com" target="_blank">cldwesterhof@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">I have a script I want to run as a service which uses:<br>
    xmodmap -pk<br>
I have to define the DISPLAY, so I use:<br>
    export DISPLAY=:0.0<br>
<br>
But this gives:<br>
    export DISPLAY=:0.0<br>
    xmodmap:  unable to open display ':0.0'<br>
<br>
When I try the same with at, I do not have this problem.<br>
<br>
What is happening here and how can I resolve this?<br></blockquote><div><br></div><div>What's happening is that you shouldn't run X11 programs as system services.</div><div><br></div><div>Most of the time, Xlib saying "No protocol specified" means that the X server rejected the connection attempt due to missing authentication details. To fix that, either the program needs the path to your Xauthority file, or the X server needs to be configured to allow all connections by your UID.</div><div><br></div><div>The default location of Xauth information is ~/.Xauthority – if your program cannot find it, either you need to set $HOME, or your display manager (gdm &c.) probably stored it elsewhere and you need to set $XAUTHORITY. Either way, don't run X11 programs as system services.</div><div><br></div><div>Allowing connections by UID might be simpler – run `xauth +SI:localuser:$(id -un)` in your X11 startup script. (The full SI:* syntax is described in Xsecurity(7).)</div><div> </div></div>-- <br><div class="gmail_signature"><div dir="ltr">Mantas Mikulėnas <<a href="mailto:grawity@gmail.com" target="_blank">grawity@gmail.com</a>></div></div>
</div></div>