28#define G_LOG_DOMAIN "XrmOptions"
50 "Commandline",
"Don't Display"};
94 {.str = &
config.menu_font},
100 {.num = &
config.location},
102 "Location on screen",
106 {.snum = &
config.y_offset},
108 "Y-offset relative to location. *DEPRECATED* see rofi-theme manpage for "
113 {.snum = &
config.x_offset},
115 "X-offset relative to location. *DEPRECATED* see rofi-theme manpage for "
120 {.num = &
config.fixed_num_lines},
122 "Always show number of lines",
127 {.snum = &
config.show_icons},
129 "Whether to load and show icons",
134 {.str = &
config.preview_cmd},
136 "Custom command to generate preview icons",
140 "on-selection-changed",
141 {.str = &
config.on_selection_changed},
143 "Custom command to call when menu selection changes",
147 {.str = &
config.on_mode_changed},
149 "Custom command to call when menu mode changes",
153 {.str = &
config.on_entry_accepted},
155 "Custom command to call when menu entry is accepted",
159 {.str = &
config.on_menu_canceled},
161 "Custom command to call when menu is canceled",
165 {.str = &
config.on_menu_error},
167 "Custom command to call when menu finds errors",
170 "on-screenshot-taken",
171 {.str = &
config.on_screenshot_taken},
173 "Custom command to call when menu screenshot is taken",
178 {.str = &
config.terminal_emulator},
184 {.str = &
config.ssh_client},
190 {.str = &
config.ssh_command},
192 "Ssh command to execute",
196 {.str = &
config.run_command},
198 "Run command to execute",
202 {.str = &
config.run_list_command},
204 "Command to get extra run targets",
208 {.str = &
config.run_shell_command},
210 "Run command to execute that runs in shell",
214 {.str = &
config.window_command},
216 "Command to executed when -kb-accept-alt binding is hit on selected "
220 "window-match-fields",
221 {.str = &
config.window_match_fields},
223 "Window fields to match in window mode",
227 {.str = &
config.icon_theme},
229 "Theme to use to look for icons",
234 {.str = &
config.drun_match_fields},
236 "Desktop entry fields to match in drun",
240 {.str = &
config.drun_categories},
242 "Only show Desktop entry from these categories",
245 "drun-exclude-categories",
246 {.str = &
config.drun_exclude_categories},
248 "Exclude Desktop entries from these categories",
252 {.num = &
config.drun_show_actions},
254 "Desktop entry show actions.",
257 "drun-display-format",
258 {.str = &
config.drun_display_format},
260 "DRUN format string. (Supports: generic,name,comment,exec,categories)",
264 {.str = &
config.drun_url_launcher},
266 "Command to open a Desktop Entry that is a Link.",
271 {.num = &
config.disable_history},
273 "Disable history in run/ssh",
277 {.str = &
config.ignored_prefixes},
279 "Programs ignored for history",
285 "Sort menu when filtered",
289 {.str = &
config.sorting_method},
291 "Choose sort strategy: normal (levenshtein) or fzf.",
295 {.num = &
config.case_sensitive},
297 "Set case-sensitivity",
301 {.num = &
config.case_smart},
303 "Set smartcase like vim (determine case-sensitivity by input)",
309 "Cycle through the results list",
313 {.num = &
config.sidebar_mode},
315 "Enable sidebar-mode",
319 {.snum = &
config.hover_select},
321 "Enable hover-select",
325 {.snum = &
config.element_height},
327 "Row height (in chars)",
331 {.num = &
config.auto_select},
333 "Enable auto select mode",
337 {.num = &
config.parse_hosts},
339 "Parse hosts file for ssh mode",
343 {.num = &
config.parse_known_hosts},
345 "Parse known_hosts file for ssh mode",
349 {.str = &
config.combi_modes},
351 "Set the modes to combine in combi mode",
355 {.str = &
config.combi_modes},
357 "Set the modes to combine in combi mode",
361 {.str = &
config.matching},
363 "Set the matching algorithm. (normal, regex, glob, fuzzy, prefix)",
367 {.num = &
config.tokenize},
369 "Tokenize input string",
377 "Monitor id to show on",
390 "Threads to use for string matching",
394 {.num = &
config.scroll_method},
396 "Scrolling method. (0: Page, 1: Centered)",
400 {.str = &
config.window_format},
402 "Window Format. w (desktop name), t (title), n (name), r (role), c "
407 {.snum = &
config.click_to_exit},
409 "Click outside the window to exit",
415 "New style theme file",
419 {.num = &
config.max_history_size},
421 "Max history size (WARNING: can cause slowdowns when set too high).",
424 "combi-hide-mode-prefix",
425 {.snum = &
config.combi_hide_mode_prefix},
427 "Hide the prefix mode prefix on the combi view.**deprecated** use "
428 "combi-display-format",
431 "combi-display-format",
432 {.str = &
config.combi_display_format},
434 "Combi format string. (Supports: mode, text)",
437 "matching-negate-char",
438 {.charc = &
config.matching_negate_char},
440 "Set the character used to negate the matching. ('\\0' to disable)",
444 {.str = &
config.cache_dir},
446 "Directory where history and temporary files are stored.",
450 {.snum = &
config.window_thumbnail},
452 "Show window thumbnail (if available) as icon in window switcher.",
455 "drun-use-desktop-cache",
456 {.snum = &
config.drun_use_desktop_cache},
458 "DRUN: build and use a cache with desktop file content.",
461 "drun-reload-desktop-cache",
462 {.snum = &
config.drun_reload_desktop_cache},
464 "DRUN: If enabled, reload the cache with desktop file content.",
468 {.snum = &
config.normalize_match},
470 "Normalize string when matching (disables match highlighting).",
474 {.snum = &
config.steal_focus},
476 "Steal focus on launch and restore to window that had it on rofi start on "
480 "application-fallback-icon",
481 {.str = &(
config.application_fallback_icon)},
483 "Fallback icon to use when the application icon is not found in run/drun.",
486 "refilter-timeout-limit",
487 {.num = &(
config.refilter_timeout_limit)},
489 "When filtering takes more then this time (in ms) switch to delayed "
493 "xserver-i300-workaround",
494 {.snum = &(
config.xserver_i300_workaround)},
496 "Workaround for XServer issue #300 (issue #611 for rofi.)",
500 {.str = &(
config.completer_mode)},
502 "What completer to use for drun/run.",
506 {.snum = &
config.enable_imdkit},
508 "Whether to enable imdkit",
524 const char *comment) {
543 iter = g_list_next(iter)) {
544 if (g_strcmp0(((
Property *)(iter->data))->name, key) == 0) {
546 g_debug(
"Setting property from backup list: %s", key);
548 (
Property *)(iter->data), &error)) {
549 g_debug(
"Failed to set property on custom entry: %s", key);
564 char *key = g_strdup_printf(
"-%s", option->
name);
565 switch (option->
type) {
578 if (option->
mem != NULL) {
591 key = g_strdup_printf(
"-no-%s", option->
name);
610 int count,
char *argv,
612 if (strlen(argv) > 4096) {
615 for (
int j = 0; j < (
count - 1); j++) {
616 g_string_append_printf(str,
"%s { ", tokens[j]);
619 char *esc = g_strescape(argv, NULL);
620 g_string_append_printf(str,
"%s: \"%s\";", tokens[
count - 1], esc);
623 g_string_append_printf(str,
"%s: %s;", tokens[
count - 1], argv);
625 for (
int j = 0; j < (
count - 1); j++) {
626 g_string_append(str,
" } ");
651 char **tokens = g_strsplit(
stored_argv[in],
"-", 3);
653 for (
int j = 1; tokens && tokens[j]; j++) {
657 if (g_str_has_prefix(tokens[1],
"theme")) {
660 count = g_strv_length(tokens);
662 GString *str = g_string_new(
"");
668 g_string_free(str, TRUE);
671 g_string_free(str, TRUE);
673 }
else if (g_strcmp0(tokens[1],
"no") != 0) {
674 GString *str = g_string_new(
"configuration { ");
677 g_string_append(str,
"}");
678 g_debug(
"str: \"%s\"\n", str->str);
682 g_string_assign(str,
"configuration { ");
685 g_string_append(str,
"}");
686 g_debug(
"str: \"%s\"\n", str->str);
692 g_string_free(str, TRUE);
706 g_strdup_printf(
"Option: %s needs to be set with a string not a %s.",
712 for (GList *iter = p->
value.
list; iter != NULL;
713 iter = g_list_next(iter)) {
716 value = g_strdup((
char *)(p2->
value.
s));
718 char *nv = g_strjoin(
",", value, (
char *)(p2->
value.
s), NULL);
724 value = g_strdup_printf(
"%d", p->
value.
i);
726 value = g_strdup(p->
value.
s);
728 if ((option)->mem != NULL) {
735 (option)->mem = *(option->
value.
str);
740 g_strdup_printf(
"Option: %s needs to be set with a number not a %s.",
749 g_strdup_printf(
"Option: %s needs to be set with a number not a %s.",
758 g_strdup_printf(
"Option: %s needs to be set with a boolean not a %s.",
768 g_strdup_printf(
"Option: %s needs to be set with a string not a %s.",
776 *error = g_strdup_printf(
"Option: %s is not of a supported type: %s.",
784 if (g_ascii_strcasecmp(p->
name,
"theme") == 0) {
786 *error = g_strdup_printf(
"The option:\n<b>\nconfiguration\n{\n\ttheme: "
787 "\"%s\";\n}</b>\nis deprecated. Please replace "
788 "with: <b>@theme \"%s\"</b> "
789 "after the configuration block.",
792 *error = g_strdup_printf(
"The option:\n<b>\nconfiguration\n{\n\ttheme: "
793 "\"%s\";\n}</b>\nis deprecated. Please replace "
794 "with: <b>@theme \"%s\"</b> "
795 "after the configuration block.",
796 "myTheme",
"myTheme");
802 if (g_strcmp0(op->
name, p->
name) == 0) {
808 if (g_strcmp0(op->
name, p->
name) == 0) {
813 g_debug(
"Option: %s is not found.", p->
name);
816 iter = g_list_next(iter)) {
817 if (g_strcmp0(((
Property *)(iter->data))->name, p->
name) == 0) {
823 g_debug(
"Adding option: %s to backup list.", p->
name);
831 for (
unsigned int i = 0; i < (
sizeof(
xrmOptions) /
sizeof(*xrmOptions));
855 fprintf(out,
"\t%s: ", option->
name);
856 switch (option->
type) {
858 fprintf(out,
"%u", *(option->
value.
num));
861 fprintf(out,
"%i", *(option->
value.
snum));
864 if ((*(option->
value.
str)) != NULL) {
866 fprintf(out,
"\"%s\"", *(option->
value.
str));
870 fprintf(out,
"%s", (*(option->
value.
num) == TRUE) ?
"true" :
"false");
877 fprintf(out,
"'\\x%02X'", *(option->
value.
charc));
879 fprintf(out,
" /* unsupported */");
893 fprintf(out,
"configuration {\n");
896 for (
unsigned int i = 0; i < entries; ++i) {
898 if ((i + 1) < entries) {
927 if (
config.theme != NULL) {
928 fprintf(out,
"@theme \"%s\"\r\n",
config.theme);
933 int l = strlen(xo->
name);
942 printf(
"\t-%s [string]%-*c%s\n", xo->
name, 30 - l,
' ', xo->
comment);
949 int l = strlen(xo->
name);
957 printf(
"\t-%s [number]%-*c%s\n", xo->
name, 30 - l,
' ', xo->
comment);
963 int l = strlen(xo->
name);
971 printf(
"\t-%s [number]%-*c%s\n", xo->
name, 30 - l,
' ', xo->
comment);
977 int l = strlen(xo->
name);
985 printf(
"\t-%s [character]%-*c%s\n", xo->
name, 30 - l,
' ', xo->
comment);
991 int l = strlen(xo->
name);
1000 printf(
"\t-[no-]%s %-*c%s\n", xo->
name, 33 - l,
' ', xo->
comment);
1001 printf(
"\t\t%s", (*(xo->
value.
snum)) ?
"True" :
"False");
1032 int is_term = isatty(fileno(stdout));
1034 for (
unsigned int i = 0; i < entries; ++i) {
1035 if ((i + 1) < entries) {
1048 const char *def,
int isatty) {
1049 int l = 37 - strlen(option) - strlen(type);
1057 printf(
"\t%s %s %-*c%s\n", option, type, l,
' ', text);
1059 printf(
"\t\t%s\n", def);
1067 switch (option->
type) {
1069 return g_markup_printf_escaped(
1070 "<b%-*s</b> (%u) <span style='italic' size='small'>%s</span>", ll,
1073 return g_markup_printf_escaped(
1074 "<b%-*s</b> (%d) <span style='italic' size='small'>%s</span>", ll,
1077 return g_markup_printf_escaped(
1078 "<b>%-*s</b> (%s) <span style='italic' size='small'>%s</span>", ll,
1083 return g_markup_printf_escaped(
1084 "<b>%-*s</b> (%s) <span style='italic' size='small'>%s</span>", ll,
1085 option->
name, (*(option->
value.
num) == TRUE) ?
"true" :
"false",
1089 return g_markup_printf_escaped(
1090 "<b>%-*s</b> (%c) <span style='italic' size='small'>%s</span>", ll,
1093 return g_markup_printf_escaped(
1094 "<b%-*s</b> (\\x%02X) <span style='italic' size='small'>%s</span>",
1101 return g_strdup(
"failed");
1110 size_t max_length = 0;
1111 for (
unsigned int i = 0; i < entries; ++i) {
1113 max_length = MAX(max_length, l);
1117 max_length = MAX(max_length, l);
1122 for (
unsigned int i = 0; i < entries; ++i) {
1123 if ((i + 1) < entries) {
1128 if (strncmp(
xrmOptions[i].name,
"kb", 2) != 0 &&
1134 retv = g_realloc(retv, ((*length) + 2) *
sizeof(
char *));
1146 retv = g_realloc(retv, ((*length) + 2) *
sizeof(
char *));
1151 if ((*length) > 0) {
1152 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::@107061111126257051370212157274163204227103130150 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)