yurikhan / kitty_grab

Keyboard-driven screen grabber for Kitty
GNU General Public License v3.0
178 stars 12 forks source link

kitty_grab no longer works with the newest Kitty #25

Closed gregorias closed 2 years ago

gregorias commented 2 years ago

Since somewhere around Kitty 0.26.3, kitty_grab stopped working, because the API has changed.

For example, _grab_ui.py depends on kitty.fast_data_types.set_clipboard_string, but Kitty moved that function away from fast_data_types in https://github.com/kovidgoyal/kitty/commit/7e1380cc0dfbef2e7f5ce8988e4aef206a193335.

yurikhan commented 2 years ago

Oh nice :frowning: Breaking API changes, just what we need at this particular time.

Can you test with this patch, are there other breakages?

diff --git a/_grab_ui.py b/_grab_ui.py
index f58f56a..73ce8e5 100644
--- a/_grab_ui.py
+++ b/_grab_ui.py
@@ -14,7 +14,7 @@ from kitten_options_types import Options, defaults
 from kitten_options_parse import create_result_dict, merge_result_dicts, parse_conf_item
 from kitty.conf.utils import load_config as _load_config, parse_config_base, resolve_config
 from kitty.constants import config_dir
-from kitty.fast_data_types import set_clipboard_string, truncate_point_for_length, wcswidth
+from kitty.fast_data_types import truncate_point_for_length, wcswidth
 import kitty.key_encoding as kk
 from kitty.key_encoding import KeyEvent
 from kitty.rgb import color_as_sgr
@@ -22,6 +22,12 @@ from kittens.tui.handler import Handler
 from kittens.tui.loop import Loop

+try:
+    from kitty.clipboard import set_clipboard_string
+except ImportError:
+    from kitty.fast_data_types import set_clipboard_string
+
+
 if TYPE_CHECKING:
     from typing_extensions import TypedDict
     ResultDict = TypedDict('ResultDict', {'copy': str})
gregorias commented 2 years ago

Kitty Grab with the patch works on Kitty 0.26.3.

yurikhan commented 2 years ago

Good. Pushed as 1768dab.