webpro / dotfiles

Dotfiles for macOS
1.09k stars 231 forks source link

XDG Base Directory Specification $XDG_RUNTIME_DIR #37

Open jmschp opened 2 weeks ago

jmschp commented 2 weeks ago

Hi

First of all thank you for your project. I have learned a lot from it to build my own dot-files.

I am wondering how you manage the XDG_RUNTIME_DIR directory on a MacOS. At system/.env you do export XDG_RUNTIME_DIR="$HOME/.local/runtime # macOS does not have session lifetime directories; alt:~/Library/Caches".

According to XDG Base Directory Specification for $XDG_RUNTIME_DIR:

The lifetime of the directory MUST be bound to the user being logged in. It MUST be created when the user first logs in and if the user fully logs out the directory MUST be removed. If the user logs in more than once they should get pointed to the same directory, and it is mandatory that the directory continues to exist from their first login to their last logout on the system, and not removed in between. Files in the directory MUST not survive reboot or a full logout/login cycle.

How do you manage this lifecycle?

I read this SO answer about a similar behavior in MacOS.

webpro commented 2 weeks ago

First of all thank you for your project. I have learned a lot from it to build my own dot-files.

That's awesome! Great to hear.

How do you manage this lifecycle?

Good question, the short answer is: I don't. Since I'm the only user on my machine I didn't really bother when introducing this. Perhaps at the very least this deserves a warning in the docs and/or during installation.

Maybe, as a single user, it could be mitigated a tiny bit by at least removing the directory after login.

jmschp commented 2 weeks ago

Hey

Still didn't get to a proper solution for this. After Googling a bit and asking AI, it seems creating a LaunchAgent could simulate the behavior in macOS, at least for login. But macOS doesn't have a true "logout" event like Linux systems, some some hack might be needed.

Thanks.