Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEAT] Allow wildcards in 'include' config option #82

Closed
dantefromhell opened this issue Apr 16, 2024 · 6 comments
Closed

[FEAT] Allow wildcards in 'include' config option #82

dantefromhell opened this issue Apr 16, 2024 · 6 comments
Assignees
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@dantefromhell
Copy link
Contributor

Is your feature request related to a problem? Please describe.

As of pyprland 2.2.7 it is not possible to import all files within a specific folder.
The setting

[pyprland]
include = ["~/.config/overrides/pyprland/*.toml"]

yields the following error:

2024-04-15 23:46:37,033 [CRITICAL] pypr :: Config file not found! Please create /home/dante/.config/overrides/pyprland/*.toml :: command.py:105

Describe the solution you'd like

Using the config example above, ideally the following happens every time pyprland is starting or the config is reloaded

  1. The wildcard gets resolved into a list of files
  2. The list of files is sorted alphabetically to ensure consistent configuration file import behaviour.
  3. The config files are imported as per order of the list

Possibly it might be required to replace a single entry in the include list by the resolved list of elements, while keeping the total order. E.g in an example:

[pyprland]
include = ["~/.config/overrides/pyprland/*.toml" , "/tmp/ultimate_override.toml"]

yields the following file list

include = [
  "/home/dante/.config/overrides/pyprland/01_first_file.toml",   
  "/home/dante/.config/overrides/pyprland/02_second_file.toml", 
  "/tmp/ultimate_override.toml"
]

Describe alternatives you've considered

None I can think of.

@dantefromhell dantefromhell added the enhancement New feature or request label Apr 16, 2024
@fdev31
Copy link
Collaborator

fdev31 commented Apr 16, 2024

It may require something like a "glob:" prefix to avoid complexity in case someone has "?" in the filename and don't want to use globbing...
Or something like {globbing: true, path: "/foo/*.toml"} in the list...
Please share your thoughts...

EDIT: I can also try to only support * and not (the more likely in a filename) ? ... but it sounds a bit odd to support one and the other.

@fdev31
Copy link
Collaborator

fdev31 commented Apr 24, 2024

Another idea, maybe the most simple without degrading the feature: ability to pass a folder name, which will be listed searching for .toml files... (sorted alphabetically)

@fdev31 fdev31 added the good first issue Good for newcomers label Apr 29, 2024
@dantefromhell
Copy link
Contributor Author

dantefromhell commented May 3, 2024

Another idea, maybe the most simple without degrading the feature: ability to pass a folder name, which will be listed searching for .toml files... (sorted alphabetically)

That describes the behavior I am looking for well.

in case someone has "?" in the filename

As far as I understand Linux, the ? character in a filename needs to be masked everywhere, including shells as it already has a special meaning.

Are you pointing to the combination of TOML 'literal string' and the python glob: potentially misbehaving?

@fdev31
Copy link
Collaborator

fdev31 commented May 4, 2024

Are you pointing to the combination of TOML 'literal string' and the python glob: potentially misbehaving?

Yes, but not only, it's overall complications with the different escaping of "?" to get it to work as a literal or as a regex, it will generally not be armful but I don't like the idea that much, I think I'll go for the folder solution with sounds the most straightforward.

fdev31 added a commit that referenced this issue May 4, 2024
@fdev31
Copy link
Collaborator

fdev31 commented May 4, 2024

I am using it now, really helps making things easier to organize indeed.

In the main file I have all the most simple plugins defined and listed, plus:

[pyprland]
include = ["~/.config/hypr/pyprland.d"]

Then even plugins can be self-loaded from their own config file, not being in the main plugins array:

image

@fdev31 fdev31 closed this as completed May 4, 2024
@dantefromhell
Copy link
Contributor Author

Awesome, thanks for implementing!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants