cdown / clipnotify Goto Github PK
View Code? Open in Web Editor NEWNotify on new X clipboard events
License: Other
Notify on new X clipboard events
License: Other
The way, when command is run per each request or for each event, is somewhat ineffective. Clipnotify could stay at stdout, sending something (may be just a newline) on each event. For example, some other tools support daemon mode: inotifywait, alsactl and amixer, pacmd, skb (similar tool for xkb layout watching), free (program, not word).
If clipnotify supported such mode, it would allow to make super-effective clipmenud by moving maximum job into special utilities, arranging them into persistant pipeline, while shell would only manage its setup.
Example option: -o, --stdout, -m, --monitor
(last two as for inotifywait).
Please add it in readme
When building on FreeBSD the location of the include files for cc
are in /usr/local/include and /usr/local/lib. In the Makefile there is already the following variable defined x11_bsd_flags = -I/usr/X11R6/include -L/usr/X11R6/lib
which seems valid for OpenBSD
Now clipnotify uses XFIXES extension to X11. Since the world is moving to Wayland would be great to support it.
https://archlinux.org/packages/community/x86_64/clipnotify/
Just wondering when the new version will reach the arch repos.
Last version is from 2020.
Right now I have to keep using a fork.
if X emits an event when the clipboard is emptied (i.e. when the owner dies)
then clipnotify could relay that to automatically restore the clipboard from history
and so solve the problem of may-be-missing contents without stealing ownership
For compliling & installing clipmenu
, clipnotify
was not available on debian, so I tried to compile, but failed on this error
cc clipnotify.c -o clipnotify -I/usr/X11R6/include -L/usr/X11R6/lib -lX11 -lXfixes
clipnotify.c:3:10: fatal error: X11/extensions/Xfixes.h: No such file or directory
3 | #include <X11/extensions/Xfixes.h>
| ^~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
Hi, thanks for this little program quite useful ! I use it to automatically copy the primary selection to the clipboard when I select something :
while clipnotify; do
xclip -sel p -o | xclip -sel c
done
But, this poses a problem when on an application like libreoffice I need to copy with ctrl+c directly to clipboard, as my script gonna erase this selection overwriting the clipboard with the primary selection. I use now a trick : storing the clipboard content in a variable, I can check if the new clipboard content is different than the stored one (a new clipboard selection is done) or not (a new primary selection is done).
while clipnotify; do
if [[ $(xclip -sel c -o) == "$clipboard" ]]; then
xclip -sel p -o | xclip -sel c
fi
clipboard=$(xclip -sel c -o)
done
But it would be more elegant to have the possibility to discriminate between primary and clipboard notification with clipnotify or something else. I would like a syntax like:
while clipnotify; do
if the sel is primary then
done
Why not something like the bspwm daemon : bspc subscribe node_geometry | while read -a msg; do
sending just a message with the name of the X selection (primary/clipboard...) ?
This is not a bug report. I'm just writing you to thank you for writing this very useful little program. I was able to use it to help me write a little system for sharing clipboard contents over the network.
https://git.coom.tech/gg1234/shared-clipboard
The example calls clipnotify and, when it returns, does something with the new selection value.
But what if a change arrives just before clipnotify starts listening?
Then the program will wait forever and not notice the new selection value, right?
I understand it may be impossible to catch brief transient values, but I'd like eventual consistency; e.g. if the selection value changes to "foo" and stays that way, the script should eventually notice that.
To demonstrate:
In bash shell window #1, run this clipnotify loop:
while ./clipnotify; do echo "PRIMARY: '$(xclip -o -sel p)' CLIPBOARD: '$(xclip -o -sel c)'"; done
In bash shell window #2, run this naive polling loop:
p0=$(xclip -o -sel p); c0=$(xclip -o -sel c); while true; do p1=$(xclip -o -sel p); c1=$(xclip -o -sel c); if [[ "$p1" != "$p0" || "$c1" != "$c0" ]]; then echo "PRIMARY: '$p1' CLIPBOARD: '$c1'"; p0=$p1; c0=$c1; fi; done
In bash shell window #3, run this repeatedly:
echo -n foo | xclip; echo -n bar | xclip
Desired result: the last line, in both windows #1 and #2, should always look like:
...
PRIMARY: 'bar' CLIPBOARD: 'whatever'
Actual result: window #2 (the naive polling loop) is always good. But window #1 (the clipnotify loop) sometimes ends up showing the not-most-recent value:
...
PRIMARY: 'foo' CLIPBOARD: 'whatever'
I'm running Chromium 64.0.3282.167, clipnotify 071c3d3, and clipmenu caab3f6a62a. As I select text using my trackpad I see many entries being added by clipmenud, which clutters up the history when I run clipmenu. I'm inferring that Chromium sends many SetSelectionOwner events while a selection is being made, which doesn't seem to break any ICCCM recommendations, but also doesn't work well with clipnotify. I can't think of a Works Every Time way to handle this. Maybe the answer is to change Chromium's behaviour.
Oddly, I've heard that Chrome doesn't display this behaviour.
I receive this error
~/.clipnotify(master โ) make
cc clipnotify.c -o clipnotify -I/usr/X11R6/include -L/usr/X11R6/lib -lX11 -lXfixes
clipnotify.c:1:10: fatal error: X11/Xatom.h: No such file or directory
#include <X11/Xatom.h>
^~~~~~~~~~~~~
compilation terminated.
Makefile:4: recipe for target 'all' failed
make: *** [all] Error 1
I'm sure the solution may be simple but I'd need to see it. Thanks
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.