Commit graph

134 commits

Author SHA1 Message Date
Navneet Aman 607a2f1127
Back off if clipnotify fails
This probably means the X server is gone, so avoid spinning uselessly.
2022-04-14 16:17:22 +01:00
Chris Down b30c01dbe3 clipmenud: Touch cache file at startup
May fix #182.
2022-03-15 18:50:47 +00:00
Matthew White bc35b6f44a clipmenud: Fix killing background jobs when there are multiple
`jobs -p' should be read into an array, as it might contain more than
one job.

[cdown: squash, massage changelog, remove space between local/readarray]
2021-11-21 12:24:25 +00:00
Matthew White 775adccfb4 clipmenud: print message when disabling but already disabled
Print a specific message when receiving a disable signal but already
disabled, as it's done for when enabling but already enabled.
2021-11-21 00:33:18 +00:00
Matthew White 5c53e5f1cd clipmenud: prevent another clipnotify job when trapping a signal
Since trapping a signal breaks `wait $_CM_CLIPNOTIFY_PID` w/o killing
the clipnotify job, call kill_background_jobs before restarting the
loop.  This prevents `clipctl enable` from spawning another job.
2021-11-21 00:33:18 +00:00
Axel Dahlberg a3f0897aee Create status file after cache directory 2021-02-11 20:52:27 +00:00
Axel Dahlberg 17823bacea
Added commands to clipctl to check the status, toggle, get version and directory (#152) 2021-01-21 15:15:00 +00:00
Ferenc Erki a882cf9732 Sync primary to clipboard immediately 2020-11-03 12:05:27 +00:00
Chris Down 9c7f1b9bf3 clipmenud: Don't assume that we're the process group leader
We usually are, but this is more robust in light of #139.
2020-10-14 14:07:36 +01:00
Chris Down ee11a09fb0 Add $DISPLAY check
Fixes #131.
2020-06-09 14:20:17 +01:00
Chris Down 2677932c56 clipmenud: Check cache file existence before vacuuming
Fixes #123.
2020-04-03 12:29:00 +01:00
Chris Down e7e8425c3b clipmenud: Replace empty values for CM_DIR/CM_MAX_CLIPS/CM_SELECTIONS
Empty strings for these are not useful. Related to #123.
2020-04-03 12:28:21 +01:00
Chris Down fc7f47f81f clipmenud: Store the last data on reenabling 2020-03-26 00:35:31 +00:00
Chris Down 84fd3614ab clipmenud: Allow disable with USR1 and enable with USR2
This allows avoiding having to delete after the fact for things like
issues #57 and #98.

Why have this over just stopping clipmenud? Well:

1. Stopping clipmenud should usually be an init system action, but we
   are init-system agnostic. If we just exit, we don't have a way of
   reliably starting again.
2. Even if we *do* do it using the init system, we don't want some
   things (like a lingering xsel which owns the selection for
   CM_OWN_CLIPBOARD) being killed as well.
3. This is a nicer interface for things like password managers to stop
   clipmenu rather than stopping clipmenu entirely.
2020-03-25 19:13:22 +00:00
Chris Down d24b57c9db clipmenud: Fix potential misaligned truncation in duplicate detection
If we detect a duplicate for this selection, but another selection has
already been written, we will truncate the wrong length in the line.
2020-03-24 17:36:30 +00:00
Chris Down afb2f7ce2f clipmenud: Remove weird extra line in --help 2020-03-24 01:11:02 +00:00
Chris Down 2ffa909d79 clipmenud: Vacuum every 10 clips
This is much less expensive now, we can do it more often.
2020-03-24 00:52:47 +00:00
Chris Down a95b727d3b clipmenud: Remove not very useful vacuuming debug message 2020-03-23 17:57:22 +00:00
Chris Down 7aed22e1a7 clipmenud: $cache_file must exist by vacuum time 2020-03-23 17:55:06 +00:00
Chris Down be7dcfb4db clipmenu: Since we don't reuse line content, don't store it 2020-03-23 17:52:57 +00:00
Chris Down f9ab57522d clipmenud: Remove timeout_cmd, we already rely on coreutils for truncate 2020-03-23 17:50:43 +00:00
Chris Down da1ccb7c70 get_first_line: Simplify END logic 2020-03-23 17:45:48 +00:00
Chris Down a9fb4c9823 Remove CM_ONESHOT debug message, it has never been useful 2020-03-23 17:41:50 +00:00
Chris Down a090177497 get_first_line: We never set line_length_limit, just make it static 2020-03-23 17:40:13 +00:00
Chris Down b4d001149c clipmenud: Remove some debug messages which have never been useful 2020-03-23 17:23:36 +00:00
Chris Down f8658b0d00 clipmenud: Colocate related variables and comments 2020-03-23 17:20:30 +00:00
Chris Down 4770e52cf3 clipmenud: Update comment for CM_OWN_CLIPBOARD, we don't use element_in 2020-03-23 17:15:52 +00:00
Chris Down 2aae4989af clipmenud: Colocate similar functions 2020-03-23 17:14:01 +00:00
Chris Down 80b697edd2 clipmenud: Don't mkdir cache_dir again
If someone deletes the dir, they must restart clipmenud.
2020-03-23 17:11:04 +00:00
Chris Down 228fcbdd0d clipmenud: Tidy up some old, too-verbose comments 2020-03-23 17:10:43 +00:00
Chris Down 9e672cf0a5 Make clipnotify mandatory
The old sleep method is basically untested and unmaintained. Make it
official.
2020-03-23 17:05:59 +00:00
Chris Down 8de3d7a9c5 Check clipboard selection for ownership explicitly
We no longer need to do the element_in checks, just do it for this
selection when it runs.
2020-03-23 17:02:59 +00:00
Chris Down 099aeb3e22 Print out number of vacuumed files 2020-03-23 16:25:00 +00:00
Chris Down ea3ccea514 clipmenud: Mention selection used for possible partials 2020-03-23 16:01:11 +00:00
Chris Down 879854975e Run CM_MAX_CLIPS handling/vacuuming out of selection loop 2020-03-23 15:59:42 +00:00
Chris Down bbf495c147 Add async vacuum support
This makes sure that, for all cases, we don't end up ever dereferencing
a still referenced clip.
2020-03-23 13:00:14 +00:00
Chris Down f22fce7f04 Use a single line cache file
In c7c894a0, a per-selection line-cache was introduced in order to
overcome some of the limitations of clipmenu at the time (for example,
missing duplicate detection). However, now we have all the features we
need to have a single line cache again, and having multiple line caches
has caused more trouble than it is worth.

For example, maintaining CM_MAX_CLIPS globally is extremely cumbersome,
so we don't do it, and CM_MAX_CLIPS is actually acted on per-selection.
We also have had bugs where we perform actions on cache files without
properly consulting other line caches, and while those can be fixed, the
simplest thing to do now is just to go back to having a single line
cache.
2020-03-23 13:00:14 +00:00
Chris Down 25c7503c6a Default CM_OWN_CLIPBOARD to 0
See #113, #102, and (probably) #119. This seems to cause more trouble
than it's really worth.
2020-03-11 14:58:42 +00:00
Chris Down e89f4843bb truncation: Avoid harmless reporting of multi-removals on a single file 2020-03-11 00:46:23 +00:00
Chris Down 7a9299cc18 clipmenud: Better document new CM_MAX_CLIPS batching 2020-03-07 12:34:46 +00:00
Chris Down a495bcc7a4 clipmenud: Batch truncations in groups of 100 for performance 2019-07-09 22:37:25 +01:00
Chris Down 85aaec1626 clipmenud: Avoid deleting still-referenced files in the case of dupes 2019-07-09 22:31:20 +01:00
Chris Down 7cb215c3f9 clipmenud: Add INFO logging for removals 2019-07-09 22:28:16 +01:00
Chris Down 4a39610896 clipmenud: Make session file error message more clear 2019-05-01 11:27:24 -04:00
Chris Down ad47f8e2db clipmenud: Create die and error functions 2019-05-01 11:26:01 -04:00
Chris Down 1cb46143f3 clipmenud: Add a sessionwide lock 2019-05-01 11:22:48 -04:00
Sohalt 7de9c9e809 Add support to ignore the clipboard in certain windows (#89)
The clipboard does not get recorded when the title of the currently 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 between 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.
2018-11-08 16:39:18 +00:00
Chris Down f748a2e5a6 Make timeout optional 2018-11-01 00:35:38 +00:00
Chris Down 7c3bd5060a Do $PATH lookup for bash 2018-10-31 08:12:09 +00:00
Chris Down d76b716d9f Sort environment variables in --help 2018-08-21 15:39:17 -04:00