-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path__main__.py
More file actions
34 lines (26 loc) · 993 Bytes
/
__main__.py
File metadata and controls
34 lines (26 loc) · 993 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import logging
import os
from Xlib.display import Display
from clipstack.spy import ClipboardSpy
from clipstack.clipboard import Clipboard
if os.getenv("CLIPSTACK_DEBUG"):
logging.basicConfig(level=logging.INFO, format="[%(levelname)s] %(name)s: %(message)s")
else:
logging.basicConfig(
level=logging.WARNING, format="[%(levelname)s] %(name)s: %(message)s"
)
if __name__ == "__main__":
display = Display()
cb_spy = ClipboardSpy(display)
cb = Clipboard(display)
for content in cb_spy.spy():
# this can't handle images yet
targets = [display.get_atom_name(k) for k in content.keys()]
content_is_img = any(["image" in target for target in targets])
# ignore images
# let the original applications handle it
# the stack will remain intact
if content_is_img:
logging.warning("Skipping content since we can't handle it right now")
continue
cb.copy_content(content)