What's the right place to set the XAUTHORITY environment variable?

9,504

It seems as if LightDM was interfering with the XAUTHORITY environment variable by setting its own value.

While I didn't manage to find a way to prevent this, I was able to achieve my goal by adding

[LightDM]
user-authority-in-system-dir=true

to /etc/lightdm/lightdm.conf.

After this, the environment variable has changed its value

$ echo $XAUTHORITY 
/var/run/lightdm/user/xauthority

which solves the original problem of getting rid of $HOME/.Xauthority.

Share:
9,504

Related videos on Youtube

soc
Author by

soc

Updated on September 18, 2022

Comments

  • soc
    soc over 1 year

    I'm trying to get rid of the .Xauthority file in my home directory.

    The arch wiki suggests defining

    export XAUTHORITY="$XDG_RUNTIME_DIR"/Xauthority

    but neither placing this line in .profile nor adding

    XAUTHORITY DEFAULT=${XDG_RUNTIME_DIR}/Xauthority

    to .pam_environment does the trick:

    • Using .profile, logging in stops working and I'm returned to the login screen.
    • Using .pam_environment, the env var doesn't seem to be set, as echo $XAUTHORITY returns /home/user/.Xauthority.

    Note that ICEAUTHORITY DEFAULT=${XDG_RUNTIME_DIR}/ICEauthority works as expected.

    • steeldriver
      steeldriver over 6 years
      What display manager are you using? I don't think setting XAUTHORITY to something different on the user side is going to help unless you also persuade your DM to actually write the file there - see for example change location of $HOME/.Xauthority
    • Panther
      Panther over 6 years
      Why are you trying to move .Xauthority at all ?
    • soc
      soc over 6 years
      @steeldriver: I did the same for .ICEauthority and it worked perfectly. I'm using LightDM as my display manager.
    • soc
      soc over 6 years
      @bodhi.zazen: I'm tired of applications using $HOME as a dumping ground for their private application data and I want to make $HOME read-only. This is not possible as the .Xauthority is currently written to $HOME. Fixing this, I can finally make $HOME read-only.
    • Panther
      Panther over 6 years
      LOL !!! That is not what home is for, but alright. You just need to make some other system directory rw for data and what not, spinning your wheels a bit IMO =)
    • soc
      soc over 6 years
      @bodhi.zazen: I'm not sure I'm understanding your comment correctly, but there are standards where files need to be placed, and I want applications to follow them, not dump files into $HOME.
    • Panther
      Panther over 6 years
      The standard is for users settings , documents, music, pictures, etc to be placed in $HOME, which is where they default to. What standards are you looking at that it should be otherwise ? And even if you move them to $some_other_location the effect is the same. all the .config or .cache or documents or pictures need to be rw by the $USER in question so, IMO, best keep them all in one place, as they should be, in $HOME then when you need to back up user data you just back up $HOME.
    • Panther
      Panther over 6 years
      Your method is sort of a long run for a short slide, users will still have the same access to .Xauthority regardless of location. Perhaps is better to configure bothersome apps to not save data or clean $HOME from time to time.
    • soc
      soc over 6 years
      @bodhi.zazen I'm not sure what you are trying to argue. I am keeping all my files in subdirectories of $HOME. Only $HOME is read-only, not its contents. The accessibility of .Xauthority itself is also not the issue at hand.