28#define G_LOG_DOMAIN "XrmOptions"
46 "Commandline",
"Don't Display"};
102 "Location on screen",
110 "On Wayland, specifies the layer where rofi is rendered. "
111 "Available layers are background, bottom, top, overlay.",
119 "Y-offset relative to location. *DEPRECATED* see rofi-theme manpage "
129 "X-offset relative to location. *DEPRECATED* see rofi-theme manpage "
139 "Always show number of lines",
148 "Whether to load and show icons in the default theme",
157 "Custom command to generate preview icons",
163 "on-selection-changed",
166 "Custom command to call when menu selection changes",
174 "Custom command to call when menu mode changes",
182 "Custom command to call when menu entry is accepted",
190 "Custom command to call when menu is canceled",
198 "Custom command to call when menu finds errors",
203 "on-screenshot-taken",
206 "Custom command to call when menu screenshot is taken",
231 "Ssh command to execute",
239 "Run command to execute",
247 "Command to get extra run targets",
255 "Run command to execute that runs in shell",
263 "Command to executed when -kb-accept-alt binding is hit on selected "
269 "window-match-fields",
272 "Window fields to match in window mode",
280 "Theme to use to look for icons",
289 "Desktop entry fields to match in drun",
297 "Only show Desktop entry from these categories",
302 "drun-exclude-categories",
305 "Exclude Desktop entries from these categories",
313 "Desktop entry show actions.",
318 "drun-display-format",
321 "DRUN format string. (Supports: generic,name,comment,exec,categories)",
329 "Command to open a Desktop Entry that is a Link.",
338 "Disable history in run/ssh",
346 "Programs ignored for history",
354 "Sort menu when filtered",
362 "Choose sort strategy: normal (levenshtein) or fzf.",
370 "Set case-sensitivity",
378 "Set smartcase like vim (determine case-sensitivity by input)",
386 "Cycle through the results list",
394 "Enable sidebar-mode",
402 "Enable hover-select",
410 "Row height (in chars)",
418 "Enable auto select mode",
426 "Parse hosts file for ssh mode",
434 "Parse known_hosts file for ssh mode",
442 "Set the modes to combine in combi mode",
450 "Set the modes to combine in combi mode",
458 "Set the matching algorithm. (normal, regex, glob, fuzzy, prefix)",
466 "Tokenize input string",
483 "Monitor id to show on",
507 "Threads to use for string matching",
515 "Scrolling method. (0: Page, 1: Centered)",
523 "Window Format. w (desktop name), t (title), n (name), r (role), c "
532 "Click outside the window to exit",
540 "Touch swipe in pixels per scroll step, 0 for one list element "
549 "Inhibit compositor shortcuts so they can be reused in rofi (wayland)",
557 "New style theme file",
565 "Max history size (WARNING: can cause slowdowns when set too high).",
570 "combi-hide-mode-prefix",
573 "Hide the prefix mode prefix on the combi view.**deprecated** use "
574 "combi-display-format",
579 "combi-display-format",
582 "Combi format string. (Supports: mode, text)",
587 "matching-negate-char",
590 "Set the character used to negate the matching. ('\\0' to disable)",
598 "Directory where history and temporary files are stored.",
606 "Show window thumbnail (if available) as icon in window switcher.",
611 "drun-use-desktop-cache",
614 "DRUN: build and use a cache with desktop file content.",
619 "drun-reload-desktop-cache",
622 "DRUN: If enabled, reload the cache with desktop file content.",
630 "Normalize string when matching (disables match highlighting).",
638 "Steal focus on launch and restore to window that had it on rofi start "
645 "application-fallback-icon",
648 "Fallback icon to use when the application icon is not found in "
654 "refilter-timeout-limit",
657 "When filtering takes more then this time (in ms) switch to delayed "
663 "xserver-i300-workaround",
666 "Workaround for XServer issue #300 (issue #611 for rofi.)",
673 "What completer to use for drun/run."},
679 "Whether to enable imdkit"},
682 "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) {
763 *(option->
value.num) = TRUE;
767 key = g_strdup_printf(
"-no-%s", option->
name);
769 *(option->
value.num) = FALSE;
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) {
908 *(option->
value.str) = value;
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");
1050 if (*(option->
value.charc) > 32 && *(option->
value.charc) < 127) {
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");
1109 int l = strlen(xo->
name);
1114 (*(xo->
value.str) == NULL) ?
"(unset)" : (*(xo->
value.str)));
1118 printf(
"\t-%s [string]%-*c%s\n", xo->
name, 30 - l,
' ', xo->
comment);
1120 (*(xo->
value.str) == NULL) ?
"(unset)" : (*(xo->
value.str)));
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);
1148 printf(
"\t\t%d", *(xo->
value.snum));
1153 int l = strlen(xo->
name);
1161 printf(
"\t-%s [character]%-*c%s\n", xo->
name, 30 - l,
' ', xo->
comment);
1162 printf(
"\t\t%c", *(xo->
value.charc));
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,
1256 (*(option->
value.str) != NULL) ? *(option->
value.str) :
"null",
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",
1264 if (*(option->
value.charc) > 32 && *(option->
value.charc) < 127) {
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]
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
char * fallback_icon_themes
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::@244212033047230145217067100004346177247122154202 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)