summaryrefslogtreecommitdiffstats
path: root/source
diff options
context:
space:
mode:
authorDave Davenport <qball@gmpclient.org>2019-02-08 20:43:53 +0100
committerDave Davenport <qball@gmpclient.org>2019-02-08 20:43:53 +0100
commit52204a527cfbad35c66030efbfd8742870d0ff04 (patch)
treee7038fee03264dbdddfa84c43743538641bd45f4 /source
parent94ebd7e635a1246007e90eb00730dbf947872855 (diff)
Add option to change location of cache dir.
-cache-dir Fixes: #769
Diffstat (limited to 'source')
-rw-r--r--source/rofi.c19
-rw-r--r--source/xrmoptions.c2
2 files changed, 14 insertions, 7 deletions
diff --git a/source/rofi.c b/source/rofi.c
index 4bea8012..dfb687de 100644
--- a/source/rofi.c
+++ b/source/rofi.c
@@ -776,13 +776,6 @@ int main ( int argc, char *argv[] )
g_free ( base_name );
}
TICK ();
- // Get the path to the cache dir.
- cache_dir = g_get_user_cache_dir ();
-
- if ( g_mkdir_with_parents ( cache_dir, 0700 ) < 0 ) {
- g_warning ( "Failed to create cache directory: %s", g_strerror ( errno ) );
- return EXIT_FAILURE;
- }
// Create pid file path.
const char *path = g_get_user_runtime_dir ();
@@ -883,6 +876,18 @@ int main ( int argc, char *argv[] )
parse_keys_abe ( bindings );
+ // Get the path to the cache dir.
+ cache_dir = g_get_user_cache_dir ();
+
+ if ( config.cache_dir != NULL ) {
+ cache_dir = config.cache_dir;
+ }
+
+ if ( g_mkdir_with_parents ( cache_dir, 0700 ) < 0 ) {
+ g_warning ( "Failed to create cache directory: %s", g_strerror ( errno ) );
+ return EXIT_FAILURE;
+ }
+
/** dirty hack for dmenu compatibility */
char *windowid = NULL;
if ( !dmenu_mode ) {
diff --git a/source/xrmoptions.c b/source/xrmoptions.c
index d7bae743..485acc41 100644
--- a/source/xrmoptions.c
+++ b/source/xrmoptions.c
@@ -218,6 +218,8 @@ static XrmOption xrmOptions[] = {
"Hide the prefix mode prefix on the combi view.", CONFIG_DEFAULT },
{ xrm_Char, "matching-negate-char", { .charc= &config.matching_negate_char }, NULL,
"Set the character used to negate the matching. ('\\0' to disable)", CONFIG_DEFAULT },
+ { xrm_String, "cache-dir", { .str = &config.cache_dir }, NULL,
+ "Directory where history and temporary files are stored.", CONFIG_DEFAULT },
};
/** Dynamic array of extra options */