From fb05355ef0441a75234f6f836159de68f461a6a7 Mon Sep 17 00:00:00 2001
From: Mattia Rizzolo <mattia@debian.org>
Date: Tue, 2 Aug 2016 14:59:41 +0000
Subject: [PATCH] Instruct sigil to look up a couple of path by default on
 linux for dictionaries

add /usr/share/hunspell/ and /usr/share/myspell/ to the used paths.

Those are the paths where spelling dictionaries are installed on most linux
distributions.

Used only when neither SIGIL_DICTIONARIES nor SIGIL_EXTRA_ROOT are set.
---
 src/Misc/SpellCheck.cpp                               | 15 ++++++++++-----
 src/Resource_Files/plugin_launchers/python/wrapper.py |  7 +++++--
 2 files changed, 15 insertions(+), 7 deletions(-)

diff --git a/src/Misc/SpellCheck.cpp b/src/Misc/SpellCheck.cpp
index 40c9f26..eeb47e3 100644
--- a/src/Misc/SpellCheck.cpp
+++ b/src/Misc/SpellCheck.cpp
@@ -342,11 +342,16 @@ void SpellCheck::loadDictionaryNames()
         }
     }
     // else use the env var runtime overridden 'share/sigil/hunspell_dictionaries/' location.
-    else if (!sigil_extra_root.isEmpty()) {
-        paths.append(sigil_extra_root + "/hunspell_dictionaries/");
-    } else {
-        // else use the standard build time 'share/sigil/hunspell_dictionaries/'location.
-        paths.append(sigil_share_root + "/hunspell_dictionaries/");
+    else {
+        if (!sigil_extra_root.isEmpty()) {
+            paths.append(sigil_extra_root + "/hunspell_dictionaries/");
+        } else {
+            // prepend the usual places where hunspell dictionaries are located in unix systems
+            paths.append("/usr/share/myspell/");
+            paths.append("/usr/share/hunspell/");
+            // else use the standard build time 'share/sigil/hunspell_dictionaries/'location.
+            paths.append(sigil_share_root + "/hunspell_dictionaries/");
+        }
     }
 #endif
     // Add the user dictionary directory last because anything in here
diff --git a/src/Resource_Files/plugin_launchers/python/wrapper.py b/src/Resource_Files/plugin_launchers/python/wrapper.py
index 265f330..a1be0eb 100644
--- a/src/Resource_Files/plugin_launchers/python/wrapper.py
+++ b/src/Resource_Files/plugin_launchers/python/wrapper.py
@@ -828,11 +828,14 @@ def get_dictionary_dirs(self):
                 if len(share_override):
                     apaths.append(unipath.abspath(os.path.join(share_override, "hunspell_dictionaries")))
                 else:
+                    # prepend usual places where hunspell dictionaries are located in unix systems
+                    apaths.append(os.path.join(os.sep, 'usr', 'share', 'myspell')
+                    apaths.append(os.path.join(os.sep, 'usr', 'share', 'hunspell')
                     # Otherwise, use Sigil's bundled hunspell dictionary location.
                     apaths.append(unipath.abspath(os.path.join(share_prefix, "share", 'sigil', "hunspell_dictionaries")))
             apaths.append(unipath.abspath(os.path.join(self.usrsupdir,"hunspell_dictionaries")))
         return apaths
-                        
+
     def get_gumbo_path(self):
         if sys.platform.startswith('darwin'):
             lib_dir = unipath.abspath(os.path.join(self.appdir,"..","lib"))
@@ -844,7 +847,7 @@ def get_gumbo_path(self):
             lib_dir = unipath.abspath(self.appdir)
             lib_name = 'libsigilgumbo.so'
         return os.path.join(lib_dir, lib_name)
-            
+
     def get_hunspell_path(self):
         if sys.platform.startswith('darwin'):
             lib_dir = unipath.abspath(os.path.join(self.appdir,"..","lib"))
