[systemd-devel] xmodmap gives: No protocol specified

Cecil Westerhof cldwesterhof at gmail.com
Fri Nov 4 14:46:19 UTC 2016


2016-11-04 13:29 GMT+01:00 Mantas Mikulėnas <grawity at gmail.com>:
> On Fri, Nov 4, 2016 at 1:47 PM, Cecil Westerhof <cldwesterhof at gmail.com>
> wrote:
>>
>> I have a script I want to run as a service which uses:
>>     xmodmap -pk
>> I have to define the DISPLAY, so I use:
>>     export DISPLAY=:0.0
>>
>> But this gives:
>>     export DISPLAY=:0.0
>>     xmodmap:  unable to open display ':0.0'
>>
>> When I try the same with at, I do not have this problem.
>>
>> What is happening here and how can I resolve this?
>
>
> What's happening is that you shouldn't run X11 programs as system services.

It worked with xscreensaver:
    https://www.linkedin.com/pulse/saving-netbook-battery-bash-script-cecil-westerhof


> 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.

The strange thing I use the same user with at and systemd. So what is
the difference?
But I also tried setting XAUTHORITY with:
   export XAUTHORITY=~/.Xauthority

With ‘xauth info’ I saw that the authority file is:
    /run/lightdm/cecil/xauthority
but using that in the above statement did not help either.


> 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.

I want to set my own keyboard definitions when they get lost. They
sometimes do. The only way of doing this automatically is in a cronjob
or a systemd service. I would prefer a systemd service. But for the
moment I rewrite the script to be run from cron instead of systemd.

-- 
Cecil Westerhof


More information about the systemd-devel mailing list