depot/third_party/nixpkgs/pkgs/applications/misc/gnome-frog/update-compatible-with-non-flatpak-env.patch
Default email 02cf88bb76 Project import generated by Copybara.
GitOrigin-RevId: c4a0efdd5a728e20791b8d8d2f26f90ac228ee8d
2022-08-12 15:06:08 +03:00

33 lines
1.4 KiB
Diff
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

diff --git a/frog/config.py b/frog/config.py
index 9837755..b73e4e3 100644
--- a/frog/config.py
+++ b/frog/config.py
@@ -30,10 +30,14 @@ import os
APP_ID = "com.github.tenderowl.frog"
RESOURCE_PREFIX = "/com/github/tenderowl/frog"
+# This is based from the XDG Base Directory specification.
+if not os.getenv('XDG_DATA_HOME'):
+ os.environ['XDG_DATA_HOME'] = os.path.expanduser("~/.local/share")
+
if not os.path.exists(os.path.join(os.environ['XDG_DATA_HOME'], 'tessdata')):
os.mkdir(os.path.join(os.environ['XDG_DATA_HOME'], 'tessdata'))
tessdata_url = "https://github.com/tesseract-ocr/tessdata/raw/main/"
tessdata_best_url = "https://github.com/tesseract-ocr/tessdata_best/raw/main/"
tessdata_dir = os.path.join(os.environ['XDG_DATA_HOME'], 'tessdata')
-tessdata_config = f'--tessdata-dir {tessdata_dir} psm 6'
+tessdata_config = f'-psm 6 --tessdata-dir {tessdata_dir}'
diff --git a/frog/language_manager.py b/frog/language_manager.py
index 5752be6..4f6a908 100644
--- a/frog/language_manager.py
+++ b/frog/language_manager.py
@@ -156,7 +156,7 @@ class LanguageManager(GObject.GObject):
os.mkdir(tessdata_dir)
dest_path = os.path.join(tessdata_dir, 'eng.traineddata')
- source_path = pathlib.Path('/app/share/appdata/eng.traineddata')
+ source_path = pathlib.Path('@out@/share/appdata/eng.traineddata')
if os.path.exists(dest_path):
return