35 #include <xcb/xcb_xrm.h> 130 "Command to executed when -kb-accept-alt binding is hit on selected window ",
CONFIG_DEFAULT },
139 "Only show Desktop entry from these categories",
CONFIG_DEFAULT },
143 "DRUN format string. (Supports: generic,name,comment,exec,categories)",
CONFIG_DEFAULT },
145 "Command to open an Desktop Entry that is a Link.",
CONFIG_DEFAULT },
154 "Choose the strategy used for sorting: normal (levenshtein) or fzf.",
CONFIG_DEFAULT },
172 "Set the matching algorithm. (normal, regex, glob, fuzzy)",
CONFIG_DEFAULT },
187 "Separator style (none, dash, solid) *DEPRECATED*",
CONFIG_DEFAULT },
203 "Background to use for fake transparency. (background or screenshot) *DEPRECATED*",
CONFIG_DEFAULT },
205 "Window Format. w (desktop name), t (title), n (name), r (role), c (class)",
CONFIG_DEFAULT },
221 "Max history size (WARNING: can cause slowdowns when set to high).",
CONFIG_DEFAULT },
223 "Hide the prefix mode prefix on the combi view.",
CONFIG_DEFAULT },
225 "Set the character used to negate the matching. ('\\0' to disable)",
CONFIG_DEFAULT },
227 "Directory where history and temporary files are stored.",
CONFIG_DEFAULT },
229 "Show window thumbnail (if available) as icon in window switcher.",
CONFIG_DEFAULT },
231 "DRUN: build and use a cache with desktop file content.",
CONFIG_DEFAULT },
233 "DRUN: If enabled, reload the cache with desktop file content.",
CONFIG_DEFAULT },
235 "Normalize string when matching (implies -no-show-match).",
CONFIG_DEFAULT },
267 switch ( option->
type )
270 if ( ( option )->mem != NULL ) {
271 g_free ( option->
mem );
274 *( option->
value.
str ) = g_strchomp ( g_strdup ( xrmValue ) );
277 ( option )->mem = *( option->
value.
str );
280 *( option->
value.
num ) = (
unsigned int) g_ascii_strtoull ( xrmValue, NULL, 10 );
283 *( option->
value.
snum ) = (
int) g_ascii_strtoll ( xrmValue, NULL, 10 );
286 if ( strlen ( xrmValue ) > 0 &&
287 g_ascii_strcasecmp ( xrmValue,
"true" ) == 0 ) {
303 const char * namePrefix =
"rofi";
306 char *name = g_strdup_printf (
"%s.%s", namePrefix,
xrmOptions[i].name );
308 char *xrmValue = NULL;
309 if ( xcb_xrm_resource_get_string ( xDB, name, NULL, &xrmValue ) == 0 ) {
321 const char * namePrefix =
"rofi";
326 name = g_strdup_printf (
"%s.%s", namePrefix,
extra_options[i].name );
327 char *xrmValue = NULL;
328 if ( xcb_xrm_resource_get_string ( xDB, name, NULL, &xrmValue ) == 0 ) {
340 xcb_xrm_database_t *xDB = xcb_xrm_database_from_default (
xcb->
connection );
344 xcb_xrm_database_free ( xDB );
353 xcb_xrm_database_t *xDB = xcb_xrm_database_from_file ( filename );
359 xcb_xrm_database_free ( xDB );
368 char *key = g_strdup_printf (
"-%s", option->
name );
369 switch ( option->
type )
383 if ( option->
mem != NULL ) {
384 g_free ( option->
mem );
397 key = g_strdup_printf (
"-no-%s", option->
name );
431 *error = g_strdup_printf (
"Option: %s needs to be set with a string not a %s.", option->
name,
PropertyTypeName[p->
type] );
436 for ( GList *iter = p->
value.
list; iter != NULL; iter = g_list_next ( iter ) ) {
437 if ( value == NULL ) {
438 value = g_strdup ( (
char *) ( iter->data ) );
441 char *nv = g_strjoin (
",", value, (
char *) ( iter->data ), NULL );
448 value = g_strdup ( p->
value.
s );
450 if ( ( option )->mem != NULL ) {
451 g_free ( option->
mem );
457 ( option )->mem = *( option->
value.
str );
462 *error = g_strdup_printf (
"Option: %s needs to be set with a number not a %s.", option->
name,
PropertyTypeName[p->
type] );
470 *error = g_strdup_printf (
"Option: %s needs to be set with a number not a %s.", option->
name,
PropertyTypeName[p->
type] );
478 *error = g_strdup_printf (
"Option: %s needs to be set with a boolean not a %s.", option->
name,
PropertyTypeName[p->
type] );
486 *error = g_strdup_printf (
"Option: %s needs to be set with a character not a %s.", option->
name,
PropertyTypeName[p->
type] );
504 if ( g_strcmp0 ( op->
name, p->
name ) == 0 ) {
510 if ( g_strcmp0 ( op->
name, p->
name ) == 0 ) {
514 *error = g_strdup_printf (
"Option: %s is not found.", p->
name );
539 printf (
"! \"%s\" ", option->
comment );
544 printf (
"%s.%s: %*s", namePrefix, option->
name,
545 (
int) ( 30 - strlen ( option->
name ) ),
"" );
546 switch ( option->
type )
549 printf (
"%u", *( option->
value.
num ) );
552 printf (
"%i", *( option->
value.
snum ) );
555 if ( ( *( option->
value.
str ) ) != NULL ) {
556 printf (
"%s", *( option->
value.
str ) );
560 printf (
"%s", ( *( option->
value.
num ) == TRUE ) ?
"true" :
"false" );
567 printf (
"\\x%02X", *( option->
value.
charc ) );
578 const char * namePrefix =
"rofi";
580 for (
unsigned int i = 0; i < entries; ++i ) {
582 if ( ( i + 1 ) < entries ) {
597 fprintf ( out,
"/*" );
599 fprintf ( out,
"\t%s: ", option->
name );
600 switch ( option->
type )
603 fprintf ( out,
"%u", *( option->
value.
num ) );
606 fprintf ( out,
"%i", *( option->
value.
snum ) );
609 if ( ( *( option->
value.
str ) ) != NULL ) {
611 fprintf ( out,
"\"%s\"", *( option->
value.
str ) );
615 fprintf ( out,
"%s", ( *( option->
value.
num ) == TRUE ) ?
"true" :
"false" );
620 fprintf ( out,
"'%c'", *( option->
value.
charc ) );
623 fprintf ( out,
"'\\x%02X'", *( option->
value.
charc ) );
625 fprintf ( out,
" /* unsupported */" );
631 fprintf ( out,
";" );
633 fprintf ( out,
"*/" );
635 fprintf ( out,
"\n" );
640 fprintf ( out,
"configuration {\n" );
643 for (
unsigned int i = 0; i < entries; ++i ) {
645 if ( ( i + 1 ) < entries ) {
660 fprintf ( out,
"}\n" );
665 int l = strlen ( xo->
name );
672 printf (
"\t-%s [string]%-*c%s\n", xo->
name, 30 - l,
' ', xo->
comment );
673 printf (
"\t\t%s", ( *( xo->
value.
str ) == NULL ) ?
"(unset)" : ( *( xo->
value.
str ) ) );
679 int l = strlen ( xo->
name );
686 printf (
"\t-%s [number]%-*c%s\n", xo->
name, 30 - l,
' ', xo->
comment );
687 printf (
"\t\t%u", *( xo->
value.
num ) );
693 int l = strlen ( xo->
name );
700 printf (
"\t-%s [number]%-*c%s\n", xo->
name, 30 - l,
' ', xo->
comment );
701 printf (
"\t\t%d", *( xo->
value.
snum ) );
707 int l = strlen ( xo->
name );
714 printf (
"\t-%s [character]%-*c%s\n", xo->
name, 30 - l,
' ', xo->
comment );
721 int l = strlen ( xo->
name );
728 printf (
"\t-[no-]%s %-*c%s\n", xo->
name, 33 - l,
' ', xo->
comment );
729 printf (
"\t\t%s", ( *( xo->
value.
snum ) ) ?
"True" :
"False" );
760 int is_term = isatty ( fileno ( stdout ) );
762 for (
unsigned int i = 0; i < entries; ++i ) {
763 if ( ( i + 1 ) < entries ) {
775 void print_help_msg (
const char *option,
const char *type,
const char*text,
const char *def,
int isatty )
777 int l = 37 - strlen ( option ) - strlen ( type );
785 printf (
"\t%s %s %-*c%s\n", option, type, l,
' ', text );
787 printf (
"\t\t%s\n", def );
795 switch ( option->
type )
798 return g_markup_printf_escaped (
"<b%-*s</b> (%u) <span style='italic' size='small'>%s</span>",
801 return g_markup_printf_escaped (
"<b%-*s</b> (%d) <span style='italic' size='small'>%s</span>",
804 return g_markup_printf_escaped (
"<b>%-*s</b> (%s) <span style='italic' size='small'>%s</span>",
810 return g_markup_printf_escaped (
"<b>%-*s</b> (%s) <span style='italic' size='small'>%s</span>",
811 ll, option->
name, ( *( option->
value.
num ) == TRUE ) ?
"true" :
"false", option->
comment );
814 return g_markup_printf_escaped (
"<b>%-*s</b> (%c) <span style='italic' size='small'>%s</span>",
818 return g_markup_printf_escaped (
"<b%-*s</b> (\\x%02X) <span style='italic' size='small'>%s</span>",
825 return g_strdup (
"failed" );
835 size_t max_length = 0;
836 for (
unsigned int i = 0; i < entries; ++i ) {
838 max_length = MAX ( max_length, l );
842 max_length = MAX ( max_length, l );
847 for (
unsigned int i = 0; i < entries; ++i ) {
848 if ( ( i + 1 ) < entries ) {
853 if ( strncmp (
xrmOptions[i].name,
"kb", 2 ) != 0 && strncmp (
xrmOptions[i].name,
"ml", 2 ) != 0 && strncmp (
xrmOptions[i].name,
"me", 2 ) != 0 ) {
857 retv = g_realloc ( retv, ( ( *length ) + 2 ) *
sizeof (
char* ) );
866 retv = g_realloc ( retv, ( ( *length ) + 2 ) *
sizeof (
char* ) );
870 if ( ( *length ) > 0 ) {
871 retv[( *length )] = NULL;
static void print_option_string(XrmOption *xo, int is_term)
void config_parse_dump_config_rasi_format(FILE *out, gboolean changes)
Dump configuration in rasi format.
static XrmOption xrmOptions[]
unsigned int fake_transparency
static void config_parse_dump_config_option(FILE *out, XrmOption *option)
static void xresource_dump_entry(const char *namePrefix, XrmOption *option)
int find_arg_char(const char *const key, char *val)
unsigned int case_sensitive
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
union XrmOption::@3 value
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)
gboolean drun_reload_desktop_cache
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
gboolean drun_use_desktop_cache
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)
gboolean window_thumbnail
unsigned int hide_scrollbar
const char *const PropertyTypeName[P_NUM_TYPES]
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[]