You are not logged in.

#1 2015-08-15 05:50:11

Mobiusstrip
Member
Registered: 2015-08-15
Posts: 2

X 11 $DISPLAY not set as root

I'm having a few issues setting up my system because the $DISPLAY variable is not set as root:

- I wrote a script to cycle my wallpaper using feh. It works correctly as the logged-in user. I can only force it to work for root by manually setting "DISPLAY=:0".

- I set that script to run as a cronjob on the user level via cronie. However, when it runs, it gives me the same errors I get when I run it as root. To verify this I edited cronie service file ( /usr/lib/systemd/system/cronie.service ) to execute /usr/bin/kill -n -s (where -s logs output to the systemlog). Every time the cron job comes in I get this output:

Aug 15 01:30:01 mobius crond[2936]: pam_unix(crond:session): session opened for user user by (uid=0)
Aug 15 01:30:01 mobius CROND[2937]: (user) CMD (/usr/local/bin/wallpaper)
Aug 15 01:30:01 mobius CROND[2936]: (user) CMDOUT (feh ERROR: Can't open X display. It *is* running, yeah?)
Aug 15 01:30:01 mobius CROND[2936]: pam_unix(crond:session): session closed for user user

- I can't properly set redshift as a systemd service without access to the display. (I tried such a service as a normal user, but it wouldn't launch on startx even with "WantedBy=graphical.target". I prefer running it as a systemd service to having "exec redshift [options]" in my .xinitrc.) I am not sure if this is related to a bad systemd service file or root not having access to $DISPLAY.

I tried the 2nd posted solution in the above link, which didn't work (probably because my Xauthority iis unrelated to Display being unset). The first solution had no effect and I do not understand why. I've read a number of solution threads where the answer is to put "export DISPLAY=:0" in the bashrc -- I consider this hackish and it wouldn't solve some of my problems anyways. Most of the other solutions I found involved downloading a nvidia package -- I am not sure if I need one since I already have the intel graphics drivers, and I wouldn't understand why this solved my problem if it were to.

What is the best solution(s) to my problems? Am I missing some magic setting that makes everything work?

Thanks for any help.

Offline

#2 2015-08-15 06:02:31

Scimmia
Fellow
Registered: 2012-09-01
Posts: 11,605

Re: X 11 $DISPLAY not set as root

You've obviously read https://wiki.archlinux.org/index.php/Ru … ps_as_root, so what specifically have you tried?

Know that systemd services run in a sanitized environment, so they're a special case.

Last edited by Scimmia (2015-08-15 06:04:30)

Offline

#3 2015-08-15 06:38:01

Mobiusstrip
Member
Registered: 2015-08-15
Posts: 2

Re: X 11 $DISPLAY not set as root

For what it's worth, my service script for redshift has this line:

Environment="DISPLAY=:0"

Does not redshift from being able to find the display.

Currently I've tried:

- Editing /etc/pam.d/su[-1] per the linked arch page

- Exporting user .Xauthority per linked page. No effect.

- "xhost +" run from both user and root. Not permanent. Cronjobs and services still failed.

- "export DISPLAY=:0" in my bashrc. Hackish. Cronjobs and systemd services still failed.

- Changing systemd script to local user service. ( ~.config/systemd/user). Systemd script works but not on boot.

- Moving cronjob to root account. Did not work. Did not expect it to since it fails as normal user with X server permissions.

- Copying /etc/X11/xinitrc to ~/.xinitrc, restoring defaults

I also tinkered around to make sure I had the right intel drivers (xf68-intel and xf86-intel-graphics) for my machine (HP with an i5 core). I've installed and uninstalled a few different desktop managers but have not lost any X server dependencies. All of my X files are in the correct locations.

I would not be surprised if the best solution is putting something in my .xinitrc. But through all the pages I've found none have suggested anything like this.

Offline

Board footer

Powered by FluxBB