diff --git a/doc/rofi.1 b/doc/rofi.1 index 30d661dc..95fcace9 100644 --- a/doc/rofi.1 +++ b/doc/rofi.1 @@ -69,7 +69,8 @@ Markup support can be enabled, see CONFIGURATION options. .PP There are currently three methods of setting configuration options (evaluated in order below): .IP \(bu 2 -System configuration file (for example \fB\fC/etc/rofi.rasi\fR or old format \fB\fC/etc/rofi.conf\fR). +System configuration file (for example \fB\fC/etc/rofi.rasi\fR or old format \fB\fC/etc/rofi.conf\fR). +It checks XDG\_CONFIG\_DIRS and SYSCONFDIR passed at compile time. .IP \(bu 2 Xresources: A method of storing key values in the Xserver. See here diff --git a/doc/rofi.1.markdown b/doc/rofi.1.markdown index f63e4206..78cff763 100644 --- a/doc/rofi.1.markdown +++ b/doc/rofi.1.markdown @@ -53,7 +53,8 @@ Markup support can be enabled, see CONFIGURATION options. There are currently three methods of setting configuration options (evaluated in order below): - * System configuration file (for example `/etc/rofi.rasi` or old format `/etc/rofi.conf`). + * System configuration file (for example `/etc/rofi.rasi` or old format `/etc/rofi.conf`). + It checks XDG_CONFIG_DIRS and SYSCONFDIR passed at compile time. * Xresources: A method of storing key values in the Xserver. See [here](https://en.wikipedia.org/wiki/X_resources) for more information. * Rasi theme file: The new *theme* format can be used to set configuration values. diff --git a/source/rofi.c b/source/rofi.c index f6811aa7..5fdd02e7 100644 --- a/source/rofi.c +++ b/source/rofi.c @@ -289,7 +289,7 @@ static void print_main_application_options ( int is_term ) print_help_msg ( "-show", "[mode]", "Show the mode 'mode' and exit. The mode has to be enabled.", NULL, is_term ); print_help_msg ( "-no-lazy-grab", "", "Disable lazy grab that, when fail to grab keyboard, does not block but retry later.", NULL, is_term ); print_help_msg ( "-no-plugins", "", "Disable loading of external plugins.", NULL, is_term ); - print_help_msg ( "-plugin-path", "", "Directory used to search for rofi plugins.", NULL, is_term ); + print_help_msg ( "-plugin-path", "", "Directory used to search for rofi plugins. *DEPRECATED*", NULL, is_term ); print_help_msg ( "-dump-config", "", "Dump the current configuration in rasi format and exit.", NULL, is_term ); print_help_msg ( "-upgrade-config", "", "Upgrade the old-style configuration fiel in the new rasi format and exit.", NULL, is_term ); print_help_msg ( "-dump-theme", "", "Dump the current theme in rasi format and exit.", NULL, is_term ); @@ -868,22 +868,52 @@ int main ( int argc, char *argv[] ) TICK_N ( "Setup abe" ); if ( find_arg ( "-no-config" ) < 0 ) { - gchar *etc = g_build_filename ( SYSCONFDIR, "rofi.rasi", NULL ); - g_debug ( "Testing: %s", etc ); - if ( g_file_test ( etc, G_FILE_TEST_IS_REGULAR ) ) { - g_debug ( "Parsing: %s", etc ); - rofi_theme_parse_file ( etc ); - } - else { - // Load distro default settings - gchar *xetc = g_build_filename ( SYSCONFDIR, "rofi.conf", NULL ); - if ( g_file_test ( xetc, G_FILE_TEST_IS_REGULAR ) ) { - config_parse_xresource_options_file ( xetc ); - old_config_format = TRUE; + // Load distro default settings + gboolean found_system = FALSE; + const char * const * dirs = g_get_system_config_dirs(); + if ( dirs ) + { + for ( unsigned int i =0; !found_system && dirs[i]; i++ ) { + /** New format. */ + gchar *etc = g_build_filename ( dirs[i], "rofi.rasi", NULL ); + g_debug ( "Look for default config file: %s", etc ); + if ( g_file_test ( etc, G_FILE_TEST_IS_REGULAR ) ) { + g_debug ( "Parsing: %s", etc ); + rofi_theme_parse_file ( etc ); + found_system = TRUE; + } else { + /** Old format. */ + gchar *xetc = g_build_filename ( dirs[i], "rofi.conf", NULL ); + g_debug ( "Look for default config file: %s", xetc ); + if ( g_file_test ( xetc, G_FILE_TEST_IS_REGULAR ) ) { + config_parse_xresource_options_file ( xetc ); + old_config_format = TRUE; + found_system = TRUE; + } + g_free ( xetc ); + } + g_free ( etc ); } - g_free ( xetc ); } - g_free ( etc ); + if ( ! found_system ) { + /** New format. */ + gchar *etc = g_build_filename ( SYSCONFDIR, "rofi.rasi", NULL ); + g_debug ( "Look for default config file: %s", etc ); + if ( g_file_test ( etc, G_FILE_TEST_IS_REGULAR ) ) { + g_debug ( "Look for default config file: %s", etc ); + rofi_theme_parse_file ( etc ); + } else { + /** Old format. */ + gchar *xetc = g_build_filename ( SYSCONFDIR, "rofi.conf", NULL ); + g_debug ( "Look for default config file: %s", xetc ); + if ( g_file_test ( xetc, G_FILE_TEST_IS_REGULAR ) ) { + config_parse_xresource_options_file ( xetc ); + old_config_format = TRUE; + } + g_free ( xetc ); + } + g_free ( etc ); + } // Load in config from X resources. config_parse_xresource_options ( xcb ); if ( config_path_new && g_file_test ( config_path_new, G_FILE_TEST_IS_REGULAR ) ) {