1
0
Fork 0
mirror of https://github.com/davatorium/rofi.git synced 2024-11-18 13:54:36 -05:00

Parse XDG_CONFIG_DIRS for default configuration file.

This commit is contained in:
Dave Davenport 2020-04-19 11:55:53 +02:00
parent 3a9c60804b
commit e7554da627
3 changed files with 49 additions and 17 deletions

View file

@ -69,7 +69,8 @@ Markup support can be enabled, see CONFIGURATION options.
.PP .PP
There are currently three methods of setting configuration options (evaluated in order below): There are currently three methods of setting configuration options (evaluated in order below):
.IP \(bu 2 .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 .IP \(bu 2
Xresources: A method of storing key values in the Xserver. See Xresources: A method of storing key values in the Xserver. See
here here

View file

@ -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): 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 * Xresources: A method of storing key values in the Xserver. See
[here](https://en.wikipedia.org/wiki/X_resources) for more information. [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. * Rasi theme file: The new *theme* format can be used to set configuration values.

View file

@ -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 ( "-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-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 ( "-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 ( "-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 ( "-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 ); 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" ); TICK_N ( "Setup abe" );
if ( find_arg ( "-no-config" ) < 0 ) { if ( find_arg ( "-no-config" ) < 0 ) {
gchar *etc = g_build_filename ( SYSCONFDIR, "rofi.rasi", NULL ); // Load distro default settings
g_debug ( "Testing: %s", etc ); gboolean found_system = FALSE;
if ( g_file_test ( etc, G_FILE_TEST_IS_REGULAR ) ) { const char * const * dirs = g_get_system_config_dirs();
g_debug ( "Parsing: %s", etc ); if ( dirs )
rofi_theme_parse_file ( etc ); {
} for ( unsigned int i =0; !found_system && dirs[i]; i++ ) {
else { /** New format. */
// Load distro default settings gchar *etc = g_build_filename ( dirs[i], "rofi.rasi", NULL );
gchar *xetc = g_build_filename ( SYSCONFDIR, "rofi.conf", NULL ); g_debug ( "Look for default config file: %s", etc );
if ( g_file_test ( xetc, G_FILE_TEST_IS_REGULAR ) ) { if ( g_file_test ( etc, G_FILE_TEST_IS_REGULAR ) ) {
config_parse_xresource_options_file ( xetc ); g_debug ( "Parsing: %s", etc );
old_config_format = TRUE; 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. // Load in config from X resources.
config_parse_xresource_options ( xcb ); config_parse_xresource_options ( xcb );
if ( config_path_new && g_file_test ( config_path_new, G_FILE_TEST_IS_REGULAR ) ) { if ( config_path_new && g_file_test ( config_path_new, G_FILE_TEST_IS_REGULAR ) ) {