You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Played around with swayidle exec in sway config and moved an earlier line commented out above as quick save. I often lock my session manually, so I only noticed a few boots later when talking with a colleague for well over 20 minutes, without being near my desk at all, that my PC was still unlocked. As idle locking definitively worked before with a similar config where that commented line still was part of the exec line, I checked if swayidle even ran, put a quick pgrep -a sway came back empty. Starting the exact same swayidle command manually worked, so it wasn't an issue with the used arguments.
Checking sway -dC made me notice that the whole swayidle line was parsed as comment, I guessed that trailing new line escape through \ was a bit overly eager, and triggered also in commented-out lines. To confirm that I simply added a single # character to the end of the commented-out line and checked sway -dC again, and it was indeed working again:
Anyhow, checking the config parser code I saw that a basic comment check is there for continuation checking in the getline_with_cont function: while (nread >= 2 && strcmp(&(*lineptr)[nread - 2], "\\\n") == 0 && (*lineptr)[0] != '#') {
But it only works if the comment character is the very first one, i.e., no whitespace before.
Now, as comments are also accepted with initial whitespace the question is if that is a by-design limitation to keep the parser simple, or if this should be improved so that it is slightly less surprising.
Possible WIP Fix
One (untested and a bit ugly) possibility may be to directly using the strspn function from strings.h to get the index of the first non-whitespace of the line to check for #, iow., something like:
What do you think? I could prepare a pull-request if above seems OK in general, or adapt it if you'd favor another approach.
If this is desired behavior I'd like to prepare at least a documentation patch, as I did not find any note w.r.t. comments, continuation or their possible interference with each other in man 5 sway.
The text was updated successfully, but these errors were encountered:
Sway Version:
sway version 1.7
Debug Log:
Example snipped that triggered the issue here with a few line extra context:
Played around with swayidle exec in sway config and moved an earlier line commented out above as quick save. I often lock my session manually, so I only noticed a few boots later when talking with a colleague for well over 20 minutes, without being near my desk at all, that my PC was still unlocked. As idle locking definitively worked before with a similar config where that commented line still was part of the exec line, I checked if swayidle even ran, put a quick
pgrep -a sway
came back empty. Starting the exact sameswayidle
command manually worked, so it wasn't an issue with the used arguments.Checking
sway -dC
made me notice that the whole swayidle line was parsed as comment, I guessed that trailing new line escape through\
was a bit overly eager, and triggered also in commented-out lines. To confirm that I simply added a single#
character to the end of the commented-out line and checkedsway -dC
again, and it was indeed working again:Anyhow, checking the config parser code I saw that a basic comment check is there for continuation checking in the
getline_with_cont
function:while (nread >= 2 && strcmp(&(*lineptr)[nread - 2], "\\\n") == 0 && (*lineptr)[0] != '#') {
But it only works if the comment character is the very first one, i.e., no whitespace before.
Now, as comments are also accepted with initial whitespace the question is if that is a by-design limitation to keep the parser simple, or if this should be improved so that it is slightly less surprising.
One (untested and a bit ugly) possibility may be to directly using the
strspn
function from strings.h to get the index of the first non-whitespace of the line to check for#
, iow., something like:What do you think? I could prepare a pull-request if above seems OK in general, or adapt it if you'd favor another approach.
If this is desired behavior I'd like to prepare at least a documentation patch, as I did not find any note w.r.t. comments, continuation or their possible interference with each other in
man 5 sway
.The text was updated successfully, but these errors were encountered: