You are not logged in.
Hi everyone,
I am on arch (4.19.12-arch1-1-ARCH) with i3 (4.15.0.1-107-g34cf1073). For some reasons I would like to store in a file every copied instances that xclip gets.
That sounds easy but after some tests I can not succeed.
xclip is not a daemon and I prefer avoiding modify the package itself.
I can easily perform:
xclip -o > IputmyfileswhereverIwant.txtbut if I want to do it every time xclip is called I need an event. I added the bindsym Ctrl+c in my i3 config but of course then the copy bindsym (Ctrl+c) for every app stops working.
I could use a daemon that checks every keytap but that's very overkill. Is it a way to have a "ghost" bindsym in a window manager that lets the key event access to the window too? Doing that I will get the key event at different layers.
Better idea?
Thanks for your time.
Last edited by Yann (2018-12-29 16:12:28)
all different - all equal
Offline
Offline
Thanks Raynman, I am having a look. Looks to solve my desire. However I need the process to run in background?
all different - all equal
Offline
You could write a script that wraps around the real 'xclip'. What might work is saving that script as "/usr/local/bin/xclip". The "/usr/local/bin" location normally comes in front of "/usr/bin" in $PATH so should then replace the real 'xclip' for programs that call it.
In your wrapper script you would check what the arguments are and save the clipboard in a file and then run the real '/usr/bin/xclip'.
Offline
Thanks for the reply. I would prefer this solution, however after setting the wrap I figured out that there are some dysfunctions. After a search on my system I figured out that main of the processes call "/usr/bin/xclip" and not "xclip". So the only solution I see is to move "/usr/bin/xclip" to another location and put the wrap in "/usr/bin". But doing that I guess I will break the xclip pacman updates and get some errors..
What do you think about this point?
Otherwise, the clipnotify solution is exactly what I was looking for, I run "top | grep clipnotify" and was surprised that the process appears only when there is a selection. Don't undersand why.
while clipnotify; do
echo -e "$(date +%H:%M:%S): $(xclip -o)\n" >> $Iwillputmyfileherethattime.txt
doneall different - all equal
Offline
The xclip notify only shows up in top in the inner part of that loop. The shell script running the loop will always be in top.
This loop has to continually run in the background just like any daemon you are avoiding (just less efficiently). What you want requires *some process* to be running in the background. Your proposal of having the WM filter every key press would work, but that would require a more complex background process (the WM) running all the time.
Accept that to do what you want, some process must be running all the time. Once you've accepted that, opt for the background process that simply and cleanly does what you want with the least baggage.
I'd suggest slightly modifying xclipnotify to instead continuously listen for selection events, and on every change (still within the C code) write the selection content to a file.
Last edited by Trilby (2018-12-29 14:01:56)
"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Offline
Ok Trilby, that's clear. I am trying to accept it... And that's not easy. But ok, that's the best solution and it's necessary. I accept it!
I am going to use the clipnotify solution that Raynman suggested.
Just to know, what is the level of difficulty of getting a "ghost" bindsym (letting the keytap pass to the window) for a WM such as i3?
all different - all equal
Offline
What do you mean the "difficulty" of it? It would be very easy if you modify the WM code. But to what end? Why a key press? There are many other ways for a selection to be filled, e.g. highlighting with a mouse.
Do you want every clipboard/primary-selection change logged to a file, or do you want to log to a file the content of the buffer every time you use an i3 binding to call xclip to fill it? The latter is *much much* easier.
"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Offline
No no, I want "every clipboard/primary-selection change logged to a file". And the clinotify solves it.
However, just to know, how can I get a "ghost" bindsym (letting the keytap pass to the window) for a WM such as i3? (not very related to the main issue..)
all different - all equal
Offline
It'd be just the same as any other key binding via XGabKey/XGrabKeyboard but then followed by a SendEvent to relay the event to the focused window. It'd likely be horribly inefficient though as you might need to ungrab the key/keyboard before sending the event on to the intended target. You'd likely be better off doing this at a lower level prior to the input being processed by Xorg.
Last edited by Trilby (2018-12-29 16:18:13)
"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Offline
Ok, thanks for answering. My question is SOLVED.
all different - all equal
Offline