28#define G_LOG_DOMAIN "XrmOptions"
46 "Commandline",
"Don't Display"};
90 {.str = &
config.menu_font},
102 {.snum = &
config.y_offset},
104 "Y-offset relative to location. *DEPRECATED* see rofi-theme manpage for "
109 {.snum = &
config.x_offset},
111 "X-offset relative to location. *DEPRECATED* see rofi-theme manpage for "
116 {.num = &
config.fixed_num_lines},
118 "Always show number of lines",
123 {.snum = &
config.show_icons},
125 "Whether to load and show icons",
130 {.str = &
config.preview_cmd},
132 "Custom command to generate preview icons",
136 "on-selection-changed",
137 {.str = &
config.on_selection_changed},
139 "Custom command to call when menu selection changes",
143 {.str = &
config.on_mode_changed},
145 "Custom command to call when menu mode changes",
149 {.str = &
config.on_entry_accepted},
151 "Custom command to call when menu entry is accepted",
155 {.str = &
config.on_menu_canceled},
157 "Custom command to call when menu is canceled",
161 {.str = &
config.on_menu_error},
163 "Custom command to call when menu finds errors",
166 "on-screenshot-taken",
167 {.str = &
config.on_screenshot_taken},
169 "Custom command to call when menu screenshot is taken",
174 {.str = &
config.terminal_emulator},
180 {.str = &
config.ssh_client},
186 {.str = &
config.ssh_command},
188 "Ssh command to execute",
192 {.str = &
config.run_command},
194 "Run command to execute",
198 {.str = &
config.run_list_command},
200 "Command to get extra run targets",
204 {.str = &
config.run_shell_command},
206 "Run command to execute that runs in shell",
210 {.str = &
config.window_command},
212 "Command to executed when -kb-accept-alt binding is hit on selected "
216 "window-match-fields",
217 {.str = &
config.window_match_fields},
219 "Window fields to match in window mode",
223 {.str = &
config.icon_theme},
225 "Theme to use to look for icons",
230 {.str = &
config.drun_match_fields},
232 "Desktop entry fields to match in drun",
236 {.str = &
config.drun_categories},
238 "Only show Desktop entry from these categories",
241 "drun-exclude-categories",
242 {.str = &
config.drun_exclude_categories},
244 "Exclude Desktop entries from these categories",
248 {.num = &
config.drun_show_actions},
250 "Desktop entry show actions.",
253 "drun-display-format",
254 {.str = &
config.drun_display_format},
256 "DRUN format string. (Supports: generic,name,comment,exec,categories)",
260 {.str = &
config.drun_url_launcher},
262 "Command to open a Desktop Entry that is a Link.",
267 {.num = &
config.disable_history},
269 "Disable history in run/ssh",
273 {.str = &
config.ignored_prefixes},
275 "Programs ignored for history",
281 "Sort menu when filtered",
285 {.str = &
config.sorting_method},
287 "Choose sort strategy: normal (levenshtein) or fzf.",
291 {.num = &
config.case_sensitive},
293 "Set case-sensitivity",
297 {.num = &
config.case_smart},
299 "Set smartcase like vim (determine case-sensitivity by input)",
305 "Cycle through the results list",
309 {.num = &
config.sidebar_mode},
311 "Enable sidebar-mode",
315 {.snum = &
config.hover_select},
317 "Enable hover-select",
321 {.snum = &
config.element_height},
323 "Row height (in chars)",
327 {.num = &
config.auto_select},
329 "Enable auto select mode",
333 {.num = &
config.parse_hosts},
335 "Parse hosts file for ssh mode",
339 {.num = &
config.parse_known_hosts},
341 "Parse known_hosts file for ssh mode",
345 {.str = &
config.combi_modes},
347 "Set the modes to combine in combi mode",
351 {.str = &
config.combi_modes},
353 "Set the modes to combine in combi mode",
357 {.str = &
config.matching},
359 "Set the matching algorithm. (normal, regex, glob, fuzzy, prefix)",
363 {.num = &
config.tokenize},
365 "Tokenize input string",
373 "Monitor id to show on",
386 "Threads to use for string matching",
390 {.num = &
config.scroll_method},
392 "Scrolling method. (0: Page, 1: Centered)",
396 {.str = &
config.window_format},
398 "Window Format. w (desktop name), t (title), n (name), r (role), c "
403 {.snum = &
config.click_to_exit},
405 "Click outside the window to exit",
409 {.snum = &
config.global_kb},
411 "Click outside the window to exit",
417 "New style theme file",
421 {.num = &
config.max_history_size},
423 "Max history size (WARNING: can cause slowdowns when set too high).",
426 "combi-hide-mode-prefix",
427 {.snum = &
config.combi_hide_mode_prefix},
429 "Hide the prefix mode prefix on the combi view.**deprecated** use "
430 "combi-display-format",
433 "combi-display-format",
434 {.str = &
config.combi_display_format},
436 "Combi format string. (Supports: mode, text)",
439 "matching-negate-char",
440 {.charc = &
config.matching_negate_char},
442 "Set the character used to negate the matching. ('\\0' to disable)",
446 {.str = &
config.cache_dir},
448 "Directory where history and temporary files are stored.",
452 {.snum = &
config.window_thumbnail},
454 "Show window thumbnail (if available) as icon in window switcher.",
457 "drun-use-desktop-cache",
458 {.snum = &
config.drun_use_desktop_cache},
460 "DRUN: build and use a cache with desktop file content.",
463 "drun-reload-desktop-cache",
464 {.snum = &
config.drun_reload_desktop_cache},
466 "DRUN: If enabled, reload the cache with desktop file content.",
470 {.snum = &
config.normalize_match},
472 "Normalize string when matching (disables match highlighting).",
476 {.snum = &
config.steal_focus},
478 "Steal focus on launch and restore to window that had it on rofi start on "
482 "application-fallback-icon",
483 {.str = &(
config.application_fallback_icon)},
485 "Fallback icon to use when the application icon is not found in run/drun.",
488 "refilter-timeout-limit",
489 {.num = &(
config.refilter_timeout_limit)},
491 "When filtering takes more then this time (in ms) switch to delayed "
495 "xserver-i300-workaround",
496 {.snum = &(
config.xserver_i300_workaround)},
498 "Workaround for XServer issue #300 (issue #611 for rofi.)",
502 {.str = &(
config.completer_mode)},
504 "What completer to use for drun/run.",
508 {.snum = &
config.enable_imdkit},
510 "Whether to enable imdkit",
526 const char *comment) {
545 iter = g_list_next(iter)) {
546 if (g_strcmp0(((
Property *)(iter->data))->name, key) == 0) {
548 g_debug(
"Setting property from backup list: %s", key);
550 (
Property *)(iter->data), &error)) {
551 g_debug(
"Failed to set property on custom entry: %s", key);
566 char *key = g_strdup_printf(
"-%s", option->
name);
567 switch (option->
type) {
580 if (option->
mem != NULL) {
593 key = g_strdup_printf(
"-no-%s", option->
name);
612 int count,
char *argv,
614 if (strlen(argv) > 4096) {
617 for (
int j = 0; j < (
count - 1); j++) {
618 g_string_append_printf(str,
"%s { ", tokens[j]);
621 char *esc = g_strescape(argv, NULL);
622 g_string_append_printf(str,
"%s: \"%s\";", tokens[
count - 1], esc);
625 g_string_append_printf(str,
"%s: %s;", tokens[
count - 1], argv);
627 for (
int j = 0; j < (
count - 1); j++) {
628 g_string_append(str,
" } ");
653 char **tokens = g_strsplit(
stored_argv[in],
"-", 3);
655 for (
int j = 1; tokens && tokens[j]; j++) {
659 if (g_str_has_prefix(tokens[1],
"theme")) {
662 count = g_strv_length(tokens);
664 GString *str = g_string_new(
"");
670 g_string_free(str, TRUE);
673 g_string_free(str, TRUE);
675 }
else if (g_strcmp0(tokens[1],
"no") != 0) {
676 GString *str = g_string_new(
"configuration { ");
679 g_string_append(str,
"}");
680 g_debug(
"str: \"%s\"\n", str->str);
684 g_string_assign(str,
"configuration { ");
687 g_string_append(str,
"}");
688 g_debug(
"str: \"%s\"\n", str->str);
694 g_string_free(str, TRUE);
708 g_strdup_printf(
"Option: %s needs to be set with a string not a %s.",
714 for (GList *iter = p->
value.
list; iter != NULL;
715 iter = g_list_next(iter)) {
718 value = g_strdup((
char *)(p2->
value.
s));
720 char *nv = g_strjoin(
",", value, (
char *)(p2->
value.
s), NULL);
726 value = g_strdup_printf(
"%d", p->
value.
i);
728 value = g_strdup(p->
value.
s);
730 if ((option)->mem != NULL) {
737 (option)->mem = *(option->
value.
str);
742 g_strdup_printf(
"Option: %s needs to be set with a number not a %s.",
751 g_strdup_printf(
"Option: %s needs to be set with a number not a %s.",
760 g_strdup_printf(
"Option: %s needs to be set with a boolean not a %s.",
770 g_strdup_printf(
"Option: %s needs to be set with a string not a %s.",
778 *error = g_strdup_printf(
"Option: %s is not of a supported type: %s.",
786 if (g_ascii_strcasecmp(p->
name,
"theme") == 0) {
788 *error = g_strdup_printf(
"The option:\n<b>\nconfiguration\n{\n\ttheme: "
789 "\"%s\";\n}</b>\nis deprecated. Please replace "
790 "with: <b>@theme \"%s\"</b> "
791 "after the configuration block.",
794 *error = g_strdup_printf(
"The option:\n<b>\nconfiguration\n{\n\ttheme: "
795 "\"%s\";\n}</b>\nis deprecated. Please replace "
796 "with: <b>@theme \"%s\"</b> "
797 "after the configuration block.",
798 "myTheme",
"myTheme");
804 if (g_strcmp0(op->
name, p->
name) == 0) {
810 if (g_strcmp0(op->
name, p->
name) == 0) {
815 g_debug(
"Option: %s is not found.", p->
name);
818 iter = g_list_next(iter)) {
819 if (g_strcmp0(((
Property *)(iter->data))->name, p->
name) == 0) {
825 g_debug(
"Adding option: %s to backup list.", p->
name);
833 for (
unsigned int i = 0; i < (
sizeof(
xrmOptions) /
sizeof(*xrmOptions));
857 fprintf(out,
"\t%s: ", option->
name);
858 switch (option->
type) {
860 fprintf(out,
"%u", *(option->
value.
num));
863 fprintf(out,
"%i", *(option->
value.
snum));
866 if ((*(option->
value.
str)) != NULL) {
868 fprintf(out,
"\"%s\"", *(option->
value.
str));
872 fprintf(out,
"%s", (*(option->
value.
num) == TRUE) ?
"true" :
"false");
879 fprintf(out,
"'\\x%02X'", *(option->
value.
charc));
881 fprintf(out,
" /* unsupported */");
895 fprintf(out,
"configuration {\n");
898 for (
unsigned int i = 0; i < entries; ++i) {
900 if ((i + 1) < entries) {
929 if (
config.theme != NULL) {
930 fprintf(out,
"@theme \"%s\"\r\n",
config.theme);
935 int l = strlen(xo->
name);
944 printf(
"\t-%s [string]%-*c%s\n", xo->
name, 30 - l,
' ', xo->
comment);
951 int l = strlen(xo->
name);
959 printf(
"\t-%s [number]%-*c%s\n", xo->
name, 30 - l,
' ', xo->
comment);
965 int l = strlen(xo->
name);
973 printf(
"\t-%s [number]%-*c%s\n", xo->
name, 30 - l,
' ', xo->
comment);
979 int l = strlen(xo->
name);
987 printf(
"\t-%s [character]%-*c%s\n", xo->
name, 30 - l,
' ', xo->
comment);
993 int l = strlen(xo->
name);
1002 printf(
"\t-[no-]%s %-*c%s\n", xo->
name, 33 - l,
' ', xo->
comment);
1003 printf(
"\t\t%s", (*(xo->
value.
snum)) ?
"True" :
"False");
1034 int is_term = isatty(fileno(stdout));
1036 for (
unsigned int i = 0; i < entries; ++i) {
1037 if ((i + 1) < entries) {
1050 const char *def,
int isatty) {
1051 int l = 37 - strlen(option) - strlen(type);
1059 printf(
"\t%s %s %-*c%s\n", option, type, l,
' ', text);
1061 printf(
"\t\t%s\n", def);
1069 switch (option->
type) {
1071 return g_markup_printf_escaped(
1072 "<b%-*s</b> (%u) <span style='italic' size='small'>%s</span>", ll,
1075 return g_markup_printf_escaped(
1076 "<b%-*s</b> (%d) <span style='italic' size='small'>%s</span>", ll,
1079 return g_markup_printf_escaped(
1080 "<b>%-*s</b> (%s) <span style='italic' size='small'>%s</span>", ll,
1085 return g_markup_printf_escaped(
1086 "<b>%-*s</b> (%s) <span style='italic' size='small'>%s</span>", ll,
1087 option->
name, (*(option->
value.
num) == TRUE) ?
"true" :
"false",
1091 return g_markup_printf_escaped(
1092 "<b>%-*s</b> (%c) <span style='italic' size='small'>%s</span>", ll,
1095 return g_markup_printf_escaped(
1096 "<b%-*s</b> (\\x%02X) <span style='italic' size='small'>%s</span>",
1103 return g_strdup(
"failed");
1112 size_t max_length = 0;
1113 for (
unsigned int i = 0; i < entries; ++i) {
1115 max_length = MAX(max_length, l);
1119 max_length = MAX(max_length, l);
1124 for (
unsigned int i = 0; i < entries; ++i) {
1125 if ((i + 1) < entries) {
1130 if (strncmp(
xrmOptions[i].name,
"kb", 2) != 0 &&
1136 retv = g_realloc(retv, ((*length) + 2) *
sizeof(
char *));
1148 retv = g_realloc(retv, ((*length) + 2) *
sizeof(
char *));
1153 if ((*length) > 0) {
1154 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]
union XrmOption::@155152233035312152110273303163376352050147322314 value
void rofi_theme_print_index(ThemeWidget *wid, int index)
Property * rofi_theme_property_copy(const Property *p, G_GNUC_UNUSED void *data)
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 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)
static char * config_parser_return_display_help_entry(XrmOption *option, size_t l)
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)