Ticket #46546

Make yash work with XDG directories

Open Date: 2023-01-19 03:04 Last Update: 2023-01-24 22:06

Reporter:
(Anonymous)
Owner:
Status:
Open [Owner assigned]
Component:
MileStone:
(None)
Priority:
5 - Medium
Severity:
5 - Medium
Resolution:
None
File:
None
Vote
Score: 0
No votes
0.0% (0/0)
0.0% (0/0)

Details

I would like to request a way to make yash work with XDG directories. Examples:

  1. Make it read $XDG_CONFIG_HOME/yashrc, normally ~/.config/yashrc
  2. Make it read $XDG_CONFIG_HOME/yash_profile, normally ~/.config/yash_profile
  3. etc

Ticket History (3/16 Histories)

2023-01-19 03:04 Updated by: None
  • New Ticket "Make yash work with XDG directories" created
2023-01-19 06:50 Updated by: magicant
Comment

Could you show me why XDG support is important for you? Does adding symbolic links not work?

2023-01-19 07:24 Updated by: None
Comment

Reply To magicant

Could you show me why XDG support is important for you? Does adding symbolic links not work?

First of all, the separation between files like histfile, config, profile, cache are needed for a good desktop. Also, with symlinks the $HOME stills get the files, so it defeats the purpose. Another thing is when you do advanced backups, the XDG directories can clearly separate things and make it easier to backup specific files or directories. My last argument is that the specification does not hardcode the paths, so anyone that wants it's files in a different place can get them.And besides being something to add, the spec is not really that big, you can take a look: https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html.

Another person saying the advantages: https://maex.me/2019/12/the-power-of-the-xdg-base-directory-specification/ And another one: https://ploum.net/207-modify-your-application-to-use-xdg-folders/

2023-01-19 07:26 Updated by: None
Comment

The first link is broken, sorry. Here's the real link: https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html

2023-01-21 14:53 Updated by: magicant
  • Details Updated
Comment

My last argument is that the specification does not hardcode the paths, so anyone that wants it's files in a different place can get them.

My understanding is that you can specify paths dynamically with the XDG-prefixed environment variables. When do you define them then? If you define the variables in your yash_profile or yashrc, they will not affect the paths of those files, since the shell has to open the files to read the definitions in the first place.

2023-01-21 18:34 Updated by: None
Comment

Reply To magicant

My last argument is that the specification does not hardcode the paths, so anyone that wants it's files in a different place can get them.

My understanding is that you can specify paths dynamically with the XDG-prefixed environment variables. When do you define them then? If you define the variables in your yash_profile or yashrc, they will not affect the paths of those files, since the shell has to open the files to read the definitions in the first place.

I define them in my /etc/profile, but it can be in /etc/bashrc or any system-wide configuration. But by default, if this is not set, you can fallback for the $HOME/.config/yashrc and $HOME/.config/yash_profile and others. This will make it respects the XDG directories. You can also not implement the fallbacks, but if this variable is set I think is important to respect them.

2023-01-21 22:34 Updated by: magicant
Comment

/etc/profile is not necessarily your file because it is shared among all users on the host. Defining variables in any file under /etc would not make sense since yash does not read them unless explicitly required in ~/.yash_profile or ~/.yashrc.

2023-01-21 22:47 Updated by: None
Comment

Reply To magicant

/etc/profile is not necessarily your file because it is shared among all users on the host. Defining variables in any file under /etc would not make sense since yash does not read them unless explicitly required in ~/.yash_profile or ~/.yashrc.

So, do you have any suggestions to make it declare those variables? Or perhaps just look in the .config folder first instead of using the home?

2023-01-22 13:38 Updated by: magicant
Comment

So, do you have any suggestions to make it declare those variables?

No. Overall, I think the XDG spec is incompatible with the way the shell starts and initializes itself.

Or perhaps just look in the .config folder first instead of using the home?

That would be confusing and unuseful for users who want to use non-default XDG directories.

2023-01-22 22:18 Updated by: None
Comment

Reply To magicant

So, do you have any suggestions to make it declare those variables?

No. Overall, I think the XDG spec is incompatible with the way the shell starts and initializes itself.

Or perhaps just look in the .config folder first instead of using the home?

That would be confusing and unuseful for users who want to use non-default XDG directories.

Why? If the person doesn't want to use XDG, just place on the HOME. You can also set it as a secondary option, just set it to not create one on HOME if the file exists on .config. As for the incompatibility, fish, powershell, elvish, ion, xonsh, nu and others are compatible. Also, there are some optionally compatible like Oh, zsh, bash and others.

2023-01-23 00:54 Updated by: magicant
Comment

users who want to use non-default XDG directories.

If the person doesn't want to use XDG, just place on the HOME.

