35 #include <xcb/xcb_xrm.h> 87 "Enabled modi", CONFIG_DEFAULT },
89 "Window width", CONFIG_DEFAULT },
91 "Number of lines", CONFIG_DEFAULT },
93 "Number of columns", CONFIG_DEFAULT },
96 "Font to use", CONFIG_DEFAULT },
100 "Border width", CONFIG_DEFAULT },
103 "Location on screen", CONFIG_DEFAULT },
106 "Padding", CONFIG_DEFAULT },
108 "Y-offset relative to location", CONFIG_DEFAULT },
110 "X-offset relative to location", CONFIG_DEFAULT },
112 "Always show number of lines", CONFIG_DEFAULT },
115 "Whether to load and show icons", CONFIG_DEFAULT },
118 "Terminal to use", CONFIG_DEFAULT },
120 "Ssh client to use", CONFIG_DEFAULT },
122 "Ssh command to execute", CONFIG_DEFAULT },
124 "Run command to execute", CONFIG_DEFAULT },
126 "Command to get extra run targets", CONFIG_DEFAULT },
128 "Run command to execute that runs in shell", CONFIG_DEFAULT },
130 "Command executed on accep-entry-custom for window modus", CONFIG_DEFAULT },
132 "Window fields to match in window mode", CONFIG_DEFAULT },
134 "Theme to use to look for icons", CONFIG_DEFAULT },
137 "Desktop entry fields to match in drun", CONFIG_DEFAULT },
139 "Desktop entry show actions.", CONFIG_DEFAULT },
141 "DRUN format string. (Supports: generic,name,comment,exec,categories)", CONFIG_DEFAULT },
143 "Disable history in run/ssh", CONFIG_DEFAULT },
145 "Programs ignored for history", CONFIG_DEFAULT },
147 "Use sorting", CONFIG_DEFAULT },
149 "Choose the strategy used for sorting: normal (levenshtein) or fzf.", CONFIG_DEFAULT },
151 "Set case-sensitivity", CONFIG_DEFAULT },
153 "Cycle through the results list", CONFIG_DEFAULT },
155 "Enable sidebar-mode", CONFIG_DEFAULT },
157 "Row height (in chars)", CONFIG_DEFAULT },
159 "Enable auto select mode", CONFIG_DEFAULT },
161 "Parse hosts file for ssh mode", CONFIG_DEFAULT },
163 "Parse known_hosts file for ssh mode", CONFIG_DEFAULT },
165 "Set the modi to combine in combi mode", CONFIG_DEFAULT },
167 "Set the matching algorithm. (normal, regex, glob, fuzzy)", CONFIG_DEFAULT },
169 "Tokenize input string", CONFIG_DEFAULT },
171 "", CONFIG_DEFAULT },
174 "Monitor id to show on", CONFIG_DEFAULT },
176 "Margin between rows *DEPRECATED*", CONFIG_DEFAULT },
178 "Padding within rows *DEPRECATED*", CONFIG_DEFAULT },
180 "Pre-set filter", CONFIG_DEFAULT },
182 "Separator style (none, dash, solid) *DEPRECATED*", CONFIG_DEFAULT },
184 "Hide scroll-bar *DEPRECATED*", CONFIG_DEFAULT },
186 "Fullscreen", CONFIG_DEFAULT },
188 "Fake transparency *DEPRECATED*", CONFIG_DEFAULT },
190 "DPI", CONFIG_DEFAULT },
192 "Threads to use for string matching", CONFIG_DEFAULT },
194 "Scrollbar width *DEPRECATED*", CONFIG_DEFAULT },
196 "Scrolling method. (0: Page, 1: Centered)", CONFIG_DEFAULT },
198 "Background to use for fake transparency. (background or screenshot) *DEPRECATED*", CONFIG_DEFAULT },
200 "Window Format. w (desktop name), t (title), n (name), r (role), c (class)", CONFIG_DEFAULT },
202 "Click outside the window to exit", CONFIG_DEFAULT },
204 "Indicate how it match by underlining it.", CONFIG_DEFAULT },
206 "New style theme file", CONFIG_DEFAULT },
208 "Color scheme for normal row", CONFIG_DEFAULT },
210 "Color scheme for urgent row", CONFIG_DEFAULT },
212 "Color scheme for active row", CONFIG_DEFAULT },
214 "Color scheme window", CONFIG_DEFAULT },
216 "Max history size (WARNING: can cause slowdowns when set to high).", CONFIG_DEFAULT },
218 "Hide the prefix mode prefix on the combi view.", CONFIG_DEFAULT },
220 "Set the character used to negate the matching. ('\\0' to disable)", CONFIG_DEFAULT },
222 "Directory where history and temporary files are stored.", CONFIG_DEFAULT },
254 switch ( option->
type )
257 if ( ( option )->mem != NULL ) {
258 g_free ( option->
mem );
261 *( option->
value.
str ) = g_strchomp ( g_strdup ( xrmValue ) );
264 ( option )->mem = *( option->
value.
str );
267 *( option->
value.
num ) = (
unsigned int) g_ascii_strtoull ( xrmValue, NULL, 10 );
270 *( option->
value.
snum ) = (
int) g_ascii_strtoll ( xrmValue, NULL, 10 );
273 if ( strlen ( xrmValue ) > 0 &&
274 g_ascii_strcasecmp ( xrmValue,
"true" ) == 0 ) {
290 const char * namePrefix =
"rofi";
293 char *name = g_strdup_printf (
"%s.%s", namePrefix, xrmOptions[i].name );
295 char *xrmValue = NULL;
296 if ( xcb_xrm_resource_get_string ( xDB, name, NULL, &xrmValue ) == 0 ) {
308 const char * namePrefix =
"rofi";
313 name = g_strdup_printf (
"%s.%s", namePrefix, extra_options[i].name );
314 char *xrmValue = NULL;
315 if ( xcb_xrm_resource_get_string ( xDB, name, NULL, &xrmValue ) == 0 ) {
327 xcb_xrm_database_t *xDB = xcb_xrm_database_from_default ( xcb->
connection );
331 xcb_xrm_database_free ( xDB );
340 xcb_xrm_database_t *xDB = xcb_xrm_database_from_file ( filename );
346 xcb_xrm_database_free ( xDB );
355 char *key = g_strdup_printf (
"-%s", option->
name );
356 switch ( option->
type )
370 if ( option->
mem != NULL ) {
371 g_free ( option->
mem );
384 key = g_strdup_printf (
"-no-%s", option->
name );
418 *error = g_strdup_printf (
"Option: %s needs to be set with a string not a %s.", option->
name,
PropertyTypeName[p->
type] );
423 for ( GList *iter = p->
value.
list; iter != NULL; iter = g_list_next ( iter ) ) {
424 if ( value == NULL ) {
425 value = g_strdup ( (
char *) ( iter->data ) );
428 char *nv = g_strjoin (
",", value, (
char *) ( iter->data ), NULL );
435 value = g_strdup ( p->
value.
s );
437 if ( ( option )->mem != NULL ) {
438 g_free ( option->
mem );
444 ( option )->mem = *( option->
value.
str );
449 *error = g_strdup_printf (
"Option: %s needs to be set with a number not a %s.", option->
name,
PropertyTypeName[p->
type] );
457 *error = g_strdup_printf (
"Option: %s needs to be set with a number not a %s.", option->
name,
PropertyTypeName[p->
type] );
465 *error = g_strdup_printf (
"Option: %s needs to be set with a boolean not a %s.", option->
name,
PropertyTypeName[p->
type] );
483 if ( g_strcmp0 ( op->
name, p->
name ) == 0 ) {
489 if ( g_strcmp0 ( op->
name, p->
name ) == 0 ) {
493 *error = g_strdup_printf (
"Option: %s is not found.", p->
name );
499 for (
unsigned int i = 0; i < (
sizeof (
xrmOptions ) /
sizeof ( *xrmOptions ) ); ++i ) {
500 if ( xrmOptions[i].mem != NULL ) {
501 g_free ( xrmOptions[i].mem );
502 xrmOptions[i].
mem = NULL;
506 if ( extra_options[i].mem != NULL ) {
507 g_free ( extra_options[i].mem );
508 extra_options[i].
mem = NULL;
511 if ( extra_options != NULL ) {
512 g_free ( extra_options );
518 printf (
"! \"%s\" ", option->
comment );
523 printf (
"%s.%s: %*s", namePrefix, option->
name,
524 (
int) ( 30 - strlen ( option->
name ) ),
"" );
525 switch ( option->
type )
528 printf (
"%u", *( option->
value.
num ) );
531 printf (
"%i", *( option->
value.
snum ) );
534 if ( ( *( option->
value.
str ) ) != NULL ) {
535 printf (
"%s", *( option->
value.
str ) );
539 printf (
"%s", ( *( option->
value.
num ) == TRUE ) ?
"true" :
"false" );
546 printf (
"\\x%02X", *( option->
value.
charc ) );
557 const char * namePrefix =
"rofi";
558 unsigned int entries =
sizeof (
xrmOptions ) /
sizeof ( *xrmOptions );
559 for (
unsigned int i = 0; i < entries; ++i ) {
561 if ( ( i + 1 ) < entries ) {
562 if ( xrmOptions[i].value.
str == xrmOptions[i + 1].
value.
str ) {
578 printf (
"\t%s: ", option->
name );
579 switch ( option->
type )
582 printf (
"%u", *( option->
value.
num ) );
585 printf (
"%i", *( option->
value.
snum ) );
588 if ( ( *( option->
value.
str ) ) != NULL ) {
590 printf (
"\"%s\"", *( option->
value.
str ) );
594 printf (
"%s", ( *( option->
value.
num ) == TRUE ) ?
"true" :
"false" );
602 printf (
"'\\x%02X'", *( option->
value.
charc ) );
604 printf (
" /* unsupported */" );
619 printf (
"configuration {\n" );
621 unsigned int entries =
sizeof (
xrmOptions ) /
sizeof ( *xrmOptions );
622 for (
unsigned int i = 0; i < entries; ++i ) {
624 if ( ( i + 1 ) < entries ) {
625 if ( xrmOptions[i].value.
str == xrmOptions[i + 1].
value.
str ) {
644 int l = strlen ( xo->
name );
651 printf (
"\t-%s [string]%-*c%s\n", xo->
name, 30 - l,
' ', xo->
comment );
652 printf (
"\t\t%s", ( *( xo->
value.
str ) == NULL ) ?
"(unset)" : ( *( xo->
value.
str ) ) );
658 int l = strlen ( xo->
name );
665 printf (
"\t-%s [number]%-*c%s\n", xo->
name, 30 - l,
' ', xo->
comment );
666 printf (
"\t\t%u", *( xo->
value.
num ) );
672 int l = strlen ( xo->
name );
679 printf (
"\t-%s [number]%-*c%s\n", xo->
name, 30 - l,
' ', xo->
comment );
680 printf (
"\t\t%d", *( xo->
value.
snum ) );
686 int l = strlen ( xo->
name );
693 printf (
"\t-%s [character]%-*c%s\n", xo->
name, 30 - l,
' ', xo->
comment );
700 int l = strlen ( xo->
name );
707 printf (
"\t-[no-]%s %-*c%s\n", xo->
name, 33 - l,
' ', xo->
comment );
708 printf (
"\t\t%s", ( *( xo->
value.
snum ) ) ?
"True" :
"False" );
739 int is_term = isatty ( fileno ( stdout ) );
740 unsigned int entries =
sizeof (
xrmOptions ) /
sizeof ( *xrmOptions );
741 for (
unsigned int i = 0; i < entries; ++i ) {
742 if ( ( i + 1 ) < entries ) {
743 if ( xrmOptions[i].value.
str == xrmOptions[i + 1].
value.
str ) {
754 void print_help_msg (
const char *option,
const char *type,
const char*text,
const char *def,
int isatty )
756 int l = 37 - strlen ( option ) - strlen ( type );
764 printf (
"\t%s %s %-*c%s\n", option, type, l,
' ', text );
766 printf (
"\t\t%s\n", def );
774 switch ( option->
type )
777 return g_markup_printf_escaped (
"<b%-*s</b> (%u) <span style='italic' size='small'>%s</span>",
780 return g_markup_printf_escaped (
"<b%-*s</b> (%d) <span style='italic' size='small'>%s</span>",
783 return g_markup_printf_escaped (
"<b>%-*s</b> (%s) <span style='italic' size='small'>%s</span>",
789 return g_markup_printf_escaped (
"<b>%-*s</b> (%s) <span style='italic' size='small'>%s</span>",
790 ll, option->
name, ( *( option->
value.
num ) == TRUE ) ?
"true" :
"false", option->
comment );
793 return g_markup_printf_escaped (
"<b>%-*s</b> (%c) <span style='italic' size='small'>%s</span>",
797 return g_markup_printf_escaped (
"<b%-*s</b> (\\x%02X) <span style='italic' size='small'>%s</span>",
804 return g_strdup (
"failed" );
809 unsigned int entries =
sizeof (
xrmOptions ) /
sizeof ( *xrmOptions );
814 size_t max_length = 0;
815 for (
unsigned int i = 0; i < entries; ++i ) {
816 size_t l = strlen ( xrmOptions[i].name );
817 max_length = MAX ( max_length, l );
820 size_t l = strlen ( extra_options[i].name );
821 max_length = MAX ( max_length, l );
826 for (
unsigned int i = 0; i < entries; ++i ) {
827 if ( ( i + 1 ) < entries ) {
828 if ( xrmOptions[i].value.
str == xrmOptions[i + 1].
value.
str ) {
832 if ( strncmp ( xrmOptions[i].name,
"kb", 2 ) != 0 && strncmp ( xrmOptions[i].name,
"ml", 2 ) != 0 && strncmp ( xrmOptions[i].name,
"me", 2 ) != 0 ) {
836 retv = g_realloc ( retv, ( ( *length ) + 2 ) *
sizeof (
char* ) );
842 if ( strncmp ( extra_options[i].name,
"kb", 2 ) != 0 && strncmp ( extra_options[i].name,
"ml", 2 ) != 0 && strncmp ( extra_options[i].name,
"me", 2 ) != 0 ) {
845 retv = g_realloc ( retv, ( ( *length ) + 2 ) *
sizeof (
char* ) );
849 if ( ( *length ) > 0 ) {
850 retv[( *length )] = NULL;
static void print_option_string(XrmOption *xo, int is_term)
static XrmOption xrmOptions[]
unsigned int fake_transparency
static void xresource_dump_entry(const char *namePrefix, XrmOption *option)
int find_arg_char(const char *const key, char *val)
unsigned int case_sensitive
union XrmOption::@2 value
unsigned int sidebar_mode
unsigned int parse_known_hosts
unsigned int menu_columns
char * drun_display_format
static void config_parse_cmd_option(XrmOption *option)
void config_parse_xresource_dump(void)
unsigned int scroll_method
unsigned int scrollbar_width
gboolean combi_hide_mode_prefix
int find_arg_uint(const char *const key, unsigned int *val)
int find_arg_str(const char *const key, char **val)
int find_arg_int(const char *const key, int *val)
static char * config_parser_return_display_help_entry(XrmOption *option, size_t l)
void config_parse_xresource_options_file(const char *filename)
static void print_option(XrmOption *xo, int is_term)
unsigned int max_history_size
void print_help_msg(const char *option, const char *type, const char *text, const char *def, int isatty)
void config_parse_xresource_options(xcb_stuff *xcb)
static void print_option_number(XrmOption *xo, int is_term)
char * window_match_fields
void config_xresource_free(void)
static void __config_parse_xresource_options(xcb_xrm_database_t *xDB, enum ConfigSource source)
static void print_option_char(XrmOption *xo, int is_term)
static void print_option_boolean(XrmOption *xo, int is_term)
char ** config_parser_return_display_help(unsigned int *length)
xcb_connection_t * connection
unsigned int drun_show_actions
static void print_option_snumber(XrmOption *xo, int is_term)
static void config_parser_set(XrmOption *option, char *xrmValue, enum ConfigSource source)
static void __config_parse_xresource_options_dynamic(xcb_xrm_database_t *xDB, enum ConfigSource source)
static void config_parse_dump_config_option(XrmOption *option)
unsigned int hide_scrollbar
const char *const PropertyTypeName[P_NUM_TYPES]
void config_parse_dump_config_rasi_format(gboolean changes)
Dump configuration in rasi format.
char matching_negate_char
void config_parse_cmd_options(void)
int find_arg(const char *const key)
gboolean config_parse_set_property(const Property *p, char **error)
Set config option.
void config_parser_add_option(XrmOptionType type, const char *key, void **value, const char *comment)
static gboolean __config_parser_set_property(XrmOption *option, const Property *p, char **error)
char helper_parse_char(const char *arg)
unsigned int num_extra_options
unsigned int disable_history
unsigned int fixed_num_lines
XrmOption * extra_options
unsigned int line_padding
const char *const ConfigSourceStr[]