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

[Config] Load default config file in at startup

* load via resources doc/default_configuration.rasi
* print the configuration options on dump-config
This commit is contained in:
Dave Davenport 2021-07-10 00:25:20 +02:00
parent 0c3d24136d
commit 9f71c4f78d
8 changed files with 47 additions and 2 deletions

View file

@ -256,6 +256,7 @@ EXTRA_DIST+=\
script/get_git_rev.sh\
$(theme_DATA)\
doc/default_theme.rasi\
doc/default_configuration.rasi\
Changelog
##
# Indent

View file

@ -0,0 +1,11 @@
configuration {
// Timeout from user input.
timeout {
// The delay after inactivity to execute action.
delay: 0;
// The action to execute once the delay expires.
action: "kb-cancel";
}
}

View file

@ -111,6 +111,7 @@ ThemeWidget *rofi_theme_find_or_create_name ( ThemeWidget *base, const char *nam
* Print out the widget to the commandline.
*/
void rofi_theme_print ( ThemeWidget *widget );
void rofi_theme_print_index ( ThemeWidget *widget, int index );
/**
* @param type The type of the property to create.

View file

@ -2,5 +2,6 @@
<gresources>
<gresource prefix="/org/qtools/rofi">
<file alias="default_theme.rasi">doc/default_theme.rasi</file>
<file alias="default_configuration.rasi">doc/default_configuration.rasi</file>
</gresource>
</gresources>

View file

@ -856,6 +856,33 @@ int main ( int argc, char *argv[] )
}
config_parser_add_option ( xrm_String, "pid", (void * *) &pidfile, "Pidfile location" );
/** default configuration */
{
GBytes *theme_data = g_resource_lookup_data (
resources_get_resource (),
"/org/qtools/rofi/default_configuration.rasi",
G_RESOURCE_LOOKUP_FLAGS_NONE,
NULL );
if ( theme_data ) {
const char *theme = g_bytes_get_data ( theme_data, NULL );
if ( rofi_theme_parse_string ( (const char *) theme ) ) {
g_warning ( "Failed to parse default configuration. Giving up.." );
if ( list_of_error_msgs ) {
for ( GList *iter = g_list_first ( list_of_error_msgs );
iter != NULL; iter = g_list_next ( iter ) ) {
g_warning ( "Error: %s%s%s",
color_bold, ( (GString *) iter->data )->str, color_reset );
}
}
rofi_configuration = NULL;
cleanup ();
return EXIT_FAILURE;
}
g_bytes_unref ( theme_data );
}
}
if ( find_arg ( "-config" ) < 0 ) {
const char *cpath = g_get_user_config_dir ();
if ( cpath ) {

View file

@ -503,7 +503,7 @@ static void rofi_theme_print_property_index ( size_t pnl, int depth, Property *p
putchar ( '\n' );
}
static void rofi_theme_print_index ( ThemeWidget *widget, int index )
void rofi_theme_print_index ( ThemeWidget *widget, int index )
{
GHashTableIter iter;
gpointer key, value;

View file

@ -511,7 +511,7 @@ static void rofi_view_set_user_timeout ( G_GNUC_UNUSED gpointer data )
if ( wid ) {
/** Check string property */
Property *p = rofi_theme_find_property ( wid, P_INTEGER, "delay", TRUE);
if ( p != NULL && p->type == P_INTEGER) {
if ( p != NULL && p->type == P_INTEGER && p->value.i > 0 ) {
int delay = p->value.i;
CacheState.user_timeout = g_timeout_add ( delay*1000 , rofi_view_user_timeout, NULL );
}

View file

@ -553,6 +553,10 @@ void config_parse_dump_config_rasi_format ( FILE *out, gboolean changes )
}
}
for ( unsigned int index = 0; index < rofi_configuration->num_widgets; index ++ ) {
rofi_theme_print_index ( rofi_configuration->widgets[index], 2 );
}
fprintf ( out, "}\n" );
}