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",
141 {.str = &
config.terminal_emulator},
147 {.str = &
config.ssh_client},
153 {.str = &
config.ssh_command},
155 "Ssh command to execute",
159 {.str = &
config.run_command},
161 "Run command to execute",
165 {.str = &
config.run_list_command},
167 "Command to get extra run targets",
171 {.str = &
config.run_shell_command},
173 "Run command to execute that runs in shell",
177 {.str = &
config.window_command},
179 "Command to executed when -kb-accept-alt binding is hit on selected "
183 "window-match-fields",
184 {.str = &
config.window_match_fields},
186 "Window fields to match in window mode",
190 {.str = &
config.icon_theme},
192 "Theme to use to look for icons",
197 {.str = &
config.drun_match_fields},
199 "Desktop entry fields to match in drun",
203 {.str = &
config.drun_categories},
205 "Only show Desktop entry from these categories",
209 {.num = &
config.drun_show_actions},
211 "Desktop entry show actions.",
214 "drun-display-format",
215 {.str = &
config.drun_display_format},
217 "DRUN format string. (Supports: generic,name,comment,exec,categories)",
221 {.str = &
config.drun_url_launcher},
223 "Command to open a Desktop Entry that is a Link.",
228 {.num = &
config.disable_history},
230 "Disable history in run/ssh",
234 {.str = &
config.ignored_prefixes},
236 "Programs ignored for history",
242 "Sort menu when filtered",
246 {.str = &
config.sorting_method},
248 "Choose sort strategy: normal (levenshtein) or fzf.",
252 {.num = &
config.case_sensitive},
254 "Set case-sensitivity",
260 "Cycle through the results list",
264 {.num = &
config.sidebar_mode},
266 "Enable sidebar-mode",
270 {.snum = &
config.hover_select},
272 "Enable hover-select",
276 {.snum = &
config.element_height},
278 "Row height (in chars)",
282 {.num = &
config.auto_select},
284 "Enable auto select mode",
288 {.num = &
config.parse_hosts},
290 "Parse hosts file for ssh mode",
294 {.num = &
config.parse_known_hosts},
296 "Parse known_hosts file for ssh mode",
300 {.str = &
config.combi_modes},
302 "Set the modes to combine in combi mode",
306 {.str = &
config.combi_modes},
308 "Set the modes to combine in combi mode",
312 {.str = &
config.matching},
314 "Set the matching algorithm. (normal, regex, glob, fuzzy, prefix)",
318 {.num = &
config.tokenize},
320 "Tokenize input string",
328 "Monitor id to show on",
341 "Threads to use for string matching",
345 {.num = &
config.scroll_method},
347 "Scrolling method. (0: Page, 1: Centered)",
351 {.str = &
config.window_format},
353 "Window Format. w (desktop name), t (title), n (name), r (role), c "
358 {.snum = &
config.click_to_exit},
360 "Click outside the window to exit",
366 "New style theme file",
370 {.num = &
config.max_history_size},
372 "Max history size (WARNING: can cause slowdowns when set too high).",
375 "combi-hide-mode-prefix",
376 {.snum = &
config.combi_hide_mode_prefix},
378 "Hide the prefix mode prefix on the combi view.**deprecated** use "
379 "combi-display-format",
382 "combi-display-format",
383 {.str = &
config.combi_display_format},
385 "Combi format string. (Supports: mode, text)",
388 "matching-negate-char",
389 {.charc = &
config.matching_negate_char},
391 "Set the character used to negate the matching. ('\\0' to disable)",
395 {.str = &
config.cache_dir},
397 "Directory where history and temporary files are stored.",
401 {.snum = &
config.window_thumbnail},
403 "Show window thumbnail (if available) as icon in window switcher.",
406 "drun-use-desktop-cache",
407 {.snum = &
config.drun_use_desktop_cache},
409 "DRUN: build and use a cache with desktop file content.",
412 "drun-reload-desktop-cache",
413 {.snum = &
config.drun_reload_desktop_cache},
415 "DRUN: If enabled, reload the cache with desktop file content.",
419 {.snum = &
config.normalize_match},
421 "Normalize string when matching (disables match highlighting).",
425 {.snum = &
config.steal_focus},
427 "Steal focus on launch and restore to window that had it on rofi start on "
431 "application-fallback-icon",
432 {.str = &(
config.application_fallback_icon)},
434 "Fallback icon to use when the application icon is not found in run/drun.",
437 "refilter-timeout-limit",
438 {.num = &(
config.refilter_timeout_limit)},
440 "When filtering takes more then this time (in ms) switch to delayed "
444 "xserver-i300-workaround",
445 {.snum = &(
config.xserver_i300_workaround)},
447 "Workaround for XServer issue #300 (issue #611 for rofi.)",
451 {.str = &(
config.completer_mode)},
453 "What completer to use for drun/run.",
469 const char *comment) {
488 iter = g_list_next(iter)) {
489 if (g_strcmp0(((
Property *)(iter->data))->name, key) == 0) {
491 g_debug(
"Setting property from backup list: %s", key);
493 (
Property *)(iter->data), &error)) {
494 g_debug(
"Failed to set property on custom entry: %s", key);
509 char *key = g_strdup_printf(
"-%s", option->
name);
510 switch (option->
type) {
523 if (option->
mem != NULL) {
536 key = g_strdup_printf(
"-no-%s", option->
name);
555 int count,
char *argv,
557 if (strlen(argv) > 4096) {
560 for (
int j = 0; j < (
count - 1); j++) {
561 g_string_append_printf(str,
"%s { ", tokens[j]);
564 char *esc = g_strescape(argv, NULL);
565 g_string_append_printf(str,
"%s: \"%s\";", tokens[
count - 1], esc);
568 g_string_append_printf(str,
"%s: %s;", tokens[
count - 1], argv);
570 for (
int j = 0; j < (
count - 1); j++) {
571 g_string_append(str,
" } ");
596 char **tokens = g_strsplit(
stored_argv[in],
"-", 3);
598 for (
int j = 1; tokens && tokens[j]; j++) {
602 if (g_str_has_prefix(tokens[1],
"theme")) {
605 count = g_strv_length(tokens);
607 GString *str = g_string_new(
"");
613 g_string_free(str, TRUE);
616 g_string_free(str, TRUE);
618 }
else if (g_strcmp0(tokens[1],
"no") != 0) {
619 GString *str = g_string_new(
"configuration { ");
622 g_string_append(str,
"}");
623 g_debug(
"str: \"%s\"\n", str->str);
627 g_string_assign(str,
"configuration { ");
630 g_string_append(str,
"}");
631 g_debug(
"str: \"%s\"\n", str->str);
637 g_string_free(str, TRUE);
651 g_strdup_printf(
"Option: %s needs to be set with a string not a %s.",
657 for (GList *iter = p->
value.
list; iter != NULL;
658 iter = g_list_next(iter)) {
661 value = g_strdup((
char *)(p2->
value.
s));
663 char *nv = g_strjoin(
",", value, (
char *)(p2->
value.
s), NULL);
669 value = g_strdup_printf(
"%d", p->
value.
i);
671 value = g_strdup(p->
value.
s);
673 if ((option)->mem != NULL) {
680 (option)->mem = *(option->
value.
str);
685 g_strdup_printf(
"Option: %s needs to be set with a number not a %s.",
694 g_strdup_printf(
"Option: %s needs to be set with a number not a %s.",
703 g_strdup_printf(
"Option: %s needs to be set with a boolean not a %s.",
713 g_strdup_printf(
"Option: %s needs to be set with a string not a %s.",
721 *error = g_strdup_printf(
"Option: %s is not of a supported type: %s.",
729 if (g_ascii_strcasecmp(p->
name,
"theme") == 0) {
731 *error = g_strdup_printf(
"The option:\n<b>\nconfiguration\n{\n\ttheme: "
732 "\"%s\";\n}</b>\nis deprecated. Please replace "
733 "with: <b>@theme \"%s\"</b> "
734 "after the configuration block.",
737 *error = g_strdup_printf(
"The option:\n<b>\nconfiguration\n{\n\ttheme: "
738 "\"%s\";\n}</b>\nis deprecated. Please replace "
739 "with: <b>@theme \"%s\"</b> "
740 "after the configuration block.",
741 "myTheme",
"myTheme");
747 if (g_strcmp0(op->
name, p->
name) == 0) {
753 if (g_strcmp0(op->
name, p->
name) == 0) {
758 g_debug(
"Option: %s is not found.", p->
name);
761 iter = g_list_next(iter)) {
762 if (g_strcmp0(((
Property *)(iter->data))->name, p->
name) == 0) {
768 g_debug(
"Adding option: %s to backup list.", p->
name);
776 for (
unsigned int i = 0; i < (
sizeof(
xrmOptions) /
sizeof(*xrmOptions));
800 fprintf(out,
"\t%s: ", option->
name);
801 switch (option->
type) {
803 fprintf(out,
"%u", *(option->
value.
num));
806 fprintf(out,
"%i", *(option->
value.
snum));
809 if ((*(option->
value.
str)) != NULL) {
811 fprintf(out,
"\"%s\"", *(option->
value.
str));
815 fprintf(out,
"%s", (*(option->
value.
num) == TRUE) ?
"true" :
"false");
822 fprintf(out,
"'\\x%02X'", *(option->
value.
charc));
824 fprintf(out,
" /* unsupported */");
838 fprintf(out,
"configuration {\n");
841 for (
unsigned int i = 0; i < entries; ++i) {
843 if ((i + 1) < entries) {
872 if (
config.theme != NULL) {
873 fprintf(out,
"@theme \"%s\"\r\n",
config.theme);
878 int l = strlen(xo->
name);
887 printf(
"\t-%s [string]%-*c%s\n", xo->
name, 30 - l,
' ', xo->
comment);
894 int l = strlen(xo->
name);
902 printf(
"\t-%s [number]%-*c%s\n", xo->
name, 30 - l,
' ', xo->
comment);
908 int l = strlen(xo->
name);
916 printf(
"\t-%s [number]%-*c%s\n", xo->
name, 30 - l,
' ', xo->
comment);
922 int l = strlen(xo->
name);
930 printf(
"\t-%s [character]%-*c%s\n", xo->
name, 30 - l,
' ', xo->
comment);
936 int l = strlen(xo->
name);
945 printf(
"\t-[no-]%s %-*c%s\n", xo->
name, 33 - l,
' ', xo->
comment);
946 printf(
"\t\t%s", (*(xo->
value.
snum)) ?
"True" :
"False");
977 int is_term = isatty(fileno(stdout));
979 for (
unsigned int i = 0; i < entries; ++i) {
980 if ((i + 1) < entries) {
993 const char *def,
int isatty) {
994 int l = 37 - strlen(option) - strlen(type);
1002 printf(
"\t%s %s %-*c%s\n", option, type, l,
' ', text);
1004 printf(
"\t\t%s\n", def);
1012 switch (option->
type) {
1014 return g_markup_printf_escaped(
1015 "<b%-*s</b> (%u) <span style='italic' size='small'>%s</span>", ll,
1018 return g_markup_printf_escaped(
1019 "<b%-*s</b> (%d) <span style='italic' size='small'>%s</span>", ll,
1022 return g_markup_printf_escaped(
1023 "<b>%-*s</b> (%s) <span style='italic' size='small'>%s</span>", ll,
1028 return g_markup_printf_escaped(
1029 "<b>%-*s</b> (%s) <span style='italic' size='small'>%s</span>", ll,
1030 option->
name, (*(option->
value.
num) == TRUE) ?
"true" :
"false",
1034 return g_markup_printf_escaped(
1035 "<b>%-*s</b> (%c) <span style='italic' size='small'>%s</span>", ll,
1038 return g_markup_printf_escaped(
1039 "<b%-*s</b> (\\x%02X) <span style='italic' size='small'>%s</span>",
1046 return g_strdup(
"failed");
1055 size_t max_length = 0;
1056 for (
unsigned int i = 0; i < entries; ++i) {
1058 max_length = MAX(max_length, l);
1062 max_length = MAX(max_length, l);
1067 for (
unsigned int i = 0; i < entries; ++i) {
1068 if ((i + 1) < entries) {
1073 if (strncmp(
xrmOptions[i].name,
"kb", 2) != 0 &&
1079 retv = g_realloc(retv, ((*length) + 2) *
sizeof(
char *));
1091 retv = g_realloc(retv, ((*length) + 2) *
sizeof(
char *));
1096 if ((*length) > 0) {
1097 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::@322305174375033275051361074027342304331176316305 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)