summaryrefslogtreecommitdiffstats
path: root/source/rofi.c
diff options
context:
space:
mode:
authorDave Davenport <qball@gmpclient.org>2020-04-19 11:55:53 +0200
committerDave Davenport <qball@gmpclient.org>2020-04-19 11:55:53 +0200
commite7554da627cbb1c459b19cf51b5d284f4548a9ce (patch)
tree54683677baeba0d5f313079737c42cf9854dd29f /source/rofi.c
parent3a9c60804b0074f07b2165b3f2c1092459113440 (diff)
Parse XDG_CONFIG_DIRS for default configuration file.
Diffstat (limited to 'source/rofi.c')
-rw-r--r--source/rofi.c58
1 files changed, 44 insertions, 14 deletions
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 );
+ // 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 );
+ }
}
- 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;
+ 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 ( xetc );
+ g_free ( etc );
}
- 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 ) ) {