swaylock icon indicating copy to clipboard operation
swaylock copied to clipboard

Exiting with status 2 only if we actually failed to lock

Open mattkae opened this issue 1 year ago • 4 comments

This is a suggested fix for: #346

Because we can distinguish between a failure to lock the screen and a simple request from the compositor to "go away now", we can exit(2) in the former case and exit(0) in the latter.

mattkae avatar Mar 04 '24 22:03 mattkae

I would prefer to keep 0 for "user unlocked" and pick something else for "compositor unlocked".

emersion avatar Mar 04 '24 23:03 emersion

I would prefer to keep 0 for "user unlocked" and pick something else for "compositor unlocked".

This depends on whether or not the compositor telling the lockscreen to go away is an error case. In my opinion, it isn't because the compositor may internally decide that it's time to unlock, which means that it wants to relate that info to the client.

mattkae avatar Mar 05 '24 14:03 mattkae

No, it's a question of the semantics of the exit code. To me, it's a good design to specify that 0 is returned if and only if credentials were successfully verified. No credentials are verified when the compositor decides to close the lock screen.

emersion avatar Mar 05 '24 15:03 emersion

The question is what are the most useful semantics for the exit code. Usually, zero indicates success and non-zero indicates a failure. Being dismissed by the compositor is not an error.

Note that the case that is motivating @mattkae is when the credentials are validated elsewhere, e.g. by the greeter, which notifies the compositor and the compositor notifies the lockscreen (by sending "finished"). In this scenario swaylock indicates an error when no error has occurred.

AlanGriffiths avatar Mar 05 '24 15:03 AlanGriffiths