28#define G_LOG_DOMAIN "XrmOptions"
50 "Commandline",
"Don't Display"};
102 "Location on screen",
108 "Y-offset relative to location. *DEPRECATED* see rofi-theme manpage for "
115 "X-offset relative to location. *DEPRECATED* see rofi-theme manpage for "
122 "Always show number of lines",
129 "Whether to load and show icons",
136 "Custom command to generate preview icons",
140 "on-selection-changed",
143 "Custom command to call when menu selection changes",
149 "Custom command to call when menu mode changes",
155 "Custom command to call when menu entry is accepted",
161 "Custom command to call when menu is canceled",
167 "Custom command to call when menu finds errors",
170 "on-screenshot-taken",
173 "Custom command to call when menu screenshot is taken",
192 "Ssh command to execute",
198 "Run command to execute",
204 "Command to get extra run targets",
210 "Run command to execute that runs in shell",
216 "Command to executed when -kb-accept-alt binding is hit on selected "
220 "window-match-fields",
223 "Window fields to match in window mode",
229 "Theme to use to look for icons",
236 "Desktop entry fields to match in drun",
242 "Only show Desktop entry from these categories",
245 "drun-exclude-categories",
248 "Exclude Desktop entries from these categories",
254 "Desktop entry show actions.",
257 "drun-display-format",
260 "DRUN format string. (Supports: generic,name,comment,exec,categories)",
266 "Command to open a Desktop Entry that is a Link.",
273 "Disable history in run/ssh",
279 "Programs ignored for history",
285 "Sort menu when filtered",
291 "Choose sort strategy: normal (levenshtein) or fzf.",
297 "Set case-sensitivity",
303 "Set smartcase like vim (determine case-sensitivity by input)",
309 "Cycle through the results list",
315 "Enable sidebar-mode",
321 "Enable hover-select",
327 "Row height (in chars)",
333 "Enable auto select mode",
339 "Parse hosts file for ssh mode",
345 "Parse known_hosts file for ssh mode",
351 "Set the modes to combine in combi mode",
357 "Set the modes to combine in combi mode",
363 "Set the matching algorithm. (normal, regex, glob, fuzzy, prefix)",
369 "Tokenize input string",
377 "Monitor id to show on",
390 "Threads to use for string matching",
396 "Scrolling method. (0: Page, 1: Centered)",
402 "Window Format. w (desktop name), t (title), n (name), r (role), c "
409 "Click outside the window to exit",
415 "New style theme file",
421 "Max history size (WARNING: can cause slowdowns when set too high).",
424 "combi-hide-mode-prefix",
427 "Hide the prefix mode prefix on the combi view.**deprecated** use "
428 "combi-display-format",
431 "combi-display-format",
434 "Combi format string. (Supports: mode, text)",
437 "matching-negate-char",
440 "Set the character used to negate the matching. ('\\0' to disable)",
446 "Directory where history and temporary files are stored.",
452 "Show window thumbnail (if available) as icon in window switcher.",
455 "drun-use-desktop-cache",
458 "DRUN: build and use a cache with desktop file content.",
461 "drun-reload-desktop-cache",
464 "DRUN: If enabled, reload the cache with desktop file content.",
470 "Normalize string when matching (disables match highlighting).",
476 "Steal focus on launch and restore to window that had it on rofi start on "
480 "application-fallback-icon",
483 "Fallback icon to use when the application icon is not found in run/drun.",
486 "refilter-timeout-limit",
489 "When filtering takes more then this time (in ms) switch to delayed "
493 "xserver-i300-workaround",
496 "Workaround for XServer issue #300 (issue #611 for rofi.)",
502 "What completer to use for drun/run.",
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);
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) {
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]
unsigned int disable_history
char * application_fallback_icon
char * on_screenshot_taken
unsigned int parse_known_hosts
unsigned int scroll_method
gboolean drun_reload_desktop_cache
unsigned int fixed_num_lines
gboolean xserver_i300_workaround
unsigned int drun_show_actions
unsigned int max_history_size
unsigned int case_sensitive
char * drun_display_format
gboolean combi_hide_mode_prefix
char * drun_exclude_categories
char * window_match_fields
gboolean window_thumbnail
unsigned int sidebar_mode
char matching_negate_char
unsigned int refilter_timeout_limit
char * on_selection_changed
gboolean drun_use_desktop_cache
char * combi_display_format
union XrmOption::@5 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)