swaylock
swaylock copied to clipboard
Exiting with status 2 only if we actually failed to lock
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.
I would prefer to keep 0 for "user unlocked" and pick something else for "compositor unlocked".
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.
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.
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.