tvrzna / emptty

Dead simple CLI Display Manager on TTY
MIT License
696 stars 25 forks source link

Use XDG Base Directory hierarchies #110

Closed Vladimir-csp closed 4 months ago

Vladimir-csp commented 5 months ago

Please consider using ${XDG_DATA_HOME:-"${HOME}/.local/share"}:${XDG_DATA_DIRS:-"/usr/local/share/:/usr/share/"} for searching wayland-sessions and xsessions subdirs, as per XDG Base Directory Specification. This would augment/replace emptty/custom-sessions/ with a more predictable set of places.

tvrzna commented 4 months ago

XDG variables in emptty are mostly handled as fallbacks for software compatibility. I have no intention to rely on XDG variables since emptty was meant for distros, that don't need them too. The plan is to support only those variables, that are necessary for compatibility. Also scanning more directories would be slower on many (non-SSD) devices.

Vladimir-csp commented 4 months ago

But even if those variables are empty or not defined, their spec defaults are valid places to look for session entries. /usr/local/share/wayland-sessions may be used by local admins, ${HOME}/.local/share/wayland-sessions can be used by users. Listing dirs can be pretty cheap even on HDDs, reading files is the main hog.

tvrzna commented 4 months ago

Well, I thought you insist specifically on $XDG_DATA_HOME or $XDG_DATA_DIRS which I've seen in horrible states (more than 50 directories). That's why I was against it; listing multiple folders would be extremely slow. Especially when the desktop files are read during the listing. ${HOME}/.local/share/wayland-sessions and ${HOME}/.local/share/xsessions are small addition and could be easily done.

Vladimir-csp commented 4 months ago

If user has 50 items in $XDG_DATA_DIRS, there's probably something wrong on user's side. Implementing hardcoded paths may not be a good idea since any of those vars can be defined via systemd's environment.d mechanism and be already present for processes launched in user session context. In this case there is a potential for unexpected behavior from user's point of view. In a generic default case only 6 dirs would be listed, most of which would not exist. And in case they do exist and contain overrides, there is no need to even read the same entries higher in the hierarchy.

Vladimir-csp commented 4 months ago

...there seems to be no checks for Hidden/NoDisplay keys. A predictable thing to do to disable an option would be to put an entry with Hidden=true to a lower place of hiearachy, i.e. /usr/local/share/wayland-sessions/ (by a local admin for all local users) or $HOME/.local/share/wayland-sessions/ (by a user).

tvrzna commented 4 months ago

As I mentioned, I'm not planning using XDG vars this way. I can revert previous commit to avoid any potential unexpected behaviour. Hidden and NoDisplay seem nice to be implemented.