hyprland-community/pyprland

[FEAT] Allow wildcards in 'include' config option

dantefromhell opened this issue · 6 comments

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.

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.

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)

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?

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.

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

Awesome, thanks for implementing!