Add support to ignore the clipboard in certain windows#89
Conversation
The clipboard does not get recorded when the title of the currenlty active window matches the regular expression in CM_IGNORE_WINDOW. This allows copying passwords from a password manager without the passwords ending up in clipmenu. The matching is not 100% exact however, as there is a race condition bewteen the time the clipboard is populated, clipmenu queries the clipboard, and the active window gets queried. This race condition can be especially problematic when using polling with large intervals instead of clipnotify.
|
Maybe the dependency on xdotool should be documented somewhere in the README or help text, as well as the race condition. |
| fi | ||
|
|
||
| windowname="$(xdotool getactivewindow getwindowname)" | ||
| if [[ -n "${CM_IGNORE_WINDOW+x}" && "$windowname" =~ $CM_IGNORE_WINDOW ]]; then |
There was a problem hiding this comment.
I wanted to distinguish between CM_IGNORE_WINDOW being unset and CM_IGNORE_WINDOW being set to the empty string, so I used the approach from https://stackoverflow.com/questions/3601515/how-to-check-if-a-variable-is-set-in-bash (I thought the empty string would match the empty string and not be treated as a wildcard, so it would be helpful to include). I'll update the code
| fi | ||
| fi | ||
|
|
||
| windowname="$(xdotool getactivewindow getwindowname)" |
There was a problem hiding this comment.
This should only be executed if we actually have anything to check
|
Looks generally sane, just a few things to change. Please do also add some code which disables this if it's set and |
|
With your hcanges it looks fine, although I see no way to accept your changes here and amend the commit, so you'll need to rebase your changes onto your existing commit locally probably. Travis failure looks like it should be fixed by these changes. |
|
Thanks! Just waiting for CI. |
|
Do you want me to squash all the commits into one? |
|
No worries, I can squash them on merge. |
|
Thanks! Merged and will go into next release. |
|
Thank you for the great review! |
The clipboard does not get recorded when the title of the currenlty active
window matches the regular expression in CM_IGNORE_WINDOW. This allows copying
passwords from a password manager without the passwords ending up in clipmenu.
The matching is not 100% exact however, as there is a race condition bewteen the
time the clipboard is populated, clipmenu queries the clipboard, and the active
window gets queried. This race condition can be especially problematic when
using polling with large intervals instead of clipnotify.
This implements #86.