Add option to change location of cache dir.

-cache-dir

Fixes: #769
This commit is contained in:
Dave Davenport 2019-02-08 20:43:53 +01:00
parent 94ebd7e635
commit 52204a527c
7 changed files with 32 additions and 9 deletions

View File

@ -156,4 +156,6 @@ Settings config = {
.combi_hide_mode_prefix = FALSE,
.matching_negate_char = '-',
.cache_dir = NULL,
};

View File

@ -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

View File

@ -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

View File

@ -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.

View File

@ -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;

View File

@ -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 ) {

View File

@ -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 */