Merge the configuration loading into something more simple (1)

This commit is contained in:
Dave Davenport 2017-03-28 17:03:46 +02:00
parent 439532450a
commit 7b30846408
1 changed files with 26 additions and 50 deletions

View File

@ -542,7 +542,6 @@ static int add_mode ( const char * token )
Mode *sw = script_switcher_parse_setup ( token ); Mode *sw = script_switcher_parse_setup ( token );
if ( sw != NULL ) { if ( sw != NULL ) {
modi[num_modi] = sw; modi[num_modi] = sw;
mode_set_config ( sw );
num_modi++; num_modi++;
} }
else { else {
@ -564,36 +563,6 @@ static void setup_modi ( void )
} }
// Free string that was modified by strtok_r // Free string that was modified by strtok_r
g_free ( switcher_str ); g_free ( switcher_str );
rofi_collect_modi_setup ();
}
/**
* Load configuration.
* Following priority: (current), X, commandline arguments
*/
static inline void load_configuration ( )
{
// Load distro default settings
gchar *etc = g_build_filename ( SYSCONFDIR, "rofi.conf", NULL );
if ( g_file_test ( etc, G_FILE_TEST_IS_REGULAR ) ) {
config_parse_xresource_options_file ( etc );
}
g_free ( etc );
// Load in config from X resources.
config_parse_xresource_options ( xcb );
config_parse_xresource_options_file ( config_path );
}
static inline void load_configuration_dynamic ( )
{
// Load distro default settings
gchar *etc = g_build_filename ( SYSCONFDIR, "rofi.conf", NULL );
if ( g_file_test ( etc, G_FILE_TEST_IS_REGULAR ) ) {
config_parse_xresource_options_dynamic_file ( etc );
}
g_free ( etc );
// Load in config from X resources.
config_parse_xresource_options_dynamic ( xcb );
config_parse_xresource_options_dynamic_file ( config_path );
} }
/** /**
@ -938,6 +907,7 @@ int main ( int argc, char *argv[] )
TICK_N ( "Open Display" ); TICK_N ( "Open Display" );
rofi_collect_modi (); rofi_collect_modi ();
rofi_collect_modi_setup ();
TICK_N ( "Collect MODI" ); TICK_N ( "Collect MODI" );
xcb->screen = xcb_aux_get_screen ( xcb->connection, xcb->screen_nbr ); xcb->screen = xcb_aux_get_screen ( xcb->connection, xcb->screen_nbr );
@ -1071,26 +1041,20 @@ 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 ) {
load_configuration ( ); // Load distro default settings
gchar *etc = g_build_filename ( SYSCONFDIR, "rofi.conf", NULL );
if ( g_file_test ( etc, G_FILE_TEST_IS_REGULAR ) ) {
config_parse_xresource_options_file ( etc );
config_parse_xresource_options_dynamic_file ( etc );
} }
// Parse command line for settings, independent of other -no-config. g_free ( etc );
config_parse_cmd_options ( ); // Load in config from X resources.
config_parse_xresource_options ( xcb );
if ( !dmenu_mode ) { config_parse_xresource_options_dynamic ( xcb );
// setup_modi config_parse_xresource_options_file ( config_path );
setup_modi (); config_parse_xresource_options_dynamic_file ( config_path );
TICK_N ( "Setup Modi" );
}
if ( find_arg ( "-no-config" ) < 0 ) {
// Reload for dynamic part.
load_configuration_dynamic ( );
TICK_N ( "Load config dynamic" );
}
// Parse command line for settings, independent of other -no-config.
config_parse_cmd_options_dynamic ( );
TICK_N ( "Load cmd config dynamic" );
find_arg_str ( "-theme", &(config.theme));
if ( config.theme ) { if ( config.theme ) {
TICK_N ( "Parse theme" ); TICK_N ( "Parse theme" );
if ( rofi_theme_parse_file ( config.theme ) ) { if ( rofi_theme_parse_file ( config.theme ) ) {
@ -1100,6 +1064,18 @@ int main ( int argc, char *argv[] )
} }
TICK_N ( "Parsed theme" ); TICK_N ( "Parsed theme" );
} }
}
// Parse command line for settings, independent of other -no-config.
config_parse_cmd_options ( );
config_parse_cmd_options_dynamic ( );
TICK_N ( "Load cmd config " );
if ( !dmenu_mode ) {
// setup_modi
setup_modi ();
TICK_N ( "Setup Modi" );
}
const char ** theme_str = find_arg_strv ( "-theme-str" ); const char ** theme_str = find_arg_strv ( "-theme-str" );
if ( theme_str ) { if ( theme_str ) {