28 #define G_LOG_DOMAIN "XrmOptions"
50 "Commandline",
"Don't Display"};
102 "Y-offset relative to location",
108 "X-offset relative to location",
114 "Always show number of lines",
121 "Whether to load and show icons",
140 "Ssh command to execute",
146 "Run command to execute",
152 "Command to get extra run targets",
158 "Run command to execute that runs in shell",
164 "Command to executed when -kb-accept-alt binding is hit on selected "
168 "window-match-fields",
171 "Window fields to match in window mode",
177 "Theme to use to look for icons",
184 "Desktop entry fields to match in drun",
190 "Only show Desktop entry from these categories",
196 "Desktop entry show actions.",
199 "drun-display-format",
202 "DRUN format string. (Supports: generic,name,comment,exec,categories)",
208 "Command to open a Desktop Entry that is a Link.",
215 "Disable history in run/ssh",
221 "Programs ignored for history",
233 "Choose the strategy used for sorting: normal (levenshtein) or fzf.",
239 "Set case-sensitivity",
245 "Cycle through the results list",
251 "Enable sidebar-mode",
257 "Enable hover-select",
263 "Row height (in chars)",
269 "Enable auto select mode",
275 "Parse hosts file for ssh mode",
281 "Parse known_hosts file for ssh mode",
287 "Set the modi to combine in combi mode",
293 "Set the matching algorithm. (normal, regex, glob, fuzzy, prefix)",
299 "Tokenize input string",
307 "Monitor id to show on",
320 "Threads to use for string matching",
326 "Scrolling method. (0: Page, 1: Centered)",
332 "Window Format. w (desktop name), t (title), n (name), r (role), c "
339 "Click outside the window to exit",
345 "New style theme file",
351 "Max history size (WARNING: can cause slowdowns when set too high).",
354 "combi-hide-mode-prefix",
357 "Hide the prefix mode prefix on the combi view.**deprecated** use "
358 "combi-display-format",
361 "combi-display-format",
364 "Combi format string. (Supports: mode, text)",
367 "matching-negate-char",
370 "Set the character used to negate the matching. ('\\0' to disable)",
376 "Directory where history and temporary files are stored.",
382 "Show window thumbnail (if available) as icon in window switcher.",
385 "drun-use-desktop-cache",
388 "DRUN: build and use a cache with desktop file content.",
391 "drun-reload-desktop-cache",
394 "DRUN: If enabled, reload the cache with desktop file content.",
400 "Normalize string when matching (disables match highlighting).",
406 "Steal focus on launch and restore to window that had it on rofi start on "
410 "application-fallback-icon",
413 "Fallback icon to use when the application icon is not found in run/drun.",
429 const char *comment) {
448 iter = g_list_next(iter)) {
449 if (g_strcmp0(((
Property *)(iter->data))->name, key) == 0) {
451 g_debug(
"Setting property from backup list: %s", key);
453 (
Property *)(iter->data), &error)) {
454 g_debug(
"Failed to set property on custom entry: %s", key);
469 char *key = g_strdup_printf(
"-%s", option->
name);
470 switch (option->
type) {
483 if (option->
mem != NULL) {
496 key = g_strdup_printf(
"-no-%s", option->
name);
515 int count,
char *argv,
517 for (
int j = 0; j < (
count - 1); j++) {
518 g_string_append_printf(str,
"%s { ", tokens[j]);
521 char *esc = g_strescape(argv, NULL);
522 g_string_append_printf(str,
"%s: \"%s\";", tokens[
count - 1], esc);
525 g_string_append_printf(str,
"%s: %s;", tokens[
count - 1], argv);
527 for (
int j = 0; j < (
count - 1); j++) {
528 g_string_append(str,
" } ");
553 char **tokens = g_strsplit(
stored_argv[in],
"-", 3);
555 for (
int j = 1; tokens && tokens[j]; j++) {
559 if (g_str_has_prefix(tokens[1],
"theme")) {
562 count = g_strv_length(tokens);
564 GString *str = g_string_new(
"");
570 g_string_free(str, TRUE);
573 g_string_free(str, TRUE);
575 }
else if (g_strcmp0(tokens[1],
"no") != 0) {
576 GString *str = g_string_new(
"configuration { ");
579 g_string_append(str,
"}");
580 g_debug(
"str: \"%s\"\n", str->str);
584 g_string_assign(str,
"configuration { ");
587 g_string_append(str,
"}");
588 g_debug(
"str: \"%s\"\n", str->str);
594 g_string_free(str, TRUE);
608 g_strdup_printf(
"Option: %s needs to be set with a string not a %s.",
614 for (GList *iter = p->
value.
list; iter != NULL;
615 iter = g_list_next(iter)) {
618 value = g_strdup((
char *)(p->
value.
s));
620 char *nv = g_strjoin(
",", value, (
char *)(p->
value.
s), NULL);
626 value = g_strdup(p->
value.
s);
628 if ((option)->mem != NULL) {
635 (option)->mem = *(option->
value.
str);
640 g_strdup_printf(
"Option: %s needs to be set with a number not a %s.",
649 g_strdup_printf(
"Option: %s needs to be set with a number not a %s.",
658 g_strdup_printf(
"Option: %s needs to be set with a boolean not a %s.",
666 *error = g_strdup_printf(
667 "Option: %s needs to be set with a character not a %s.", option->
name,
675 *error = g_strdup_printf(
"Option: %s is not of a supported type: %s.",
683 if (g_ascii_strcasecmp(p->
name,
"theme") == 0) {
685 *error = g_strdup_printf(
"The option:\n<b>\nconfiguration\n{\n\ttheme: "
686 "\"%s\";\n}</b>\nis deprecated. Please replace "
687 "with: <b>@theme \"%s\"</b> "
688 "after the configuration block.",
691 *error = g_strdup_printf(
"The option:\n<b>\nconfiguration\n{\n\ttheme: "
692 "\"%s\";\n}</b>\nis deprecated. Please replace "
693 "with: <b>@theme \"%s\"</b> "
694 "after the configuration block.",
695 "myTheme",
"myTheme");
701 if (g_strcmp0(op->
name, p->
name) == 0) {
707 if (g_strcmp0(op->
name, p->
name) == 0) {
712 g_debug(
"Option: %s is not found.", p->
name);
715 iter = g_list_next(iter)) {
716 if (g_strcmp0(((
Property *)(iter->data))->name, p->
name) == 0) {
722 g_debug(
"Adding option: %s to backup list.", p->
name);
754 fprintf(out,
"\t%s: ", option->
name);
755 switch (option->
type) {
757 fprintf(out,
"%u", *(option->
value.
num));
760 fprintf(out,
"%i", *(option->
value.
snum));
763 if ((*(option->
value.
str)) != NULL) {
765 fprintf(out,
"\"%s\"", *(option->
value.
str));
769 fprintf(out,
"%s", (*(option->
value.
num) == TRUE) ?
"true" :
"false");
776 fprintf(out,
"'\\x%02X'", *(option->
value.
charc));
778 fprintf(out,
" /* unsupported */");
792 fprintf(out,
"configuration {\n");
795 for (
unsigned int i = 0; i < entries; ++i) {
797 if ((i + 1) < entries) {
832 int l = strlen(xo->
name);
841 printf(
"\t-%s [string]%-*c%s\n", xo->
name, 30 - l,
' ', xo->
comment);
848 int l = strlen(xo->
name);
856 printf(
"\t-%s [number]%-*c%s\n", xo->
name, 30 - l,
' ', xo->
comment);
862 int l = strlen(xo->
name);
870 printf(
"\t-%s [number]%-*c%s\n", xo->
name, 30 - l,
' ', xo->
comment);
876 int l = strlen(xo->
name);
884 printf(
"\t-%s [character]%-*c%s\n", xo->
name, 30 - l,
' ', xo->
comment);
890 int l = strlen(xo->
name);
899 printf(
"\t-[no-]%s %-*c%s\n", xo->
name, 33 - l,
' ', xo->
comment);
900 printf(
"\t\t%s", (*(xo->
value.
snum)) ?
"True" :
"False");
931 int is_term = isatty(fileno(stdout));
933 for (
unsigned int i = 0; i < entries; ++i) {
934 if ((i + 1) < entries) {
947 const char *def,
int isatty) {
948 int l = 37 - strlen(option) - strlen(type);
956 printf(
"\t%s %s %-*c%s\n", option, type, l,
' ', text);
958 printf(
"\t\t%s\n", def);
966 switch (option->
type) {
968 return g_markup_printf_escaped(
969 "<b%-*s</b> (%u) <span style='italic' size='small'>%s</span>", ll,
972 return g_markup_printf_escaped(
973 "<b%-*s</b> (%d) <span style='italic' size='small'>%s</span>", ll,
976 return g_markup_printf_escaped(
977 "<b>%-*s</b> (%s) <span style='italic' size='small'>%s</span>", ll,
982 return g_markup_printf_escaped(
983 "<b>%-*s</b> (%s) <span style='italic' size='small'>%s</span>", ll,
984 option->
name, (*(option->
value.
num) == TRUE) ?
"true" :
"false",
988 return g_markup_printf_escaped(
989 "<b>%-*s</b> (%c) <span style='italic' size='small'>%s</span>", ll,
992 return g_markup_printf_escaped(
993 "<b%-*s</b> (\\x%02X) <span style='italic' size='small'>%s</span>",
1000 return g_strdup(
"failed");
1009 size_t max_length = 0;
1010 for (
unsigned int i = 0; i < entries; ++i) {
1012 max_length = MAX(max_length, l);
1016 max_length = MAX(max_length, l);
1021 for (
unsigned int i = 0; i < entries; ++i) {
1022 if ((i + 1) < entries) {
1027 if (strncmp(
xrmOptions[i].name,
"kb", 2) != 0 &&
1033 retv = g_realloc(retv, ((*length) + 2) *
sizeof(
char *));
1045 retv = g_realloc(retv, ((*length) + 2) *
sizeof(
char *));
1050 if ((*length) > 0) {
1051 retv[(*length)] = NULL;
void config_parse_cmd_options(void)
void config_parser_add_option(XrmOptionType type, const char *key, void **value, const char *comment)
void print_help_msg(const char *option, const char *type, const char *text, const char *def, int isatty)
gboolean config_parse_set_property(const Property *p, char **error)
Set config option.
void config_parse_dump_config_rasi_format(FILE *out, gboolean changes)
Dump configuration in rasi format.
char ** config_parser_return_display_help(unsigned int *length)
void config_xresource_free(void)
int find_arg_char(const char *const key, char *val)
int find_arg_int(const char *const key, int *val)
int find_arg_str(const char *const key, char **val)
int find_arg_uint(const char *const key, unsigned int *val)
int find_arg(const char *const key)
void rofi_clear_error_messages(void)
const char *const PropertyTypeName[P_NUM_TYPES]
unsigned int disable_history
char * application_fallback_icon
unsigned int parse_known_hosts
unsigned int scroll_method
gboolean drun_reload_desktop_cache
unsigned int fixed_num_lines
unsigned int drun_show_actions
unsigned int max_history_size
unsigned int case_sensitive
char * drun_display_format
gboolean combi_hide_mode_prefix
char * window_match_fields
gboolean window_thumbnail
unsigned int sidebar_mode
char matching_negate_char
gboolean drun_use_desktop_cache
char * combi_display_format
union XrmOption::@5 value
Property * rofi_theme_property_copy(const Property *p)
void rofi_theme_print_index(ThemeWidget *widget, int index)
void rofi_theme_property_free(Property *p)
gboolean rofi_theme_parse_string(const char *string)
static void print_option_snumber(XrmOption *xo, int is_term)
static void print_option(XrmOption *xo, int is_term)
const char *const ConfigSourceStr[]
XrmOption * extra_options
static gboolean __config_parser_set_property(XrmOption *option, const Property *p, char **error)
static char * config_parser_return_display_help_entry(XrmOption *option, size_t l)
static void print_option_char(XrmOption *xo, int is_term)
GList * extra_parsed_options
static gboolean config_parser_form_rasi_format(GString *str, char **tokens, int count, char *argv, gboolean string)
ThemeWidget * rofi_configuration
static XrmOption xrmOptions[]
static void print_option_boolean(XrmOption *xo, int is_term)
unsigned int num_extra_options
static void print_option_number(XrmOption *xo, int is_term)
static void config_parse_cmd_option(XrmOption *option)
static void config_parse_dump_config_option(FILE *out, XrmOption *option)
static void print_option_string(XrmOption *xo, int is_term)