Comments (9)
I don’t think it’s possible without asking the graphic server itself... but using xlib would mean no wayland.
What do other clipboards do? If no one does it, maybe it’s really impossible
(I can’t recall seeing one that does it)
from clipster.
OK - so there are 2 ways to do this - the first doesn't work, the second isn't ideal:
The first way, as suggested before is to use python-xlib
. However not all windows have properties, so you have to recurse up the window tree to find a parent with properties. However some apps seem to like to use 'un-parented' windows so you never get to a parent with a WM_CLASS
property before you reach the root window. this is the case with keepass2, inkscape, and a couple of other GUI apps I tried.
The second is to look and see what window is active at the point the owner-change event occurs. This is easy to do, but feels very wrong. However, this is actually what klipper
does when you use their Disable Actions for windows of type WM_CLASS
option, so it's got some support out there.
It's very easy to break this by doing: sleep 10; echo "cat" | clipster
and then changing window focus - however I suspect for the cases where this matters (like keepass2
) you're unlikely to have any such delay.
I'll see about implementing this second option and let you know when it's ready to test.
from clipster.
Good! i didn’t know klipper could do it.
Sadly it’s too much advanced for me to help with the coding, i’m just a beginner, but i’ll be glad to at least help testing it.
from clipster.
That should be the changes added - to test, add:
filter_classes = KeePass2
To your config and if you run clipster -d -lDEBUG
you should hopefully see:
DEBUG:Filter classes enabled for: ['KeePass2']
DEBUG:Active window class is KeePass2
DEBUG:Ignoring active window.
In the output when you cut/copy in keepass2 (but no change in behaviour for other apps).
from clipster.
i get:
Traceback (most recent call last):
File "/home/arch/.shortcuts/clipster", line 10, in <module>
from gi.repository import Gtk, Gdk, GLib, GObject, Wnck
File "<frozen importlib._bootstrap>", line 969, in _find_and_load
File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 664, in _load_unlocked
File "<frozen importlib._bootstrap>", line 634, in _load_backward_compatible
File "/usr/lib/python3.5/site-packages/gi/importer.py", line 114, in load_module
introspection_module = get_introspection_module(namespace)
File "/usr/lib/python3.5/site-packages/gi/module.py", line 271, in get_introspection_module
module = IntrospectionModule(namespace, version)
File "/usr/lib/python3.5/site-packages/gi/module.py", line 120, in __init__
repository.require(namespace, version)
gi.RepositoryError: Requiring namespace 'Gtk' version '2.0', but '3.0' is already loaded
from clipster.
I think the issue is that you're missing libwnck 3.0 library, and/or the bindings for it in gi.repository. I had hoped these were part of the default Gtk3 install, but obviously not.
Not 100% sure, but a quick google suggests that this can be found in the following packages for different OSes:
- debian/ubuntu:
libwnck-3-0
andgir1.2-wnck-3.0
- arch:
libwnck3
- redhat/fedora:
libwnck3-devel
Let me know if installing that fixes the problem. It might also be necessary to put in another require_version
line at the top of the file to force the use of the 3.0:
require_version('Wnck', '3.0')
import Wnck
from clipster.
It’s perfect now; I tried it with firefox and works without flaws. About the wnck, the require_version is needed indeed. I too thought about some missing dependency, but I installed python2-wnck instead of libwnck3, so it didn’t work
from clipster.
Have added the require_version - thanks for your issue request and testing! 👍
from clipster.
thanks to you for dealing with it!
from clipster.
Related Issues (20)
- warnings HOT 2
- Infinite loop on re.findall HOT 4
- No Encoding Declared with Python2
- the config file does not work HOT 4
- Empty history JSON file crashes clipster HOT 2
- Clipster crashes when deleting multiple entries quickly from selection window HOT 2
- Clipster doesn't capture when using `Gtk.Clipboard`'s `set_text` to copy (in Python) HOT 1
- Packaging up a 2.0.2 release HOT 3
- --daemon doesn't make clipster run in background HOT 2
- sync_selections + pattern_as_selection = infinite loop HOT 1
- Clear clipboard after a configurable period of time HOT 1
- enable option -N for input HOT 1
- CLI output problems
- Feature request(s): unidirectional sync, sync without history HOT 4
- deprecation warnings when running the deamon HOT 2
- Clipboard is not replaced when selecting item from history HOT 4
- disable middle mouse button as paste HOT 2
- Gtk-WARNING: Theme parsing error HOT 1
- Question: Any plans on python3 ? HOT 1
- [Errno 2] No such file or directory: '/run/user/0/clipster.pid' HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from clipster.