I'm talking about users who want to specify the location of the XDG directories by defining the XDG-prefixed environment variables so they can use somewhere that is not either ~ or ~/.config. If a user wants to put the init file at ~/.my_config/yash/yashrc, for example, how can yash find it?

just set it to not create one on HOME if the file exists on .config.

Create what? Yash never creates yash_profile or yashrc. It just reads files created by the user.

As for the incompatibility, fish, powershell, elvish, ion, xonsh, nu and others are compatible. Also, there are some optionally compatible like Oh, zsh, bash and others.

I don't see the definition of the compatibility you're talking about. In my understanding, neither bash nor zsh supports the XDG directories.

Fish and powershell seem to support the XDG-prefixed variables, but they need another shell that sets them before startup. I don't think that's the desirable way to initialize the shell.

2023-01-23 01:48 Updated by: None
Comment

Reply To magicant

users who want to use non-default XDG directories.

If the person doesn't want to use XDG, just place on the HOME.

I'm talking about users who want to specify the location of the XDG directories by defining the XDG-prefixed environment variables so they can use somewhere that is not either ~ or ~/.config. If a user wants to put the init file at ~/.my_config/yash/yashrc, for example, how can yash find it?

Maybe a default file for the system or a directory like /etc/profile.d, this would be ideal.

just set it to not create one on HOME if the file exists on .config.

Create what? Yash never creates yash_profile or yashrc. It just reads files created by the user.

Sorry, it just creates .yash_history. Stills, it creates the history file on HOME.

As for the incompatibility, fish, powershell, elvish, ion, xonsh, nu and others are compatible. Also, there are some optionally compatible like Oh, zsh, bash and others.

I don't see the definition of the compatibility you're talking about. In my understanding, neither bash nor zsh supports the XDG directories.

You can set the ZDOTDIR on zsh, I used to set it on my /etc/zshenv. For bash there is a way, this article explains how: https://hiphish.github.io/blog/2020/12/27/making-bash-xdg-compliant/ .

Fish and powershell seem to support the XDG-prefixed variables, but they need another shell that sets them before startup. I don't think that's the desirable way to initialize the shell.

You can read the /etc/profile, read a /etc/yashrc file or source the scripts on /etc/profile.d. Also, fish uses the .config as the configuration and profile, and uses the local/share for history and completions.

2023-01-23 23:06 Updated by: magicant
Comment

Maybe a default file for the system or a directory like /etc/profile.d, this would be ideal.

Yash will never read anything under /etc unless explicitly required by the user. That is necessary to let the user have total control over their configuration. If yash relied on /etc, the user might be forced to use settings installed by the system admin.

I also have to point out that files under /etc are shared among all the users on the system, and that the user may not have permissions to sudoedit them. /etc is not where user-specific settings are meant to be placed.

it creates the history file on HOME.

You can change the history file path by defining $HISTFILE in yashrc.

You can set the ZDOTDIR on zsh, I used to set it on my /etc/zshenv. For bash there is a way, this article explains how: https://hiphish.github.io/blog/2020/12/27/making-bash-xdg-compliant/ . You can read the /etc/profile, read a /etc/yashrc file or source the scripts on /etc/profile.d.

This is not acceptable because it relies on /etc, as I explained above.

2023-01-23 23:28 Updated by: None
Comment

Reply To magicant

Maybe a default file for the system or a directory like /etc/profile.d, this would be ideal.

Yash will never read anything under /etc unless explicitly required by the user. That is necessary to let the user have total control over their configuration. If yash relied on /etc, the user might be forced to use settings installed by the system admin. I also have to point out that files under /etc are shared among all the users on the system, and that the user may not have permissions to sudoedit them. /etc is not where user-specific settings are meant to be placed.

it creates the history file on HOME.

You can change the history file path by defining $HISTFILE in yashrc.

You can set the ZDOTDIR on zsh, I used to set it on my /etc/zshenv. For bash there is a way, this article explains how: https://hiphish.github.io/blog/2020/12/27/making-bash-xdg-compliant/ . You can read the /etc/profile, read a /etc/yashrc file or source the scripts on /etc/profile.d.

This is not acceptable because it relies on /etc, as I explained above.

Ok, I understood about the /etc. But wouldn't yash be able to read ~/.config/yashrc and ~/.config/yash_profile? This could be a beggining.

2023-01-24 21:39 Updated by: magicant
Comment

But wouldn't yash be able to read ~/.config/yashrc and ~/.config/yash_profile? This could be a beggining.

Well... Maybe?

2023-01-24 22:06 Updated by: None
Comment

Reply To magicant

But wouldn't yash be able to read ~/.config/yashrc and ~/.config/yash_profile? This could be a beggining.

Well... Maybe?

I think if yash reads these files, it would be easier for people that are used to the XDG default directories, as well as a cleaner way to manage configs.

Attachment File List

No attachments

Edit

You are not logged in. I you are not logged in, your comment will be treated as an anonymous post. » Login