35 #include <xcb/xcb_xrm.h> 130 "Command executed on accep-entry-custom for window modus",
CONFIG_DEFAULT },
141 "DRUN format string. (Supports: generic,name,comment,exec,categories)",
CONFIG_DEFAULT },
147 "Choose the strategy used for sorting: normal (levenshtein) or fzf.",
CONFIG_DEFAULT },
165 "Set the matching algorithm. (normal, regex, glob, fuzzy)",
CONFIG_DEFAULT },
180 "Separator style (none, dash, solid) *DEPRECATED*",
CONFIG_DEFAULT },
196 "Background to use for fake transparency. (background or screenshot)",
CONFIG_DEFAULT },
198 "Window Format. w (desktop name), t (title), n (name), r (role), c (class) *DEPRECATED*",
CONFIG_DEFAULT },
214 "Max history size (WARNING: can cause slowdowns when set to high).",
CONFIG_DEFAULT },
216 "Hide the prefix mode prefix on the combi view.",
CONFIG_DEFAULT },
218 "Set the character used to negate the matching. ('\\0' to disable)",
CONFIG_DEFAULT },
250 switch ( option->
type )
253 if ( ( option )->mem != NULL ) {
254 g_free ( option->
mem );
257 *( option->
value.
str ) = g_strchomp ( g_strdup ( xrmValue ) );
260 ( option )->mem = *( option->
value.
str );
263 *( option->
value.
num ) = (
unsigned int) g_ascii_strtoull ( xrmValue, NULL, 10 );
266 *( option->
value.
snum ) = (
int) g_ascii_strtoll ( xrmValue, NULL, 10 );
269 if ( strlen ( xrmValue ) > 0 &&
270 g_ascii_strcasecmp ( xrmValue,
"true" ) == 0 ) {
286 const char * namePrefix =
"rofi";
289 char *name = g_strdup_printf (
"%s.%s", namePrefix,
xrmOptions[i].name );
291 char *xrmValue = NULL;
292 if ( xcb_xrm_resource_get_string ( xDB, name, NULL, &xrmValue ) == 0 ) {
304 const char * namePrefix =
"rofi";
309 name = g_strdup_printf (
"%s.%s", namePrefix,
extra_options[i].name );
310 char *xrmValue = NULL;
311 if ( xcb_xrm_resource_get_string ( xDB, name, NULL, &xrmValue ) == 0 ) {
323 xcb_xrm_database_t *xDB = xcb_xrm_database_from_default (
xcb->
connection );
327 xcb_xrm_database_free ( xDB );
336 xcb_xrm_database_t *xDB = xcb_xrm_database_from_file ( filename );
342 xcb_xrm_database_free ( xDB );
351 char *key = g_strdup_printf (
"-%s", option->
name );
352 switch ( option->
type )
366 if ( option->
mem != NULL ) {
367 g_free ( option->
mem );
380 key = g_strdup_printf (
"-no-%s", option->
name );
414 *error = g_strdup_printf (
"Option: %s needs to be set with a string not a %s.", option->
name,
PropertyTypeName[p->
type] );
419 for ( GList *iter = p->
value.
list; iter != NULL; iter = g_list_next ( iter ) ) {
420 if ( value == NULL ) {
421 value = g_strdup ( (
char *) ( iter->data ) );
424 char *nv = g_strjoin (
",", value, (
char *) ( iter->data ), NULL );
431 value = g_strdup ( p->
value.
s );
433 if ( ( option )->mem != NULL ) {
434 g_free ( option->
mem );
440 ( option )->mem = *( option->
value.
str );
445 *error = g_strdup_printf (
"Option: %s needs to be set with a number not a %s.", option->
name,
PropertyTypeName[p->
type] );
453 *error = g_strdup_printf (
"Option: %s needs to be set with a number not a %s.", option->
name,
PropertyTypeName[p->
type] );
461 *error = g_strdup_printf (
"Option: %s needs to be set with a boolean not a %s.", option->
name,
PropertyTypeName[p->
type] );
479 if ( g_strcmp0 ( op->
name, p->
name ) == 0 ) {
485 if ( g_strcmp0 ( op->
name, p->
name ) == 0 ) {
489 *error = g_strdup_printf (
"Option: %s is not found.", p->
name );
514 printf (
"! \"%s\" ", option->
comment );
519 printf (
"%s.%s: %*s", namePrefix, option->
name,
520 (
int) ( 30 - strlen ( option->
name ) ),
"" );
521 switch ( option->
type )
524 printf (
"%u", *( option->
value.
num ) );
527 printf (
"%i", *( option->
value.
snum ) );
530 if ( ( *( option->
value.
str ) ) != NULL ) {
531 printf (
"%s", *( option->
value.
str ) );
535 printf (
"%s", ( *( option->
value.
num ) == TRUE ) ?
"true" :
"false" );
542 printf (
"\\x%02X", *( option->
value.
charc ) );
553 const char * namePrefix =
"rofi";
555 for (
unsigned int i = 0; i < entries; ++i ) {
557 if ( ( i + 1 ) < entries ) {
574 printf (
"\t%s: ", option->
name );
575 switch ( option->
type )
578 printf (
"%u", *( option->
value.
num ) );
581 printf (
"%i", *( option->
value.
snum ) );
584 if ( ( *( option->
value.
str ) ) != NULL ) {
586 printf (
"\"%s\"", *( option->
value.
str ) );
590 printf (
"%s", ( *( option->
value.
num ) == TRUE ) ?
"true" :
"false" );
598 printf (
"'\\x%02X'", *( option->
value.
charc ) );
600 printf (
" /* unsupported */" );
615 printf (
"configuration {\n" );
618 for (
unsigned int i = 0; i < entries; ++i ) {
620 if ( ( i + 1 ) < entries ) {
640 int l = strlen ( xo->
name );
647 printf (
"\t-%s [string]%-*c%s\n", xo->
name, 30 - l,
' ', xo->
comment );
648 printf (
"\t\t%s", ( *( xo->
value.
str ) == NULL ) ?
"(unset)" : ( *( xo->
value.
str ) ) );
654 int l = strlen ( xo->
name );
661 printf (
"\t-%s [number]%-*c%s\n", xo->
name, 30 - l,
' ', xo->
comment );
662 printf (
"\t\t%u", *( xo->
value.
num ) );
668 int l = strlen ( xo->
name );
675 printf (
"\t-%s [number]%-*c%s\n", xo->
name, 30 - l,
' ', xo->
comment );
676 printf (
"\t\t%d", *( xo->
value.
snum ) );
682 int l = strlen ( xo->
name );
689 printf (
"\t-%s [character]%-*c%s\n", xo->
name, 30 - l,
' ', xo->
comment );
696 int l = strlen ( xo->
name );
703 printf (
"\t-[no-]%s %-*c%s\n", xo->
name, 33 - l,
' ', xo->
comment );
704 printf (
"\t\t%s", ( *( xo->
value.
snum ) ) ?
"True" :
"False" );
735 int is_term = isatty ( fileno ( stdout ) );
737 for (
unsigned int i = 0; i < entries; ++i ) {
738 if ( ( i + 1 ) < entries ) {
750 void print_help_msg (
const char *option,
const char *type,
const char*text,
const char *def,
int isatty )
752 int l = 37 - strlen ( option ) - strlen ( type );
760 printf (
"\t%s %s %-*c%s\n", option, type, l,
' ', text );
762 printf (
"\t\t%s\n", def );
770 switch ( option->
type )
773 return g_markup_printf_escaped (
"<b%-*s</b> (%u) <span style='italic' size='small'>%s</span>",
776 return g_markup_printf_escaped (
"<b%-*s</b> (%d) <span style='italic' size='small'>%s</span>",
779 return g_markup_printf_escaped (
"<b>%-*s</b> (%s) <span style='italic' size='small'>%s</span>",
785 return g_markup_printf_escaped (
"<b>%-*s</b> (%s) <span style='italic' size='small'>%s</span>",
786 ll, option->
name, ( *( option->
value.
num ) == TRUE ) ?
"true" :
"false", option->
comment );
789 return g_markup_printf_escaped (
"<b>%-*s</b> (%c) <span style='italic' size='small'>%s</span>",
793 return g_markup_printf_escaped (
"<b%-*s</b> (\\x%02X) <span style='italic' size='small'>%s</span>",
800 return g_strdup (
"failed" );
810 size_t max_length = 0;
811 for (
unsigned int i = 0; i < entries; ++i ) {
813 max_length = MAX ( max_length, l );
817 max_length = MAX ( max_length, l );
822 for (
unsigned int i = 0; i < entries; ++i ) {
823 if ( ( i + 1 ) < entries ) {
828 if ( strncmp (
xrmOptions[i].name,
"kb", 2 ) != 0 && strncmp (
xrmOptions[i].name,
"ml", 2 ) != 0 && strncmp (
xrmOptions[i].name,
"me", 2 ) != 0 ) {
832 retv = g_realloc ( retv, ( ( *length ) + 2 ) *
sizeof (
char* ) );
841 retv = g_realloc ( retv, ( ( *length ) + 2 ) *
sizeof (
char* ) );
845 if ( ( *length ) > 0 ) {
846 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[]