summaryrefslogtreecommitdiffstats
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
parent3a9c60804b0074f07b2165b3f2c1092459113440 (diff)
Parse XDG_CONFIG_DIRS for default configuration file.
-rw-r--r--doc/rofi.13
-rw-r--r--doc/rofi.1.markdown3
-rw-r--r--source/rofi.c58
3 files changed, 48 insertions, 16 deletions
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 );
+ // 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 ) ) {