Giter VIP home page Giter VIP logo

Comments (9)

 avatar commented on July 23, 2024

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.

mrichar1 avatar mrichar1 commented on July 23, 2024

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.

 avatar commented on July 23, 2024

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.

mrichar1 avatar mrichar1 commented on July 23, 2024

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.

 avatar commented on July 23, 2024

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.

mrichar1 avatar mrichar1 commented on July 23, 2024

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 and gir1.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.

 avatar commented on July 23, 2024

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.

mrichar1 avatar mrichar1 commented on July 23, 2024

Have added the require_version - thanks for your issue request and testing! 👍

from clipster.

 avatar commented on July 23, 2024

thanks to you for dealing with it!

from clipster.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.