fix: handle nirilayout.kdl as a regular file (noctalia 5)#2
Open
Piero-93 wants to merge 1 commit into
Open
Conversation
noctalia 5 writes ~/.config/niri/nirilayout.kdl as a regular file instead of a symlink to the active layout. os.Readlink then fails with EINVAL, which was only handled for ErrNotExist, so the error was treated as fatal: the FlowBox was never created while the layout loop still ran, dereferencing a nil selector and crashing with a nil pointer at Run. Detect the active layout via a new CurrentLayoutPath helper, which resolves the symlink when present (classic setup) and otherwise matches the file's contents against the known layouts (noctalia 5). Current-layout preselection now works in both setups, with no command-line flag needed. Also stop treating current-layout detection as fatal, and guard the layout loop against a nil selector.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
fix: crash on startup when nirilayout.kdl is a regular file (noctalia 5)
Problem
nirilayout crashes on startup with a nil pointer dereference for users on
noctalia 5:
noctalia 5 writes
~/.config/niri/nirilayout.kdlas a regular file(a copy of the active layout) instead of a symlink to it.
os.Readlinkthen fails with
EINVAL, but onlyfs.ErrNotExistwas handled, so the errorwas propagated as fatal to
Run. TheFlowBoxwas never created (selectorstayed nil) while the layout loop still ran, dereferencing the nil selector.
Fix
CurrentLayoutPath, which resolves the symlink when present (classicsetup) and otherwise matches the file's contents against the known layout
files (noctalia 5). Active-layout preselection now works in both setups,
with no command-line flag.
which layout is preselected).
selectoras defense in depth.Testing
go build ./...andgo test ./...pass.nirilayout.kdl; therebuilt binary no longer crashes and shows the layout list.
regular-file
nirilayout.kdl.