Skip to content

Fix #2: modernize JACK config search (XDG support)#16

Draft
struktured wants to merge 2 commits intomasterfrom
fix/issue-2-jack-preset-path
Draft

Fix #2: modernize JACK config search (XDG support)#16
struktured wants to merge 2 commits intomasterfrom
fix/issue-2-jack-preset-path

Conversation

@struktured
Copy link
Copy Markdown
Contributor

@struktured struktured commented Apr 25, 2026

Closes #2

Summary

The JACK frontend's read_config() was the oldest of the three backends — C-string manipulation, only checked ~/.projectM/config.inp, no XDG support, and called abort() on common failure paths.

This replaces it with the same Qt-based search used in PipeWire (added in PR #14):

  1. ~/.projectM/config.inp
  2. \$XDG_CONFIG_HOME/projectM/config.inp (defaults to ~/.config per XDG spec)
  3. Copy installed default into XDG location
  4. Fall back to installed default
  5. Return empty string → projectM uses built-in defaults

Changes

  • src/ui-jack/qprojectM-jack.cpp — replace read_config() (-79 lines, +44 lines)
  • src/ui-jack/CMakeLists.txt — remove unused RESOURCE_PREFIX define

Notes on the original issue

The 2021 issue mentions PROJECTM_DATADIR_PATH, which was a libprojectM 2.x build-time variable. In 4.x, preset paths come entirely from Preset Path = ... in config.inp. Honoring XDG means users can override the default config location via \$XDG_CONFIG_HOME, which is the modern equivalent.

Test plan

  • Clean build with -DENABLE_JACK=ON
  • ~/.projectM/config.inp still takes precedence if present
  • Falls back to default config from install prefix when no user config
  • Tested locally end-to-end (run projectM-jack with config in ~/.projectM/, with config in $XDG_CONFIG_HOME/projectM/, and with no user config)

The JACK frontend's read_config() used C-style string manipulation and
only checked ~/.projectM/config.inp before falling back to the install
default. It didn't honor XDG_CONFIG_HOME and didn't gracefully handle
missing default config.

Replace with the Qt-based search pattern used in PR #14 for PipeWire:
  1. ~/.projectM/config.inp
  2. $XDG_CONFIG_HOME/projectM/config.inp (defaults to ~/.config)
  3. Copy default into XDG location
  4. Fall back to install default
  5. Empty string -> built-in defaults (no abort)

Also remove unused RESOURCE_PREFIX compile define.

Closes #2

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@struktured struktured requested a review from Copilot April 25, 2026 14:55
@struktured struktured marked this pull request as draft April 25, 2026 14:55
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Modernizes the JACK frontend’s config discovery to be XDG-aware and aligned with the PipeWire backend’s Qt-based implementation, avoiding legacy C-string handling and abort() paths.

Changes:

  • Replaced read_config() in the JACK frontend with a Qt-based search order including ~/.projectM and $XDG_CONFIG_HOME + fallback copy behavior.
  • Removed the unused RESOURCE_PREFIX compile definition from the JACK target.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
src/ui-jack/qprojectM-jack.cpp Reimplements read_config() with XDG support and safer fallbacks (Qt filesystem APIs).
src/ui-jack/CMakeLists.txt Drops now-unused RESOURCE_PREFIX define after config path logic change.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/ui-jack/qprojectM-jack.cpp Outdated
Comment on lines 39 to 40
#define CONFIG_FILE "/share/projectM/config.inp"

Copy link

Copilot AI Apr 25, 2026

Choose a reason for hiding this comment

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

CONFIG_FILE is already defined in qprojectm_mainwindow.hpp (included above). Redefining it here is redundant and can trigger macro-redefinition warnings (and potentially fail builds that treat warnings as errors). Prefer removing this #define and using the header’s definition, or replace both with a single shared constant in a common header.

Suggested change
#define CONFIG_FILE "/share/projectM/config.inp"

Copilot uses AI. Check for mistakes.
CONFIG_FILE is already defined in qprojectm_mainwindow.hpp which is
included transitively. Defining it again triggers a redefinition
warning that fails -Werror builds.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@struktured struktured self-assigned this Apr 25, 2026
@struktured
Copy link
Copy Markdown
Contributor Author

@copilot review

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.

projectM-jack always searches /usr/share/projectM/presets for presets regardless of PROJECTM_DATADIR_PATH

2 participants