Skip to content

Conversation

@jmylchreest
Copy link
Contributor

Summary

  • Re-implements the source= directive for including external config files
  • Adds glob pattern support for matching multiple files
  • Supports tilde expansion and relative paths
  • Includes debug logging for troubleshooting

Background

The source= directive was originally added in PR #267 (commit 6502c87) for v0.7.6, but was lost during the v0.8.0 hyprtoolkit rewrite.

This PR restores that functionality, enabling users to:

  • Split configuration across multiple files (source=~/.config/hypr/hyprpaper.d/wallpapers.conf)
  • Use glob patterns to include multiple files (source=~/.config/hypr/hyprpaper.d/*.conf)
  • Use relative paths resolved against the current config directory

Implementation

The implementation follows the same pattern as the original PR #267 and Hyprland's source= behavior:

  1. Register a handler for source directive in CConfigManager::init()
  2. handleSource() function:
    • Trims whitespace from the value
    • Resolves paths (tilde expansion, relative path resolution)
    • Uses glob() to expand patterns
    • Calls hyprlang->parseFile() for each matched file
  3. Added getCurrentConfigPath() getter for relative path resolution
  4. Debug logging at LOG_DEBUG level (consistent with existing codebase)

Testing

Tested with various configurations:

  • Absolute paths: source=/etc/hyprpaper/themes/dark.conf
  • Tilde paths: source=~/hyprpaper-extras.conf
  • Relative paths: source=./colors.conf
  • Glob patterns: source=~/.config/hypr/hyprpaper.d/*.conf

Fixes: #302

@vaxerski
Copy link
Member

vaxerski commented Jan 2, 2026

can you rebase on main

Re-implements the source= directive for including external config files,
which was originally added in PR hyprwm#267 for v0.7.6 but lost during the
v0.8.0 hyprtoolkit rewrite.

Features:
- Include external config files using source=/path/to/file.conf
- Glob pattern support (e.g., source=~/.config/hypr/hyprpaper.d/*.conf)
- Tilde expansion for home directory paths
- Relative paths resolved relative to the current config file
- Proper error handling and logging for missing/invalid files

This restores parity with Hyprland's source= behavior, enabling modular
configuration management that was lost in the v0.8.0 transition.

Fixes: hyprwm#302
Adds LOG_DEBUG calls to help troubleshoot config include issues:
- Log when source= directive is encountered with resolved path
- Log number of files matched by glob patterns
- Log each file before parsing
- Use Hyprutils::String::trim() instead of manual whitespace trimming
- Use Hyprutils::Utils::CScopeGuard for glob cleanup instead of manual
  globfree() calls
- Remove braces from short single-line if statements per style guide
- Remove duplicate absolutePath(), extend getPath() with optional
  basePath parameter instead

For source= directives, relative paths need to resolve relative to the
config file's directory, not CWD. So `source = ./themes/dark.conf` in
`~/.config/hypr/hyprpaper.conf` resolves to
`~/.config/hypr/themes/dark.conf`, not `$CWD/themes/dark.conf`.
@jmylchreest jmylchreest force-pushed the feat/add-source-config-support branch from de3afe7 to dca6536 Compare January 2, 2026 16:26
@jmylchreest
Copy link
Contributor Author

@vaxerski done.

Copy link
Member

@vaxerski vaxerski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also needs a cf

- Use std::error_code for filesystem calls to avoid exceptions
- Move getCurrentConfigPath() body from header to cpp file
- Apply clang-format
Copy link
Member

@vaxerski vaxerski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks!

@vaxerski vaxerski merged commit 1f8d1fc into hyprwm:main Jan 2, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

source= config directive missing in v0.8.0 (regression from v0.7.6)

2 participants