28#define G_LOG_DOMAIN "XrmOptions"
46 "Commandline",
"Don't Display"};
92 {.str = &
config.menu_font},
100 {.num = &
config.location},
102 "Location on screen",
108 {.str = &
config.wayland_layer},
110 "On Wayland, specifies the layer where rofi is rendered. "
111 "Available layers are background, bottom, top, overlay.",
117 {.snum = &
config.y_offset},
119 "Y-offset relative to location. *DEPRECATED* see rofi-theme manpage "
127 {.snum = &
config.x_offset},
129 "X-offset relative to location. *DEPRECATED* see rofi-theme manpage "
137 {.num = &
config.fixed_num_lines},
139 "Always show number of lines",
146 {.snum = &
config.show_icons},
148 "Whether to load and show icons in the default theme",
155 {.str = &
config.preview_cmd},
157 "Custom command to generate preview icons",
163 "on-selection-changed",
164 {.str = &
config.on_selection_changed},
166 "Custom command to call when menu selection changes",
172 {.str = &
config.on_mode_changed},
174 "Custom command to call when menu mode changes",
180 {.str = &
config.on_entry_accepted},
182 "Custom command to call when menu entry is accepted",
188 {.str = &
config.on_menu_canceled},
190 "Custom command to call when menu is canceled",
196 {.str = &
config.on_menu_error},
198 "Custom command to call when menu finds errors",
203 "on-screenshot-taken",
204 {.str = &
config.on_screenshot_taken},
206 "Custom command to call when menu screenshot is taken",
213 {.str = &
config.terminal_emulator},
221 {.str = &
config.ssh_client},
229 {.str = &
config.ssh_command},
231 "Ssh command to execute",
237 {.str = &
config.run_command},
239 "Run command to execute",
245 {.str = &
config.run_list_command},
247 "Command to get extra run targets",
253 {.str = &
config.run_shell_command},
255 "Run command to execute that runs in shell",
261 {.str = &
config.window_command},
263 "Command to executed when -kb-accept-alt binding is hit on selected "
269 "window-match-fields",
270 {.str = &
config.window_match_fields},
272 "Window fields to match in window mode",
278 {.str = &
config.icon_theme},
280 "Theme to use to look for icons",
287 {.str = &
config.drun_match_fields},
289 "Desktop entry fields to match in drun",
295 {.str = &
config.drun_categories},
297 "Only show Desktop entry from these categories",
302 "drun-exclude-categories",
303 {.str = &
config.drun_exclude_categories},
305 "Exclude Desktop entries from these categories",
311 {.num = &
config.drun_show_actions},
313 "Desktop entry show actions.",
318 "drun-display-format",
319 {.str = &
config.drun_display_format},
321 "DRUN format string. (Supports: generic,name,comment,exec,categories)",
327 {.str = &
config.drun_url_launcher},
329 "Command to open a Desktop Entry that is a Link.",
336 {.num = &
config.disable_history},
338 "Disable history in run/ssh",
344 {.str = &
config.ignored_prefixes},
346 "Programs ignored for history",
354 "Sort menu when filtered",
360 {.str = &
config.sorting_method},
362 "Choose sort strategy: normal (levenshtein) or fzf.",
368 {.num = &
config.case_sensitive},
370 "Set case-sensitivity",
376 {.num = &
config.case_smart},
378 "Set smartcase like vim (determine case-sensitivity by input)",
386 "Cycle through the results list",
392 {.num = &
config.sidebar_mode},
394 "Enable sidebar-mode",
400 {.snum = &
config.hover_select},
402 "Enable hover-select",
408 {.snum = &
config.element_height},
410 "Row height (in chars)",
416 {.num = &
config.auto_select},
418 "Enable auto select mode",
424 {.num = &
config.parse_hosts},
426 "Parse hosts file for ssh mode",
432 {.num = &
config.parse_known_hosts},
434 "Parse known_hosts file for ssh mode",
440 {.str = &
config.combi_modes},
442 "Set the modes to combine in combi mode",
448 {.str = &
config.combi_modes},
450 "Set the modes to combine in combi mode",
456 {.str = &
config.matching},
458 "Set the matching algorithm. (normal, regex, glob, fuzzy, prefix)",
464 {.num = &
config.tokenize},
466 "Tokenize input string",
483 "Monitor id to show on",
507 "Threads to use for string matching",
513 {.num = &
config.scroll_method},
515 "Scrolling method. (0: Page, 1: Centered)",
521 {.str = &
config.window_format},
523 "Window Format. w (desktop name), t (title), n (name), r (role), c "
530 {.snum = &
config.click_to_exit},
532 "Click outside the window to exit",
538 {.snum = &
config.touch_scroll_step},
540 "Touch swipe in pixels per scroll step, 0 for one list element "
547 {.snum = &
config.global_kb},
549 "Inhibit compositor shortcuts so they can be reused in rofi (wayland)",
557 "New style theme file",
563 {.num = &
config.max_history_size},
565 "Max history size (WARNING: can cause slowdowns when set too high).",
570 "combi-hide-mode-prefix",
571 {.snum = &
config.combi_hide_mode_prefix},
573 "Hide the prefix mode prefix on the combi view.**deprecated** use "
574 "combi-display-format",
579 "combi-display-format",
580 {.str = &
config.combi_display_format},
582 "Combi format string. (Supports: mode, text)",
587 "matching-negate-char",
588 {.charc = &
config.matching_negate_char},
590 "Set the character used to negate the matching. ('\\0' to disable)",
596 {.str = &
config.cache_dir},
598 "Directory where history and temporary files are stored.",
604 {.snum = &
config.window_thumbnail},
606 "Show window thumbnail (if available) as icon in window switcher.",
611 "drun-use-desktop-cache",
612 {.snum = &
config.drun_use_desktop_cache},
614 "DRUN: build and use a cache with desktop file content.",
619 "drun-reload-desktop-cache",
620 {.snum = &
config.drun_reload_desktop_cache},
622 "DRUN: If enabled, reload the cache with desktop file content.",
628 {.snum = &
config.normalize_match},
630 "Normalize string when matching (disables match highlighting).",
636 {.snum = &
config.steal_focus},
638 "Steal focus on launch and restore to window that had it on rofi start "
645 "application-fallback-icon",
646 {.str = &(
config.application_fallback_icon)},
648 "Fallback icon to use when the application icon is not found in "
654 "refilter-timeout-limit",
655 {.num = &(
config.refilter_timeout_limit)},
657 "When filtering takes more then this time (in ms) switch to delayed "
663 "xserver-i300-workaround",
664 {.snum = &(
config.xserver_i300_workaround)},
666 "Workaround for XServer issue #300 (issue #611 for rofi.)",
671 {.str = &(
config.completer_mode)},
673 "What completer to use for drun/run."},
677 {.snum = &
config.enable_imdkit},
679 "Whether to enable imdkit"},
682 "fallback-icon-themes",
683 {.str = &
config.fallback_icon_themes},
685 "List of fallback icon themes"},
700 const char *comment) {
719 iter = g_list_next(iter)) {
720 if (g_strcmp0(((
Property *)(iter->data))->name, key) == 0) {
722 g_debug(
"Setting property from backup list: %s", key);
724 (
Property *)(iter->data), &error)) {
725 g_debug(
"Failed to set property on custom entry: %s", key);
740 char *key = g_strdup_printf(
"-%s", option->
name);
741 switch (option->
type) {
754 if (option->
mem != NULL) {
767 key = g_strdup_printf(
"-no-%s", option->
name);
786 int count,
char *argv,
788 if (strlen(argv) > 4096) {
791 for (
int j = 0; j < (
count - 1); j++) {
792 g_string_append_printf(str,
"%s { ", tokens[j]);
795 char *esc = g_strescape(argv, NULL);
796 g_string_append_printf(str,
"%s: \"%s\";", tokens[
count - 1], esc);
799 g_string_append_printf(str,
"%s: %s;", tokens[
count - 1], argv);
801 for (
int j = 0; j < (
count - 1); j++) {
802 g_string_append(str,
" } ");
827 char **tokens = g_strsplit(
stored_argv[in],
"-", 3);
829 for (
int j = 1; tokens && tokens[j]; j++) {
833 if (g_str_has_prefix(tokens[1],
"theme")) {
836 count = g_strv_length(tokens);
838 GString *str = g_string_new(
"");
844 g_string_free(str, TRUE);
847 g_string_free(str, TRUE);
849 }
else if (g_strcmp0(tokens[1],
"no") != 0) {
850 GString *str = g_string_new(
"configuration { ");
853 g_string_append(str,
"}");
854 g_debug(
"str: \"%s\"\n", str->str);
858 g_string_assign(str,
"configuration { ");
861 g_string_append(str,
"}");
862 g_debug(
"str: \"%s\"\n", str->str);
868 g_string_free(str, TRUE);
882 g_strdup_printf(
"Option: %s needs to be set with a string not a %s.",
888 for (GList *iter = p->
value.
list; iter != NULL;
889 iter = g_list_next(iter)) {
892 value = g_strdup((
char *)(p2->
value.
s));
894 char *nv = g_strjoin(
",", value, (
char *)(p2->
value.
s), NULL);
900 value = g_strdup_printf(
"%d", p->
value.
i);
902 value = g_strdup(p->
value.
s);
904 if ((option)->mem != NULL) {
911 (option)->mem = *(option->
value.
str);
916 g_strdup_printf(
"Option: %s needs to be set with a number not a %s.",
925 g_strdup_printf(
"Option: %s needs to be set with a number not a %s.",
934 g_strdup_printf(
"Option: %s needs to be set with a boolean not a %s.",
944 g_strdup_printf(
"Option: %s needs to be set with a string not a %s.",
952 *error = g_strdup_printf(
"Option: %s is not of a supported type: %s.",
960 if (g_ascii_strcasecmp(p->
name,
"theme") == 0) {
962 *error = g_strdup_printf(
"The option:\n<b>\nconfiguration\n{\n\ttheme: "
963 "\"%s\";\n}</b>\nis deprecated. Please replace "
964 "with: <b>@theme \"%s\"</b> "
965 "after the configuration block.",
968 *error = g_strdup_printf(
"The option:\n<b>\nconfiguration\n{\n\ttheme: "
969 "\"%s\";\n}</b>\nis deprecated. Please replace "
970 "with: <b>@theme \"%s\"</b> "
971 "after the configuration block.",
972 "myTheme",
"myTheme");
978 if (g_strcmp0(op->
name, p->
name) == 0) {
984 if (g_strcmp0(op->
name, p->
name) == 0) {
989 g_debug(
"Option: %s is not found.", p->
name);
992 iter = g_list_next(iter)) {
993 if (g_strcmp0(((
Property *)(iter->data))->name, p->
name) == 0) {
999 g_debug(
"Adding option: %s to backup list.", p->
name);
1007 for (
unsigned int i = 0; i < (
sizeof(
xrmOptions) /
sizeof(*xrmOptions));
1031 fprintf(out,
"\t%s: ", option->
name);
1032 switch (option->
type) {
1034 fprintf(out,
"%u", *(option->
value.
num));
1037 fprintf(out,
"%i", *(option->
value.
snum));
1040 if ((*(option->
value.
str)) != NULL) {
1042 fprintf(out,
"\"%s\"", *(option->
value.
str));
1046 fprintf(out,
"%s", (*(option->
value.
num) == TRUE) ?
"true" :
"false");
1051 fprintf(out,
"'%c'", *(option->
value.
charc));
1053 fprintf(out,
"'\\x%02X'", *(option->
value.
charc));
1055 fprintf(out,
" /* unsupported */");
1069 fprintf(out,
"configuration {\n");
1072 for (
unsigned int i = 0; i < entries; ++i) {
1074 if ((i + 1) < entries) {
1101 fprintf(out,
"}\n");
1103 if (
config.theme != NULL) {
1104 fprintf(out,
"@theme \"%s\"\r\n",
config.theme);
1109 int l = strlen(xo->
name);
1118 printf(
"\t-%s [string]%-*c%s\n", xo->
name, 30 - l,
' ', xo->
comment);
1125 int l = strlen(xo->
name);
1133 printf(
"\t-%s [number]%-*c%s\n", xo->
name, 30 - l,
' ', xo->
comment);
1134 printf(
"\t\t%u", *(xo->
value.
num));
1139 int l = strlen(xo->
name);
1147 printf(
"\t-%s [number]%-*c%s\n", xo->
name, 30 - l,
' ', xo->
comment);
1153 int l = strlen(xo->
name);
1161 printf(
"\t-%s [character]%-*c%s\n", xo->
name, 30 - l,
' ', xo->
comment);
1167 int l = strlen(xo->
name);
1172 (*(xo->
value.
snum)) ?
"True" :
"False");
1176 printf(
"\t-[no-]%s %-*c%s\n", xo->
name, 33 - l,
' ', xo->
comment);
1177 printf(
"\t\t%s", (*(xo->
value.
snum)) ?
"True" :
"False");
1208 int is_term = isatty(fileno(stdout));
1210 for (
unsigned int i = 0; i < entries; ++i) {
1211 if ((i + 1) < entries) {
1224 const char *def,
int isatty) {
1225 int l = 37 - strlen(option) - strlen(type);
1233 printf(
"\t%s %s %-*c%s\n", option, type, l,
' ', text);
1235 printf(
"\t\t%s\n", def);
1243 switch (option->
type) {
1245 return g_markup_printf_escaped(
1246 "<b%-*s</b> (%u) <span style='italic' size='small'>%s</span>", ll,
1249 return g_markup_printf_escaped(
1250 "<b%-*s</b> (%d) <span style='italic' size='small'>%s</span>", ll,
1253 return g_markup_printf_escaped(
1254 "<b>%-*s</b> (%s) <span style='italic' size='small'>%s</span>", ll,
1259 return g_markup_printf_escaped(
1260 "<b>%-*s</b> (%s) <span style='italic' size='small'>%s</span>", ll,
1261 option->
name, (*(option->
value.
num) == TRUE) ?
"true" :
"false",
1265 return g_markup_printf_escaped(
1266 "<b>%-*s</b> (%c) <span style='italic' size='small'>%s</span>", ll,
1269 return g_markup_printf_escaped(
1270 "<b%-*s</b> (\\x%02X) <span style='italic' size='small'>%s</span>",
1277 return g_strdup(
"failed");
1286 size_t max_length = 0;
1287 for (
unsigned int i = 0; i < entries; ++i) {
1289 max_length = MAX(max_length, l);
1293 max_length = MAX(max_length, l);
1298 for (
unsigned int i = 0; i < entries; ++i) {
1299 if ((i + 1) < entries) {
1304 if (strncmp(
xrmOptions[i].name,
"kb", 2) != 0 &&
1310 retv = g_realloc(retv, ((*length) + 2) *
sizeof(
char *));
1322 retv = g_realloc(retv, ((*length) + 2) *
sizeof(
char *));
1327 if ((*length) > 0) {
1328 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::@267141020341015174321034142057225345224206123123 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)