diff --git a/configure.ac.in b/configure.ac.in
index 90c9bb4e3e2161601bd2e4472d2535fbd42cd945..09efbfe6d1bbd33e86304d1851dd77612805a06e 100644
--- a/configure.ac.in
+++ b/configure.ac.in
@@ -106,6 +106,16 @@ AC_ARG_WITH([helper-path-prefix],
             [HELPER_PATH_PREFIX="$libdir"])
 AC_SUBST([HELPER_PATH_PREFIX])
 
+dnl *******************************************************
+dnl *** Optional support for custom thunarx directories ***
+dnl *******************************************************
+AC_ARG_WITH([custom-thunarx-dirs-enabled],
+            [AS_HELP_STRING([--with-custom-thunarx-dirs-enabled],
+                            [Enables the posibillity to set custom thunarx directories by using the environment variable THUNARX_DIRS])],
+            [CUSTOM_THUNARX_DIRS_ENABLED="TRUE"],
+            [CUSTOM_THUNARX_DIRS_ENABLED="FALSE"])
+AC_SUBST([CUSTOM_THUNARX_DIRS_ENABLED])
+
 dnl ***********************************************
 dnl *** Work-around system-specific limitations ***
 dnl ***********************************************
diff --git a/thunarx/Makefile.am b/thunarx/Makefile.am
index 8482b25d35cf73037cd708e21790de30f888732f..8af6a80a74ce17c8a397b044fea151598dfc0911 100644
--- a/thunarx/Makefile.am
+++ b/thunarx/Makefile.am
@@ -3,6 +3,7 @@ AM_CPPFLAGS =								\
 	-DG_LOG_DOMAIN=\"thunarx\"					\
 	-DTHUNARX_COMPILATION						\
 	-DTHUNARX_DIRECTORY=\"$(libdir)/thunarx-$(THUNARX_VERSION_API)\"	\
+	-DTHUNARX_ENABLE_CUSTOM_DIRS=\"$(CUSTOM_THUNARX_DIRS_ENABLED)\"	\
 	$(PLATFORM_CPPFLAGS)
 
 libthunarx_headers =							\
diff --git a/thunarx/thunarx-provider-factory.c b/thunarx/thunarx-provider-factory.c
index c110b56dca15449d6f0aaeb03db88d673ea00468..5d378bbc74764819d9b3fa964a9259258a07f737 100644
--- a/thunarx/thunarx-provider-factory.c
+++ b/thunarx/thunarx-provider-factory.c
@@ -157,12 +157,15 @@ thunarx_provider_factory_create_modules (ThunarxProviderFactory *factory)
   const gchar           *name;
   GList                 *lp;
   GDir                  *dp;
-  gchar                 *dirs_string;
+  gchar                 *dirs_string = NULL;
   gchar                **dirs;
 
-  dirs_string = (gchar *) g_getenv ("THUNARX_DIRS");
-  if (!dirs_string)
+  if (g_strcmp0 (THUNARX_ENABLE_CUSTOM_DIRS, "TRUE") == 0)
+    dirs_string = (gchar *) g_getenv ("THUNARX_DIRS");
+
+  if (dirs_string == NULL)
     dirs_string = THUNARX_DIRECTORY;
+
   dirs = g_strsplit (dirs_string, G_SEARCHPATH_SEPARATOR_S, 0);
 
   for (int i = 0; dirs[i] != NULL; i++)
diff --git a/thunarx/thunarx-provider-module.c b/thunarx/thunarx-provider-module.c
index 2706623328b27c40f7667d05a8e48f0f2f8b9a90..9ffba66fb410e532a9a68c081ee12dfe0f2fc9a4 100644
--- a/thunarx/thunarx-provider-module.c
+++ b/thunarx/thunarx-provider-module.c
@@ -175,13 +175,16 @@ thunarx_provider_module_load (GTypeModule *type_module)
 {
   ThunarxProviderModule *module = THUNARX_PROVIDER_MODULE (type_module);
   gchar                 *path;
-  gchar                 *dirs_string;
+  gchar                 *dirs_string = NULL;
   gchar                **dirs;
   gboolean               found;
 
-  dirs_string = (gchar *) g_getenv ("THUNARX_DIRS");
-  if (!dirs_string)
+  if (g_strcmp0 (THUNARX_ENABLE_CUSTOM_DIRS, "TRUE") == 0)
+    dirs_string = (gchar *) g_getenv ("THUNARX_DIRS");
+
+  if (dirs_string == NULL)
     dirs_string = THUNARX_DIRECTORY;
+
   dirs = g_strsplit (dirs_string, G_SEARCHPATH_SEPARATOR_S, 0);
 
   found = FALSE;