mirror of
https://github.com/lbonn/rofi
synced 2024-11-23 04:13:03 +00: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:
parent
0c3d24136d
commit
9f71c4f78d
8 changed files with 47 additions and 2 deletions
|
@ -256,6 +256,7 @@ EXTRA_DIST+=\
|
||||||
script/get_git_rev.sh\
|
script/get_git_rev.sh\
|
||||||
$(theme_DATA)\
|
$(theme_DATA)\
|
||||||
doc/default_theme.rasi\
|
doc/default_theme.rasi\
|
||||||
|
doc/default_configuration.rasi\
|
||||||
Changelog
|
Changelog
|
||||||
##
|
##
|
||||||
# Indent
|
# Indent
|
||||||
|
|
11
doc/default_configuration.rasi
Normal file
11
doc/default_configuration.rasi
Normal 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";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -111,6 +111,7 @@ ThemeWidget *rofi_theme_find_or_create_name ( ThemeWidget *base, const char *nam
|
||||||
* Print out the widget to the commandline.
|
* Print out the widget to the commandline.
|
||||||
*/
|
*/
|
||||||
void rofi_theme_print ( ThemeWidget *widget );
|
void rofi_theme_print ( ThemeWidget *widget );
|
||||||
|
void rofi_theme_print_index ( ThemeWidget *widget, int index );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param type The type of the property to create.
|
* @param type The type of the property to create.
|
||||||
|
|
|
@ -2,5 +2,6 @@
|
||||||
<gresources>
|
<gresources>
|
||||||
<gresource prefix="/org/qtools/rofi">
|
<gresource prefix="/org/qtools/rofi">
|
||||||
<file alias="default_theme.rasi">doc/default_theme.rasi</file>
|
<file alias="default_theme.rasi">doc/default_theme.rasi</file>
|
||||||
|
<file alias="default_configuration.rasi">doc/default_configuration.rasi</file>
|
||||||
</gresource>
|
</gresource>
|
||||||
</gresources>
|
</gresources>
|
||||||
|
|
|
@ -856,6 +856,33 @@ 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" );
|
||||||
|
|
||||||
|
|
||||||
|
/** 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 ) {
|
if ( find_arg ( "-config" ) < 0 ) {
|
||||||
const char *cpath = g_get_user_config_dir ();
|
const char *cpath = g_get_user_config_dir ();
|
||||||
if ( cpath ) {
|
if ( cpath ) {
|
||||||
|
|
|
@ -503,7 +503,7 @@ static void rofi_theme_print_property_index ( size_t pnl, int depth, Property *p
|
||||||
putchar ( '\n' );
|
putchar ( '\n' );
|
||||||
}
|
}
|
||||||
|
|
||||||
static void rofi_theme_print_index ( ThemeWidget *widget, int index )
|
void rofi_theme_print_index ( ThemeWidget *widget, int index )
|
||||||
{
|
{
|
||||||
GHashTableIter iter;
|
GHashTableIter iter;
|
||||||
gpointer key, value;
|
gpointer key, value;
|
||||||
|
|
|
@ -511,7 +511,7 @@ static void rofi_view_set_user_timeout ( G_GNUC_UNUSED gpointer data )
|
||||||
if ( wid ) {
|
if ( wid ) {
|
||||||
/** Check string property */
|
/** Check string property */
|
||||||
Property *p = rofi_theme_find_property ( wid, P_INTEGER, "delay", TRUE);
|
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;
|
int delay = p->value.i;
|
||||||
CacheState.user_timeout = g_timeout_add ( delay*1000 , rofi_view_user_timeout, NULL );
|
CacheState.user_timeout = g_timeout_add ( delay*1000 , rofi_view_user_timeout, NULL );
|
||||||
}
|
}
|
||||||
|
|
|
@ -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" );
|
fprintf ( out, "}\n" );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue