Fix kanshi compatibility by using output names instead of descriptions#2
Fix kanshi compatibility by using output names instead of descriptions#2zipproth wants to merge 3 commits intopetertheprocess:masterfrom
Conversation
Kanshi fails to match profiles when output descriptions contain parentheses like 'Iiyama North America PL2294H2 1207823601758 (DP-3)'. According to kanshi(5) manual, valid output criteria are: - Output names (e.g. 'DP-1') - Manufacturer/Model/Serial without parentheses This changes store.c to use head->name (e.g. 'DP-3') instead of head->description, making kanshi profiles work correctly. Fixes 'no profile matched' error when kanshi tries to apply configurations.
The match() function was still using the old quoted output syntax
("output \"%99[^\"]\"" pattern) which fails to match profiles
written with the new unquoted syntax (output DP-3).
This caused duplicate profiles to be created instead of updating
existing ones. Now supports both quoted (legacy) and unquoted
(current) output formats for backward compatibility.
|
which kanshi & sway version are u using?
Parts of my config are like that, it work and quite stable for me. I have multiple ports and different monitors in office/home/university, you solution tried all different monitors pluged into DP-1 as the same one, which is not a good idea in my opinion. |
|
@petertheprocess Thanks for the response! Your configuration works perfectly because you're using the legacy quoted format that the original matching logic supports. The core issue: There's a mismatch between what wdisplays writes vs what it can read. Currently:
This causes the matching to fail, creating duplicate profiles instead of updating existing ones. What my PR does:
Why this aligns with kanshi spec:
The current implementation writes invalid hybrid format: Your concern about port ambiguity is valid, but using port names ( The change improves robustness while maintaining full backward compatibility with your existing setup. Would you like me to clarify any part of the implementation? |
|
@zipproth Thanks for your explaination, now I understand the issue. I did some search and find it is caused by that: I would like to create a PR for kanshi to make it compatible with legacy quoted format instead of only recording the port name, but you are right your solution is more stable. Anyway, I will look into it more in detail when I have time. |
|
While investigating the consequences of choosing either port name or display serial, I ran into an other related issue: Modern kanshi syntax can be more complex and the parser from store.c will crash if the syntax is a bit more complex than a list of output profiles, eg: I believe the long-term solution would be to use the same parser as kanshi : https://codeberg.org/emersion/libscfg An other (complementary) solution would be to always create our kanshi config file separate from the main config file and use the With the current implementation, we can already have wdisplays write to a separate file just by setting an environment variable. IMHO it would be better to save profiles from wdisplays using display names rather than output names to allow user-defined generic profiles based on output names without risking erasing them. |
|
@petertheprocess and @JasonGantner I've updated this PR by merging the latest master into my branch 'fix-kanshi-output-names' to resolve some conflicts and keep it current. Additionally, I created a separate branch 'rebase-for-jason' rebased on @JasonGantner's 'v1.2.0-work' to address his merge request in JasonGantner#4 (see my comment there for details). Regarding @JasonGantner's suggestions: I agree that using libscfg for a more robust parser would be a great long-term solution to handle complex kanshi syntax (e.g., aliases). Also, saving profiles in a separate file with 'include' is a good idea to avoid interference – the current env variable support already enables this partially. If there's interest, we could discuss integrating that next. Let me know if this merge looks good or if further adjustments are needed! Best, |
Fix kanshi compatibility by using output names instead of descriptions
Problem
The current implementation writes kanshi configurations using output descriptions like:
This causes kanshi to fail with "no profile matched" because the parentheses in the description make it invalid according to kanshi's parsing rules.
Solution
This PR changes
src/store.cto usehead->name(e.g.DP-3) instead ofhead->description, generating valid kanshi configurations like:Technical Details
According to
kanshi(5)manual, valid output criteria are:The current output descriptions containing parentheses like
(DP-3)don't match either format.Testing
Before fix:
kanshishows "no profile matched"After fix:
kanshishows "applying profile" and works correctlyThis resolves the core compatibility issue that prevents the kanshi integration from working.