Reduce macOS idle resource usage
This commit is contained in:
@@ -153,6 +153,14 @@ def run(read_from='clipboard',
|
||||
on_press=on_key_press,
|
||||
on_release=on_key_release)
|
||||
tmp_paused_listener.start()
|
||||
|
||||
if sys.platform == "darwin" and 'objc' in sys.modules:
|
||||
from AppKit import NSPasteboard, NSPasteboardTypePNG, NSPasteboardTypeTIFF
|
||||
pasteboard = NSPasteboard.generalPasteboard()
|
||||
count = pasteboard.changeCount()
|
||||
mac_clipboard_polling = True
|
||||
else:
|
||||
mac_clipboard_polling = False
|
||||
else:
|
||||
read_from = Path(read_from)
|
||||
if not read_from.is_dir():
|
||||
@@ -225,6 +233,16 @@ def run(read_from='clipboard',
|
||||
|
||||
if read_from == 'clipboard':
|
||||
if not paused and not tmp_paused:
|
||||
if mac_clipboard_polling:
|
||||
changed = False
|
||||
old_count = count
|
||||
count = pasteboard.changeCount()
|
||||
if not just_unpaused and count != old_count and any(x in pasteboard.types() for x in [NSPasteboardTypePNG, NSPasteboardTypeTIFF]):
|
||||
changed = True
|
||||
else:
|
||||
changed = True
|
||||
|
||||
if changed:
|
||||
old_img = img
|
||||
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user