I am trying to use a script, nvidia-fan-controller, to control the GPU temperature on my system (Arch Linux). This works perfectly, except when I try run through systemd, I get the error

nvidia-settings control display is undefined

After some investigation, it seems like the issue comes from the .Xauthority file used in the service. nvidia-settings, used by the script, depends on the .Xauthority file, but also needs root permissions to change the fan speed. Is there any way to give root an .Xauthority file that can be accessed through systemd? The service currently points at this file for the sysadmin user I used to install the service, and consequently does not run when any other user is logged in.

I have tried creating a user service, but this does not work as the command must be run as root.

  • run the command with sudo to enable it to be ran as root. Dec 24, 2022 at 14:15

2 Answers 2


I am currently dealing with the similar issue on same distro, I found this section on arch wiki: https://wiki.archlinux.org/title/Systemd/User#DISPLAY_and_XAUTHORITY

I didn't quite understand it and how to utilize that script, but rather used this command:

systemctl --user show-environment

To list env variables and added DISPLAY and XAUTHORITY to service as such:

Description=GPU fan speed controller service


If somebody knows a cleaner way to achieve this please let me know :)

  • This was also very useful to set AllowVRR option too
    – Emanuele
    Apr 28, 2023 at 21:46

Hrvoje R. solution is correct.

I usually export those vars from within the script executed by the systemd service.

    export XAUTHORITY=/run/user/1000/gdm/Xauthority
    export DISPLAY=:1

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .