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

@ -70,6 +70,7 @@ Markup support can be enabled, see CONFIGURATION options.
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).
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

View file

@ -54,6 +54,7 @@ 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`).
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.

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 ( "-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,15 +868,44 @@ 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 );
// 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;
}
else {
// Load distro default settings
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;
@ -884,6 +913,7 @@ int main ( int argc, char *argv[] )
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 ) ) {