diff --git a/config/config.c b/config/config.c index 855dacdc..c5e569bc 100644 --- a/config/config.c +++ b/config/config.c @@ -156,4 +156,6 @@ Settings config = { .combi_hide_mode_prefix = FALSE, .matching_negate_char = '-', + + .cache_dir = NULL, }; diff --git a/doc/rofi-theme-selector.1 b/doc/rofi-theme-selector.1 index a667a0ae..6a9630c7 100644 --- a/doc/rofi-theme-selector.1 +++ b/doc/rofi-theme-selector.1 @@ -1,7 +1,7 @@ .\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "ROFI\-THEME\-SELECTOR" "1" "February 2018" "" "" +.TH "ROFI\-THEME\-SELECTOR" "1" "May 2018" "" "" . .SH "NAME" \fBrofi\-theme\-selector\fR \- Preview and apply themes for \fBrofi\fR diff --git a/doc/rofi.1 b/doc/rofi.1 index 7eba77e0..c2d4a530 100644 --- a/doc/rofi.1 +++ b/doc/rofi.1 @@ -1,7 +1,7 @@ .\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "ROFI" "1" "January 2019" "" "" +.TH "ROFI" "1" "February 2019" "" "" . .SH "NAME" \fBrofi\fR \- A window switcher, application launcher, ssh dialog and dmenu replacement @@ -311,6 +311,12 @@ Filter the list by setting text in input bar to \fIfilter\fR Load an alternative configuration file\. . .P +\fB\-cache\-dir\fR \fIfilename\fR +. +.P +Directory that is used to place temporary files, like history\. +. +.P \fB\-scroll\-method\fR \fImethod\fR . .P diff --git a/doc/rofi.1.markdown b/doc/rofi.1.markdown index 675ae06d..e09b2639 100644 --- a/doc/rofi.1.markdown +++ b/doc/rofi.1.markdown @@ -175,6 +175,11 @@ Filter the list by setting text in input bar to *filter* Load an alternative configuration file. +`-cache-dir` *filename* + +Directory that is used to place temporary files, like history. + + `-scroll-method` *method* Select the scrolling method. 0: Per page, 1: continuous. diff --git a/include/settings.h b/include/settings.h index acd0f307..e6aebc8b 100644 --- a/include/settings.h +++ b/include/settings.h @@ -181,6 +181,9 @@ typedef struct gboolean combi_hide_mode_prefix; char matching_negate_char; + + /** Cache directory. */ + char *cache_dir; } Settings; /** Global Settings structure. */ extern Settings config; 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 */