diff --git a/gramps/gen/const.py.in b/gramps/gen/const.py.in
index d0dd1fc5e..5edb27141 100644
--- a/gramps/gen/const.py.in
+++ b/gramps/gen/const.py.in
@@ -200,10 +200,23 @@ else:
# Paths to data files.
#
#-------------------------------------------------------------------------
-LOCALE_DIR = "@LOCALE_DIR@"
-DATA_DIR = "@DATA_DIR@"
-IMAGE_DIR = "@IMAGE_DIR@"
-DOC_DIR = "@DOC_DIR@"
+if "XDG_DATA_DIRS" in os.environ:
+ share = None
+ for path in os.environ["XDG_DATA_DIRS"].split(":"):
+ if os.path.exists(os.path.join(path, "gramps", "tips.xml")):
+ share = path
+ break
+ if not share:
+ share = os.path.split("@DATA_DIR@")[0]
+ LOCALE_DIR = os.path.join(share, "locale")
+ DATA_DIR = os.path.join(share, "gramps")
+ IMAGE_DIR = os.path.join(DATA_DIR, "icons", "hicolor")
+ DOC_DIR = os.path.join(share, "doc", "gramps")
+else:
+ LOCALE_DIR = "@LOCALE_DIR@"
+ DATA_DIR = "@DATA_DIR@"
+ IMAGE_DIR = "@IMAGE_DIR@"
+ DOC_DIR = "@DOC_DIR@"
TIP_DATA = os.path.join(DATA_DIR, "tips.xml")
PAPERSIZE = os.path.join(DATA_DIR, "papersize.xml")
diff --git a/mac/gramps.bundle b/mac/gramps.bundle
index efa33addd..c6db180c1 100644
--- a/mac/gramps.bundle
+++ b/mac/gramps.bundle
@@ -187,6 +187,10 @@
${prefix}/lib/graphviz/config6
+
+ ${prefix}/share/gramps
+
+