mirror of
https://github.com/davatorium/rofi.git
synced 2024-11-25 13:55:34 -05:00
Revert "Test config file before load, support ~/.config/rofi/theme and remove config_path global, fix loading dynamic options from /etc/rofi.conf"
This reverts commit 0c7d1a6b17
.
This commit is contained in:
parent
0c7d1a6b17
commit
1b4e5069f6
3 changed files with 38 additions and 46 deletions
|
@ -78,6 +78,7 @@ struct xkb_stuff xkb = {
|
||||||
.state = NULL
|
.state = NULL
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
char *config_path = NULL;
|
||||||
// Array of modi.
|
// Array of modi.
|
||||||
Mode **modi = NULL;
|
Mode **modi = NULL;
|
||||||
unsigned int num_modi = 0;
|
unsigned int num_modi = 0;
|
||||||
|
@ -336,6 +337,8 @@ static void cleanup ()
|
||||||
// Cleanup the custom keybinding
|
// Cleanup the custom keybinding
|
||||||
cleanup_abe ();
|
cleanup_abe ();
|
||||||
|
|
||||||
|
g_free ( config_path );
|
||||||
|
|
||||||
TIMINGS_STOP ();
|
TIMINGS_STOP ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -430,51 +433,24 @@ static void setup_modi ( void )
|
||||||
*/
|
*/
|
||||||
static inline void load_configuration ( )
|
static inline void load_configuration ( )
|
||||||
{
|
{
|
||||||
const char *cpath = g_get_user_config_dir ();
|
|
||||||
char *config_path = NULL;
|
|
||||||
// Load distro default settings
|
// Load distro default settings
|
||||||
gchar *etc = g_build_filename ( G_DIR_SEPARATOR_S, "etc", "rofi.conf", NULL );
|
gchar *etc = g_build_filename ( G_DIR_SEPARATOR_S, "etc", "rofi.conf", NULL );
|
||||||
if ( g_file_test ( etc, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_REGULAR ) ) {
|
if ( g_file_test ( etc, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_REGULAR ) ) {
|
||||||
config_parse_xresource_options_file ( etc );
|
config_parse_xresource_options_file ( etc );
|
||||||
config_parse_xresource_options_dynamic_file ( etc );
|
|
||||||
}
|
}
|
||||||
g_free ( etc );
|
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 );
|
||||||
config_parse_xresource_options_dynamic ( xcb );
|
|
||||||
|
|
||||||
if ( find_arg ( "-config" ) < 0 ) {
|
|
||||||
if ( cpath ) {
|
|
||||||
config_path = g_build_filename ( cpath, "rofi", "config", NULL );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
char *c = NULL;
|
|
||||||
find_arg_str ( "-config", &c );
|
|
||||||
config_path = rofi_expand_path ( c );
|
|
||||||
}
|
|
||||||
if ( config_path != NULL ) {
|
|
||||||
if ( g_file_test ( config_path, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_REGULAR ) ) {
|
|
||||||
// Load config from config file.
|
|
||||||
config_parse_xresource_options_file ( config_path );
|
config_parse_xresource_options_file ( config_path );
|
||||||
config_parse_xresource_options_dynamic_file ( config_path );
|
|
||||||
}
|
|
||||||
g_free ( config_path );
|
|
||||||
}
|
|
||||||
|
|
||||||
// Load theme file
|
|
||||||
if ( cpath ) {
|
|
||||||
char *theme_path = g_build_filename ( cpath, "rofi", "theme", NULL );
|
|
||||||
if ( g_file_test ( theme_path, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_REGULAR ) ) {
|
|
||||||
config_parse_xresource_options_file ( theme_path );
|
|
||||||
config_parse_xresource_options_dynamic_file ( theme_path );
|
|
||||||
}
|
|
||||||
g_free ( theme_path );
|
|
||||||
}
|
|
||||||
|
|
||||||
// Parse command line for settings.
|
// Parse command line for settings.
|
||||||
config_parse_cmd_options ( );
|
config_parse_cmd_options ( );
|
||||||
|
}
|
||||||
|
static inline void load_configuration_dynamic ( )
|
||||||
|
{
|
||||||
|
// Load in config from X resources.
|
||||||
|
config_parse_xresource_options_dynamic ( xcb );
|
||||||
|
config_parse_xresource_options_dynamic_file ( config_path );
|
||||||
config_parse_cmd_options_dynamic ( );
|
config_parse_cmd_options_dynamic ( );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -667,6 +643,18 @@ int main ( int argc, char *argv[] )
|
||||||
}
|
}
|
||||||
config_parser_add_option ( xrm_String, "pid", (void * *) &pidfile, "Pidfile location" );
|
config_parser_add_option ( xrm_String, "pid", (void * *) &pidfile, "Pidfile location" );
|
||||||
|
|
||||||
|
if ( find_arg ( "-config" ) < 0 ) {
|
||||||
|
const char *cpath = g_get_user_config_dir ();
|
||||||
|
if ( cpath ) {
|
||||||
|
config_path = g_build_filename ( cpath, "rofi", "config", NULL );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
char *c = NULL;
|
||||||
|
find_arg_str ( "-config", &c );
|
||||||
|
config_path = rofi_expand_path ( c );
|
||||||
|
}
|
||||||
|
|
||||||
TICK ();
|
TICK ();
|
||||||
// Register cleanup function.
|
// Register cleanup function.
|
||||||
atexit ( cleanup );
|
atexit ( cleanup );
|
||||||
|
@ -818,6 +806,9 @@ int main ( int argc, char *argv[] )
|
||||||
setup_abe ();
|
setup_abe ();
|
||||||
TICK_N ( "Setup abe" );
|
TICK_N ( "Setup abe" );
|
||||||
|
|
||||||
|
if ( find_arg ( "-no-config" ) < 0 ) {
|
||||||
|
load_configuration ( );
|
||||||
|
}
|
||||||
if ( !dmenu_mode ) {
|
if ( !dmenu_mode ) {
|
||||||
// setup_modi
|
// setup_modi
|
||||||
setup_modi ();
|
setup_modi ();
|
||||||
|
@ -827,7 +818,8 @@ int main ( int argc, char *argv[] )
|
||||||
config_parser_add_option ( xrm_Char, "sep", (void * *) &( config.separator ), "Element separator" );
|
config_parser_add_option ( xrm_Char, "sep", (void * *) &( config.separator ), "Element separator" );
|
||||||
}
|
}
|
||||||
if ( find_arg ( "-no-config" ) < 0 ) {
|
if ( find_arg ( "-no-config" ) < 0 ) {
|
||||||
load_configuration ( );
|
// Reload for dynamic part.
|
||||||
|
load_configuration_dynamic ( );
|
||||||
}
|
}
|
||||||
// Dump.
|
// Dump.
|
||||||
// catch help request
|
// catch help request
|
||||||
|
|
Loading…
Reference in a new issue