-e / --empty option added #58
Open
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.
This new
-e/--emptyoption allows-k/--keepand-x/--exchangeoptions to operate on empty selections i.e. selections that are empty will not be ignored anymore.So far, when it came to
-kand-xoptions, if both PRIMARY or SECONDARY selections were empty (meaningNULLor""), the program would simply "clear" them i.e. not ask for events associated with them anymore. This default behavior is not changed with this new addition; however, if now-eoption is passed as well, selections that areNULLwill be assigned a newly allocated"", and the program will proceed in the same way as if no selection were an empty string from the very beginning (since X server itself does not make a difference between""and any other non-NULLselection).This is something that may be useful if we want to preserve or exchange PRIMARY and SECONDARY selections on our system continuously, which we may achieve with this command:
sh -c 'while xsel -kn; do :; done'(we letxsel -knbe our condition because it exits with failure immediately when the X session stops i.e. when the user logs out). The problem with that command is, sincexsel -knwill exit immediately with success if both selections are empty, the command will create an insanely resource-consuming loop at startup; this issue may be mitigated in several ways, but the best one of which is this newly added-eoption, which prevents such behavior:while xsel -ken; do :; done. A similar case is easy to imagine in case of-xoption.