rofi 2.1.0
rofi.c
Go to the documentation of this file.
1/*
2 * rofi
3 *
4 * MIT/X11 License
5 * Copyright © 2012 Sean Pringle <sean.pringle@gmail.com>
6 * Copyright © 2013-2023 Qball Cow <qball@gmpclient.org>
7 *
8 * Permission is hereby granted, free of charge, to any person obtaining
9 * a copy of this software and associated documentation files (the
10 * "Software"), to deal in the Software without restriction, including
11 * without limitation the rights to use, copy, modify, merge, publish,
12 * distribute, sublicense, and/or sell copies of the Software, and to
13 * permit persons to whom the Software is furnished to do so, subject to
14 * the following conditions:
15 *
16 * The above copyright notice and this permission notice shall be
17 * included in all copies or substantial portions of the Software.
18 *
19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
20 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
22 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
23 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
24 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
25 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26 *
27 */
28
30#include "glib.h"
31#define G_LOG_DOMAIN "Rofi"
32
33#include "config.h"
34#include <errno.h>
35#include <gmodule.h>
36#include <locale.h>
37#include <stdint.h>
38#include <stdlib.h>
39#include <string.h>
40#include <sys/stat.h>
41#include <sys/types.h>
42#include <sysexits.h>
43#include <time.h>
44#include <unistd.h>
45
46#include <glib-unix.h>
47
48#ifdef USE_NK_GIT_VERSION
49#include "nkutils-git-version.h"
50#ifdef NK_GIT_VERSION
51#define GIT_VERSION NK_GIT_VERSION
52#endif
53#endif
54
55#include "resources.h"
56
57#include "display.h"
58#include "rofi.h"
59#include "settings.h"
60
61#include "helper.h"
62#include "mode.h"
63#include "modes/modes.h"
64#include "widgets/textbox.h"
65#include "xrmoptions.h"
66
67#include "view-internal.h"
68#include "view.h"
69
70#include "rofi-icon-fetcher.h"
71#include "theme.h"
72
73#include "timings.h"
74
75#ifdef ENABLE_WAYLAND
76#include <wayland-version.h>
77
78#endif
79
80// Limit the max stdin input to 4gb.
81#define ROFI_MAX_DMENU_INPUT UINT32_MAX
82
84char *pidfile = NULL;
86const char *cache_dir = NULL;
89char *cache_dir_alloc = NULL;
90
92GList *list_of_error_msgs = NULL;
95
96static void rofi_collectmodes_destroy(void);
97void rofi_add_error_message(GString *str) {
98 list_of_error_msgs = g_list_append(list_of_error_msgs, str);
99}
101 if (list_of_error_msgs) {
102 for (GList *iter = g_list_first(list_of_error_msgs); iter != NULL;
103 iter = g_list_next(iter)) {
104 g_string_free((GString *)iter->data, TRUE);
105 }
106 g_list_free(list_of_error_msgs);
107 list_of_error_msgs = NULL;
108 }
109}
110void rofi_add_warning_message(GString *str) {
111 list_of_warning_msgs = g_list_append(list_of_warning_msgs, str);
112}
115 for (GList *iter = g_list_first(list_of_warning_msgs); iter != NULL;
116 iter = g_list_next(iter)) {
117 g_string_free((GString *)iter->data, TRUE);
118 }
119 g_list_free(list_of_warning_msgs);
121 }
122}
123
125G_MODULE_EXPORT char *config_path = NULL;
128Mode **modes = NULL;
129
133unsigned int num_available_modes = 0;
135unsigned int num_modes = 0;
137unsigned int curr_mode = 0;
138
140NkBindings *bindings = NULL;
141
143gboolean display_setup_success = FALSE;
144
146GMainLoop *main_loop = NULL;
147
151int return_code = EXIT_SUCCESS;
152
153void process_result(RofiViewState *state);
154
155void rofi_set_return_code(int code) { return_code = code; }
156
157unsigned int rofi_get_num_enabled_modes(void) { return num_modes; }
158
159const Mode *rofi_get_mode(unsigned int index) { return modes[index]; }
160
161int mode_lookup(const char *name) {
162 for (unsigned int i = 0; i < num_modes; i++) {
163 if (strcmp(mode_get_name(modes[i]), name) == 0) {
164 return i;
165 }
166 }
167 return -1;
168}
169
176static const Mode *mode_available_lookup(const char *name) {
177 for (unsigned int i = 0; i < num_available_modes; i++) {
178 if (strcmp(mode_get_name(available_modes[i]), name) == 0) {
179 return available_modes[i];
180 }
181 }
182 return NULL;
183}
184
188static void teardown(int pfd) {
189 g_debug("Teardown");
190 // Cleanup font setup.
192
194
195 // Cleanup view
197
198 // Cleanup pid file.
199 remove_pid_file(pfd);
200}
201static void run_mode_index(ModeMode mode) {
202 // Otherwise check if requested mode is enabled.
203 for (unsigned int i = 0; i < num_modes; i++) {
204 if (!mode_init(modes[i])) {
205 GString *str = g_string_new("Failed to initialize the mode: ");
206 g_string_append(str, mode_get_name(modes[i]));
207 g_string_append(str, "\n");
208
210 g_string_free(str, FALSE);
211 break;
212 }
213 }
214 // Error dialog must have been created.
215 if (rofi_view_get_active() != NULL) {
216 return;
217 }
218 curr_mode = mode;
219 RofiViewState *state =
221
222 // User can pre-select a row.
223 if (find_arg("-selected-row") >= 0) {
224 unsigned int sr = 0;
225 find_arg_uint("-selected-row", &(sr));
227 }
228 if (state) {
230 }
231 if (rofi_view_get_active() == NULL) {
232 g_main_loop_quit(main_loop);
233 }
234}
236 Mode *sw = state->sw;
237 // rofi_view_set_active ( NULL );
238 if (sw != NULL) {
239 unsigned int selected_line = rofi_view_get_selected_line(state);
240 ;
242 char *input = g_strdup(rofi_view_get_user_input(state));
243 ModeMode retv = mode_result(sw, mretv, &input, selected_line);
244 {
245 if (state->text) {
246 if (input == NULL) {
247 textbox_text(state->text, "");
248 } else if (strcmp(rofi_view_get_user_input(state), input) != 0) {
249 textbox_text(state->text, input);
250 textbox_cursor_end(state->text);
251 }
252 }
253 }
254 g_free(input);
255
256 ModeMode mode = curr_mode;
257 // Find next enabled
258 if (retv == NEXT_DIALOG) {
259 mode = (mode + 1) % num_modes;
260 } else if (retv == PREVIOUS_DIALOG) {
261 if (mode == 0) {
262 mode = num_modes - 1;
263 } else {
264 mode = (mode - 1) % num_modes;
265 }
266 } else if (retv == RELOAD_DIALOG) {
267 // do nothing.
268 } else if (retv == RESET_DIALOG) {
270 } else if (retv < MODE_EXIT) {
271 mode = (retv) % num_modes;
272 } else {
273 mode = retv;
274 }
275 if (mode != MODE_EXIT) {
279 rofi_view_switch_mode(state, modes[mode]);
280 curr_mode = mode;
281 return;
282 }
283 // On exit, free current view, and pop to one above.
285 rofi_view_free(state);
286 return;
287 }
288 // rofi_view_set_active ( NULL );
290 rofi_view_free(state);
291}
292
296static void print_list_of_modes(int is_term) {
297 for (unsigned int i = 0; i < num_available_modes; i++) {
298 gboolean active = FALSE;
299 for (unsigned int j = 0; j < num_modes; j++) {
300 if (modes[j] == available_modes[i]) {
301 active = TRUE;
302 break;
303 }
304 }
305 printf(" • %s%s%s%s", active ? "+" : "",
306 is_term ? (active ? color_green : color_red) : "",
307 mode_get_name(available_modes[i]), is_term ? color_reset : "");
308 if (mode_plugin_get_module(available_modes[i]) != NULL) {
309 printf(" (external)");
310 }
311 printf("\n");
312 }
313}
314static void print_main_application_options(int is_term) {
315 print_help_msg("-config", "[file]", "Load an alternative configuration.",
316 NULL, is_term);
317 print_help_msg("-no-config", "",
318 "Do not load configuration, use default values.", NULL,
319 is_term);
320 print_help_msg("-v,-version", "", "Print the version number and exit.", NULL,
321 is_term);
322 print_help_msg("-dmenu", "", "Start in dmenu mode.", NULL, is_term);
323 print_help_msg("-display", "[string]", "X server to contact.", "${DISPLAY}",
324 is_term);
325 print_help_msg("-h,-help", "", "This help message.", NULL, is_term);
326 print_help_msg("-e", "[string]",
327 "Show a dialog displaying the passed message and exit.", NULL,
328 is_term);
329 print_help_msg("-markup", "", "Enable pango markup where possible.", NULL,
330 is_term);
331 print_help_msg("-normal-window", "",
332 "Behave as a normal window. (experimental)", NULL, is_term);
333 print_help_msg("-transient-window", "",
334 "Behave as a modal dialog that is transient to the currently "
335 "focused window. (experimental)",
336 NULL, is_term);
337 print_help_msg("-show", "[mode]",
338 "Show the mode 'mode' and exit. The mode has to be enabled.",
339 NULL, is_term);
340 print_help_msg("-no-lazy-grab", "",
341 "Disable lazy grab that, when fail to grab keyboard, does not "
342 "block but retry later.",
343 NULL, is_term);
344 print_help_msg("-no-plugins", "", "Disable loading of external plugins.",
345 NULL, is_term);
346 print_help_msg("-plugin-path", "",
347 "Directory used to search for rofi plugins. *DEPRECATED*",
348 NULL, is_term);
349 print_help_msg("-dump-config", "",
350 "Dump the current configuration in rasi format and exit.",
351 NULL, is_term);
352 print_help_msg("-dump-theme", "",
353 "Dump the current theme in rasi format and exit.", NULL,
354 is_term);
355 print_help_msg("-list-keybindings", "",
356 "Print a list of current keybindings and exit.", NULL,
357 is_term);
358}
359
360static void print_backend_info(void) {
361 int is_term = isatty(fileno(stdout));
362 printf("Display backends:\n");
363#ifdef ENABLE_XCB
364 printf("\t• xcb");
365 if (config.backend == DISPLAY_XCB) {
366 printf(": %sselected%s\n", is_term ? color_bold : "",
367 is_term ? color_reset : "");
368 } else {
369 printf("\n");
370 }
371#endif
372#ifdef ENABLE_WAYLAND
373 printf("\t• wayland");
375 printf(": %sselected%s\n", is_term ? color_bold : "",
376 is_term ? color_reset : "");
377 } else {
378 printf("\n");
379 }
380#endif
381 printf("\n");
382}
383
384static void help(G_GNUC_UNUSED int argc, char **argv, const gboolean compact) {
385 int is_term = isatty(fileno(stdout));
386 const char *color_bold_str = is_term ? color_bold : "";
387 const char *color_reset_str = is_term ? color_reset : "";
388 if (!compact) {
389 printf("%s usage:\n", argv[0]);
390 printf("\t%s [-options ...]\n\n", argv[0]);
391 printf("Command line only options:\n");
393 printf("DMENU command line options:\n");
395 printf("Global options:\n");
397 printf("\n");
398 }
401#ifdef ENABLE_XCB
402 if (config.backend == DISPLAY_XCB) {
403 printf("Detected Window manager:\n");
405 if (wm) {
406 printf("\t• %s\n", wm);
407 g_free(wm);
408 } else {
409 printf("\t• No window manager detected.\n");
410 }
411 printf("\n");
412 }
413#endif
415 printf("\n");
416 }
417 printf("Detected modes:\n");
418 print_list_of_modes(is_term);
419 printf("\n");
420 printf("Detected user scripts:\n");
421 script_user_list(is_term);
422 printf("\n");
423 printf("Compile time options:\n");
424 printf("\t• Pango version %s\n", pango_version_string());
425#ifdef WINDOW_MODE
426 printf("\t• window %senabled%s\n", is_term ? color_green : "",
427 color_reset_str);
428#else
429 printf("\t• window %sdisabled%s\n", is_term ? color_red : "",
430 color_reset_str);
431#endif
432#ifdef ENABLE_DRUN
433 printf("\t• drun %senabled%s\n", is_term ? color_green : "",
434 color_reset_str);
435#else
436 printf("\t• drun %sdisabled%s\n", is_term ? color_red : "",
437 color_reset_str);
438#endif
439#ifdef ENABLE_ASAN
440 printf("\t• asan %senabled%s\n", is_term ? color_green : "",
441 color_reset_str);
442#else
443 printf("\t• asan %sdisabled%s\n", is_term ? color_red : "",
444 color_reset_str);
445#endif
446#ifdef XCB_IMDKIT
447 printf("\t• imdkit %senabled%s\n", is_term ? color_green : "",
448 color_reset_str);
449#else
450 printf("\t• imdkit %sdisabled%s\n", is_term ? color_red : "",
451 color_reset_str);
452#endif
453#ifdef ENABLE_XCB
454 printf("\t• xcb %senabled%s\n", is_term ? color_green : "",
455 color_reset_str);
456#else
457 printf("\t• xcb %sdisabled%s\n", is_term ? color_red : "",
458 color_reset_str);
459#endif
460#ifdef ENABLE_WAYLAND
461 printf("\t• wayland %senabled%s (%s)\n", is_term ? color_green : "",
462 color_reset_str, WAYLAND_VERSION);
463#else
464 printf("\t• wayland %sdisabled%s\n", is_term ? color_red : "",
465 color_reset_str);
466#endif
467 printf("\n");
468 printf("For more information see: %sman rofi%s\n", color_bold_str,
469 color_reset_str);
470#ifdef GIT_VERSION
471 printf(" Version: %s" GIT_VERSION "%s\n", color_bold_str,
472 color_reset_str);
473#else
474 printf(" Version: %s" VERSION "%s\n", color_bold_str,
475 color_reset_str);
476#endif
477 printf(" Bugreports: %s" PACKAGE_BUGREPORT "%s\n",
478 color_bold_str, color_reset_str);
479 printf(" Support: %s" PACKAGE_URL "%s\n", color_bold_str,
480 color_reset_str);
481 printf(" %s#rofi @ libera.chat%s\n", color_bold_str,
482 color_reset_str);
483 if (find_arg("-no-config") < 0) {
484 if (config_path) {
485 printf(" Configuration file: %s%s%s\n", color_bold_str, config_path,
486 color_reset_str);
487 }
488 } else {
489 printf(" Configuration file: %sDisabled%s\n", color_bold_str,
490 color_reset_str);
491 }
493
495 printf("\nXDG Data directories\n");
496 printf("\tUser:\n");
497 const char *udd = g_get_user_data_dir();
498 printf("\t• %sXDG_DATA_HOME=%s\'%s\'\n", color_bold_str, color_reset_str,
499 udd);
500 const char *ucd = g_get_user_config_dir();
501 printf("\t• %sXDG_CONFIG_HOME=%s\'%s\'\n", color_bold_str, color_reset_str,
502 ucd);
503 const char *ucad = g_get_user_cache_dir();
504 printf("\t• %sXDG_CACHE_HOME=%s\'%s\'\n", color_bold_str, color_reset_str,
505 ucad);
506
507 const char *udesktopd = g_get_user_special_dir(G_USER_DIRECTORY_DESKTOP);
508 printf("\t• %sDesktop=%s\'%s\'\n", color_bold_str, color_reset_str,
509 udesktopd);
510 const char *upicturesd = g_get_user_special_dir(G_USER_DIRECTORY_PICTURES);
511 printf("\t• %spictures=%s\'%s\'\n", color_bold_str, color_reset_str,
512 upicturesd);
513 printf("\n\tSystem:\n");
514 const char *const *sdd = g_get_system_data_dirs();
515 printf("\t• %sXDG_DATA_DIRS=%s[", color_bold_str, color_reset_str);
516 for (int i = 0; sdd && sdd[i]; i++) {
517 printf("\'%s\'", sdd[i]);
518 if (sdd[i + 1]) {
519 printf(",");
520 }
521 }
522 printf("]\n");
523 const char *const *scd = g_get_system_config_dirs();
524 printf("\t• %sXDG_CONFIG_DIRS=%s[", color_bold_str, color_reset_str);
525 for (int i = 0; scd && scd[i]; i++) {
526 printf("\'%s\'", scd[i]);
527 if (scd[i + 1]) {
528 printf(",");
529 }
530 }
531 printf("]\n");
532}
533
534static void help_print_disabled_mode(const char *mode) {
535 int is_term = isatty(fileno(stdout));
536 // Only output to terminal
537 if (is_term) {
538 fprintf(stderr, "Mode %s%s%s is not enabled. I have enabled it for now.\n",
539 color_red, mode, color_reset);
540 fprintf(stderr,
541 "Please consider adding %s%s%s to the list of enabled modes: "
542 "%smodes: [%s%s%s,%s]%s.\n",
545 }
546}
547static void help_print_mode_not_found(const char *mode) {
548 GString *str = g_string_new("");
549 g_string_printf(
550 str, "Mode %s is not found.\nThe following modes are known:\n", mode);
551 for (unsigned int i = 0; i < num_available_modes; i++) {
552 gboolean active = FALSE;
553 for (unsigned int j = 0; j < num_modes; j++) {
554 if (modes[j] == available_modes[i]) {
555 active = TRUE;
556 break;
557 }
558 }
559 g_string_append_printf(str, " * %s%s\n", active ? "+" : "",
561 }
563}
564static void help_print_no_arguments(void) {
565
566 GString *emesg = g_string_new(
567 "<span size=\"x-large\">Rofi is unsure what to show.</span>\n\n");
568 g_string_append(emesg, "Please specify the mode you want to show.\n\n");
569 g_string_append(
570 emesg, " <b>rofi</b> -show <span color=\"green\">{mode}</span>\n\n");
571 g_string_append(emesg, "The following modes are enabled:\n");
572 for (unsigned int j = 0; j < num_modes; j++) {
573 g_string_append_printf(emesg, " • <span color=\"green\">%s</span>\n",
574 mode_get_name(modes[j]));
575 }
576 g_string_append(emesg, "\nThe following modes can be enabled:\n");
577 for (unsigned int i = 0; i < num_available_modes; i++) {
578 gboolean active = FALSE;
579 for (unsigned int j = 0; j < num_modes; j++) {
580 if (modes[j] == available_modes[i]) {
581 active = TRUE;
582 break;
583 }
584 }
585 if (!active) {
586 g_string_append_printf(emesg, " • <span color=\"red\">%s</span>\n",
588 }
589 }
590 g_string_append(emesg, "\nTo activate a mode, add it to the list in "
591 "the <span color=\"green\">modes</span> "
592 "setting.\n");
594 rofi_set_return_code(EXIT_SUCCESS);
595}
596
600static void cleanup(void) {
601 for (unsigned int i = 0; i < num_modes; i++) {
603 }
605 if (main_loop != NULL) {
606 g_main_loop_unref(main_loop);
607 main_loop = NULL;
608 }
609 // Cleanup
611
612 nk_bindings_free(bindings);
613
614 // Cleaning up memory allocated by the Xresources file.
616 g_free(modes);
617
618 g_free(config_path);
619
622
623 if (rofi_theme) {
625 rofi_theme = NULL;
626 }
627 TIMINGS_STOP();
631
633 if (rofi_configuration) {
635 rofi_configuration = NULL;
636 }
637 // Cleanup memory allocated by rofi_expand_path
638 if (cache_dir_alloc) {
639 g_free(cache_dir_alloc);
640 cache_dir_alloc = NULL;
641 }
642}
643
647
648Mode *rofi_collect_modes_search(const char *name) {
649 for (unsigned int i = 0; i < num_available_modes; i++) {
650 if (g_strcmp0(name, mode_get_name(available_modes[i])) == 0) {
651 return available_modes[i];
652 }
653 }
654 return NULL;
655}
656
661static gboolean rofi_collectmodes_add(Mode *mode) {
663 if (m == NULL) {
665 g_realloc(available_modes, sizeof(Mode *) * (num_available_modes + 1));
666 // Set mode.
669 return TRUE;
670 }
671 return FALSE;
672}
673
674static void rofi_collectmodes_dir(const char *base_dir) {
675 g_debug("Looking into: %s for plugins", base_dir);
676 GDir *dir = g_dir_open(base_dir, 0, NULL);
677 if (dir) {
678 const char *dn = NULL;
679 while ((dn = g_dir_read_name(dir))) {
680 if (!g_str_has_suffix(dn, G_MODULE_SUFFIX)) {
681 continue;
682 }
683 char *fn = g_build_filename(base_dir, dn, NULL);
684 g_debug("Trying to open: %s plugin", fn);
685 GModule *mod =
686 g_module_open(fn, G_MODULE_BIND_LAZY | G_MODULE_BIND_LOCAL);
687 if (mod) {
688 Mode *m = NULL;
689 if (g_module_symbol(mod, "mode", (gpointer *)&m)) {
691 g_warning("ABI version of plugin: '%s' does not match: %08X "
692 "expecting: %08X",
694 g_module_close(mod);
695 } else {
697 if (!rofi_collectmodes_add(m)) {
698 g_module_close(mod);
699 }
700 }
701 } else {
702 g_warning("Symbol 'mode' not found in module: %s", dn);
703 g_module_close(mod);
704 }
705 } else {
706 g_warning("Failed to open 'mode' plugin: '%s', error: %s", dn,
707 g_module_error());
708 }
709 g_free(fn);
710 }
711 g_dir_close(dir);
712 }
713}
714
718static void rofi_collect_modes(void) {
719#ifdef WINDOW_MODE
720#ifdef ENABLE_XCB
721 if (config.backend == DISPLAY_XCB) {
722 rofi_collectmodes_add(&window_mode);
723 rofi_collectmodes_add(&window_mode_cd);
724 }
725#endif
726#ifdef ENABLE_WAYLAND
728 rofi_collectmodes_add(&wayland_window_mode);
729 }
730#endif
731#endif // WINDOW_MODE
734#ifdef ENABLE_DRUN
735 rofi_collectmodes_add(&drun_mode);
736#endif
741
742 if (find_arg("-no-plugins") < 0) {
743 find_arg_str("-plugin-path", &(config.plugin_path));
744 g_debug("Parse plugin path: %s", config.plugin_path);
746 /* ROFI_PLUGIN_PATH */
747 const char *path = g_getenv("ROFI_PLUGIN_PATH");
748 if (path != NULL) {
749 gchar **paths = g_strsplit(path, ":", -1);
750 for (unsigned int i = 0; paths[i]; i++) {
751 rofi_collectmodes_dir(paths[i]);
752 }
753 g_strfreev(paths);
754 }
755 }
757}
758
762static void rofi_collectmodes_setup(void) {
763 for (unsigned int i = 0; i < num_available_modes; i++) {
765 }
766}
767static void rofi_collectmodes_destroy(void) {
768 for (unsigned int i = 0; i < num_available_modes; i++) {
770 GModule *mod = mode_plugin_get_module(available_modes[i]);
771 available_modes[i] = NULL;
772 g_module_close(mod);
773 }
774 if (available_modes[i]) {
776 }
777 }
778 g_free(available_modes);
779 available_modes = NULL;
781}
782
790static int add_mode(const char *token) {
791 unsigned int index = num_modes;
792 // Resize and add entry.
793 modes = (Mode **)g_realloc(modes, sizeof(Mode *) * (num_modes + 1));
794
795 Mode *mode = rofi_collect_modes_search(token);
796 if (mode) {
797 modes[num_modes] = mode;
798 num_modes++;
799 } else if (script_mode_is_valid(token)) {
800 // If not build in, use custom mode.
801 Mode *sw = script_mode_parse_setup(token);
802 if (sw != NULL) {
803 // Add to available list, so combi can find it.
805 mode_set_config(sw);
806 modes[num_modes] = sw;
807 num_modes++;
808 }
809 }
810 return (index == num_modes) ? -1 : (int)index;
811}
812static gboolean setup_modes(void) {
813 const char *const sep = ",#";
814 char *savept = NULL;
815 // Make a copy, as strtok will modify it.
816 char *mode_str = g_strdup(config.modes);
817 // Split token on ','. This modifies mode_str.
818 for (char *token = strtok_r(mode_str, sep, &savept); token != NULL;
819 token = strtok_r(NULL, sep, &savept)) {
820 if (add_mode(token) == -1) {
822 }
823 }
824 // Free string that was modified by strtok_r
825 g_free(mode_str);
826 return FALSE;
827}
828
833void rofi_quit_main_loop(void) { g_main_loop_quit(main_loop); }
834
835static gboolean main_loop_signal_handler_int(G_GNUC_UNUSED gpointer data) {
836 // Break out of loop.
837 g_main_loop_quit(main_loop);
838 return G_SOURCE_CONTINUE;
839}
840static void show_error_dialog(void) {
841 GString *emesg =
842 g_string_new("The following errors were detected when starting rofi:\n");
843 GList *iter = g_list_first(list_of_error_msgs);
844 int index = 0;
845 for (; iter != NULL && index < 2; iter = g_list_next(iter)) {
846 GString *msg = (GString *)(iter->data);
847 g_string_append(emesg, "\n\n");
848 g_string_append(emesg, msg->str);
849 index++;
850 }
851 if (g_list_length(iter) > 1) {
852 g_string_append_printf(emesg, "\nThere are <b>%u</b> more errors.",
853 g_list_length(iter) - 1);
854 }
856 g_string_free(emesg, TRUE);
857 rofi_set_return_code(EX_DATAERR);
858}
859
860static gboolean startup(G_GNUC_UNUSED gpointer data) {
861 TICK_N("Startup");
862 // flags to run immediately and exit
863 char *sname = NULL;
864 char *msg = NULL;
865 MenuFlags window_flags = MENU_NORMAL;
866
867 if (find_arg("-normal-window") >= 0) {
868 window_flags |= MENU_NORMAL_WINDOW;
869 }
870 if (find_arg("-transient-window") >= 0) {
871 window_flags |= MENU_TRANSIENT_WINDOW;
872 }
873 TICK_N("Grab keyboard");
874 __create_window(window_flags);
875 TICK_N("Create Window");
876 // Parse the keybindings.
877 TICK_N("Parse ABE");
878 // Sanity check
880 TICK_N("Config sanity check");
881
882 if (list_of_error_msgs != NULL) {
884 return G_SOURCE_REMOVE;
885 }
886 if (list_of_warning_msgs != NULL) {
887 for (GList *iter = g_list_first(list_of_warning_msgs); iter != NULL;
888 iter = g_list_next(iter)) {
889 g_warning(((GString *)iter->data)->str, NULL);
890 // fputs(((GString *)iter->data)->str, stderr);
891 // fputs("\n", stderr);
892 }
893 }
894 // Dmenu mode.
895 if (rofi_is_in_dmenu_mode == TRUE) {
896 // force off sidebar mode:
897 config.sidebar_mode = FALSE;
898 int retv = dmenu_mode_dialog();
899 if (retv) {
900 rofi_set_return_code(EXIT_SUCCESS);
901 // Directly exit.
902 g_main_loop_quit(main_loop);
903 }
904 } else if (find_arg_str("-e", &(msg))) {
905 int markup = FALSE;
906 if (find_arg("-markup") >= 0) {
907 markup = TRUE;
908 }
909 // When we pass -, we read from stdin.
910 if (g_strcmp0(msg, "-") == 0) {
911 size_t index = 0, i = 0;
912 // Include the 1 extra byte for the closing msg[index]
913 size_t length = 1025;
914 msg = g_malloc(length * sizeof(char));
915 while ((i = fread(&msg[index], 1, 1024, stdin)) > 0) {
916 index += i;
917 length += i;
918 if (length >= ROFI_MAX_DMENU_INPUT) {
919 break;
920 }
921 msg = g_realloc(msg, length * sizeof(char));
922 }
923
924 msg[index] = 0;
925
926 if (!rofi_view_error_dialog(msg, markup)) {
927 g_main_loop_quit(main_loop);
928 }
929 g_free(msg);
930 } else {
931 // Normal version
932 if (!rofi_view_error_dialog(msg, markup)) {
933 g_main_loop_quit(main_loop);
934 }
935 }
936 } else if (find_arg_str("-show", &sname) == TRUE) {
937 int index = mode_lookup(sname);
938 if (index < 0) {
939 // Add it to the list
940 index = add_mode(sname);
941 // Complain
942 if (index >= 0) {
944 }
945 // Run it anyway if found.
946 }
947 if (index >= 0) {
948 run_mode_index(index);
949 } else {
952 return G_SOURCE_REMOVE;
953 }
954 } else if (find_arg("-show") >= 0 && num_modes > 0) {
956 } else {
958
959 // g_main_loop_quit(main_loop);
960 }
961
962 return G_SOURCE_REMOVE;
963}
964
965static gboolean take_screenshot_quit(G_GNUC_UNUSED void *data) {
968 return G_SOURCE_REMOVE;
969}
970static gboolean record(G_GNUC_UNUSED void *data) {
972 return G_SOURCE_CONTINUE;
973}
974static void rofi_custom_log_function(const char *log_domain,
975 G_GNUC_UNUSED GLogLevelFlags log_level,
976 const gchar *message, gpointer user_data) {
977 int fp = GPOINTER_TO_INT(user_data);
978 dprintf(fp, "[%s]: %s\n", log_domain == NULL ? "default" : log_domain,
979 message);
980}
981
989int main(int argc, char *argv[]) {
990 cmd_set_arguments(argc, argv);
991 if (find_arg("-log") >= 0) {
992 char *logfile = NULL;
993 find_arg_str("-log", &logfile);
994 if (logfile != NULL) {
995 int fp = open(logfile, O_CLOEXEC | O_APPEND | O_CREAT | O_WRONLY,
996 S_IRUSR | S_IWUSR);
997 if (fp != -1) {
998 g_log_set_default_handler(rofi_custom_log_function,
999 GINT_TO_POINTER(fp));
1000
1001 } else {
1002 g_error("Failed to open logfile '%s': %s.", logfile, strerror(errno));
1003 }
1004
1005 } else {
1006 g_warning("Option '-log' should pass in a filename.");
1007 }
1008 }
1009 TIMINGS_START();
1010
1011 // Version
1012 if (find_arg("-v") >= 0 || find_arg("-version") >= 0) {
1013#ifdef GIT_VERSION
1014 g_print("Version: " GIT_VERSION "\n");
1015#else
1016 g_print("Version: " VERSION "\n");
1017#endif
1018 return EXIT_SUCCESS;
1019 }
1020
1021 if (find_arg("-rasi-validate") >= 0) {
1022 char *str = NULL;
1023 find_arg_str("-rasi-validate", &str);
1024 if (str != NULL) {
1025 int retv = rofi_theme_rasi_validate(str);
1026 cleanup();
1027 return retv;
1028 }
1029 fprintf(stderr, "Usage: %s -rasi-validate my-theme.rasi", argv[0]);
1030 return EXIT_FAILURE;
1031 }
1032
1033 {
1034 const char *ro_pid = g_getenv("ROFI_OUTSIDE");
1035 if (ro_pid != NULL) {
1036 pid_t ro_pidi = (pid_t)g_ascii_strtoll(ro_pid, NULL, 0);
1037 if (kill(ro_pidi, 0) == 0) {
1038 printf("Do not launch rofi from inside rofi.\r\n");
1039 return EXIT_FAILURE;
1040 }
1041 }
1042 }
1043
1044 // Detect if we are in dmenu mode.
1045 // This has two possible causes.
1046 // 1 the user specifies it on the command-line.
1047 if (find_arg("-dmenu") >= 0) {
1048 rofi_is_in_dmenu_mode = TRUE;
1049 }
1050 // 2 the binary that executed is called dmenu (e.g. symlink to rofi)
1051 else {
1052 // Get the base name of the executable called.
1053 char *base_name = g_path_get_basename(argv[0]);
1054 const char *const dmenu_str = "dmenu";
1055 rofi_is_in_dmenu_mode = (strcmp(base_name, dmenu_str) == 0);
1056 // Free the basename for dmenu detection.
1057 g_free(base_name);
1058 }
1059 TICK();
1060
1061 // Create pid file path.
1062 const char *path = g_get_user_runtime_dir();
1063 if (path) {
1064 if (g_mkdir_with_parents(path, 0700) < 0) {
1065 g_warning("Failed to create user runtime directory: %s with error: %s",
1066 path, g_strerror(errno));
1067 pidfile = g_build_filename(g_get_home_dir(), ".rofi.pid", NULL);
1068 } else {
1069 pidfile = g_build_filename(path, "rofi.pid", NULL);
1070 }
1071 }
1073 "Pidfile location");
1074
1076 if (find_arg("-no-default-config") < 0) {
1077 GBytes *theme_data = g_resource_lookup_data(
1078 resources_get_resource(), "/org/qtools/rofi/default_configuration.rasi",
1079 G_RESOURCE_LOOKUP_FLAGS_NONE, NULL);
1080 if (theme_data) {
1081 const char *theme = g_bytes_get_data(theme_data, NULL);
1082 if (rofi_theme_parse_string((const char *)theme)) {
1083 g_warning("Failed to parse default configuration. Giving up..");
1084 if (list_of_error_msgs) {
1085 for (GList *iter = g_list_first(list_of_error_msgs); iter != NULL;
1086 iter = g_list_next(iter)) {
1087 g_warning("Error: %s%s%s", color_bold, ((GString *)iter->data)->str,
1088 color_reset);
1089 }
1090 }
1091 rofi_configuration = NULL;
1092 cleanup();
1093 return EXIT_FAILURE;
1094 }
1095 g_bytes_unref(theme_data);
1096 }
1097 }
1098
1099 if (find_arg("-config") < 0) {
1100 const char *cpath = g_get_user_config_dir();
1101 if (cpath) {
1102 config_path = g_build_filename(cpath, "rofi", "config.rasi", NULL);
1103 }
1104 } else {
1105 char *c = NULL;
1106 find_arg_str("-config", &c);
1108 }
1109 TICK();
1110
1111 const struct _display_proxy *proxy = NULL;
1112#ifdef ENABLE_XCB
1113 proxy = xcb_proxy;
1115#endif
1116
1117#ifdef ENABLE_WAYLAND
1118#ifdef ENABLE_XCB
1119 const gchar *wl_display = g_getenv("WAYLAND_DISPLAY");
1120 if (find_arg("-x11") < 0 && find_arg("-xcb") < 0 && wl_display != NULL &&
1121 strlen(wl_display) > 0) {
1124 }
1125#else
1128#endif
1129#endif
1130
1132
1133 if (setlocale(LC_ALL, "") == NULL) {
1134 g_warning("Failed to set locale.");
1135 cleanup();
1136 return EXIT_FAILURE;
1137 }
1138
1139 TICK_N("Setup Locale");
1141 TICK_N("Collect MODES");
1143 TICK_N("Setup MODES");
1144
1145 main_loop = g_main_loop_new(NULL, FALSE);
1146
1147 TICK_N("Setup mainloop");
1148
1149 bindings = nk_bindings_new(0lu);
1150 TICK_N("NK Bindings");
1151
1152 // Setup keybinding
1153 setup_abe();
1154 TICK_N("Setup abe");
1155
1156 if (find_arg("-no-config") < 0) {
1157 // Load distro default settings
1158 gboolean found_system = FALSE;
1159 const char *const *dirs = g_get_system_config_dirs();
1160 if (dirs) {
1161 for (unsigned int i = 0; !found_system && dirs[i]; i++) {
1163 gchar *etc = g_build_filename(dirs[i], "rofi.rasi", NULL);
1164 g_debug("Look for default config file: %s", etc);
1165 if (g_file_test(etc, G_FILE_TEST_IS_REGULAR)) {
1166 g_debug("Parsing: %s", etc);
1168 found_system = TRUE;
1169 }
1170 g_free(etc);
1171 }
1172 }
1173 if (!found_system) {
1175 gchar *etc = g_build_filename(SYSCONFDIR, "rofi.rasi", NULL);
1176 g_debug("Look for default config file: %s", etc);
1177 if (g_file_test(etc, G_FILE_TEST_IS_REGULAR)) {
1178 g_debug("Look for default config file: %s", etc);
1180 }
1181 g_free(etc);
1182 }
1183
1184 if (config_path) {
1185 // Try to resolve the path.
1186 extern const char *rasi_theme_file_extensions[];
1187 char *file2 =
1188 helper_get_theme_path(config_path, rasi_theme_file_extensions, NULL);
1189 GFile *gf = g_file_new_for_path(file2);
1190 char *filename = g_file_get_path(gf);
1191 g_object_unref(gf);
1192 g_free(file2);
1193 if (filename && g_file_test(filename, G_FILE_TEST_EXISTS)) {
1194 if (rofi_theme_parse_file(filename)) {
1196 rofi_theme = NULL;
1197 }
1198 }
1199 g_free(filename);
1200 }
1201 }
1202 find_arg_str("-theme", &(config.theme));
1203 if (config.theme) {
1204 TICK_N("Parse theme");
1207 g_warning("Failed to parse theme: \"%s\"", config.theme);
1208 // TODO: instantiate fallback theme.?
1210 rofi_theme = NULL;
1211 }
1212 TICK_N("Parsed theme");
1213 }
1214 // Parse command line for settings, independent of other -no-config.
1215 if (list_of_error_msgs == NULL) {
1216 // Only call this when there are no errors.
1217 // This might clear existing errors.
1219 }
1220
1221 if (rofi_theme == NULL || rofi_theme->num_widgets == 0) {
1222 g_debug("Failed to load theme. Try to load default: ");
1223 rofi_theme_parse_string("@theme \"default\"");
1224 }
1225 TICK_N("Load cmd config ");
1226
1227 // Get the path to the cache dir.
1228 cache_dir = g_get_user_cache_dir();
1229
1230 if (config.cache_dir != NULL) {
1232 }
1233
1234 if (g_mkdir_with_parents(cache_dir, 0700) < 0) {
1235 g_warning("Failed to create cache directory: %s", g_strerror(errno));
1236 return EXIT_FAILURE;
1237 }
1238
1240 char *windowid = NULL;
1241 if (!rofi_is_in_dmenu_mode) {
1242 // setup_modes
1243 if (setup_modes()) {
1244 cleanup();
1245 return EXIT_FAILURE;
1246 }
1247 TICK_N("Setup Modes");
1248 } else {
1249 // Hack for dmenu compatibility.
1250 if (find_arg_str("-w", &windowid) == TRUE) {
1251 config.monitor = g_strdup_printf("wid:%s", windowid);
1252 windowid = config.monitor;
1253 }
1254 }
1255
1259 const char **theme_str = find_arg_strv("-theme-str");
1260 if (theme_str) {
1261 for (int index = 0; theme_str[index]; index++) {
1262 if (rofi_theme_parse_string(theme_str[index])) {
1263 g_warning("Failed to parse -theme-str option: \"%s\"",
1264 theme_str[index]);
1266 rofi_theme = NULL;
1267 }
1268 }
1269 g_free(theme_str);
1270 }
1271
1273 if (find_arg("-dump-theme") >= 0) {
1275 cleanup();
1276 return EXIT_SUCCESS;
1277 }
1278 if (find_arg("-dump-processed-theme") >= 0) {
1281 cleanup();
1282 return EXIT_SUCCESS;
1283 }
1284 if (find_arg("-dump-config") >= 0) {
1286 cleanup();
1287 return EXIT_SUCCESS;
1288 }
1289
1290 if (find_arg("-list-keybindings") >= 0) {
1291 int is_term = isatty(fileno(stdout));
1292 abe_list_all_bindings(is_term);
1293 return EXIT_SUCCESS;
1294 }
1295
1296 unsigned int interval = 1;
1297 if (find_arg_uint("-record-screenshots", &interval)) {
1298 g_timeout_add((guint)(1000 / (double)interval), record, NULL);
1299 }
1300 if (find_arg_uint("-take-screenshot-quit", &interval)) {
1301 g_timeout_add(interval, take_screenshot_quit, NULL);
1302 }
1303 if (find_arg("-benchmark-ui") >= 0) {
1304 config.benchmark_ui = TRUE;
1305 }
1306
1308 TICK_N("Setup Display");
1309
1310 // catch help request
1311 if (find_arg("-h") >= 0 || find_arg("-help") >= 0 ||
1312 find_arg("--help") >= 0) {
1313 help(argc, argv, FALSE);
1314 cleanup();
1315 return EXIT_SUCCESS;
1316 }
1317 if (find_arg("-info") >= 0 || find_arg("--info") >= 0) {
1318 help(argc, argv, TRUE);
1319 cleanup();
1320 return EXIT_SUCCESS;
1321 }
1322
1323 if (!display_setup_success) {
1324#ifdef ENABLE_WAYLAND
1325#ifdef ENABLE_XCB
1326 g_warning("No valid backend was found. Make sure to launch %s from a valid "
1327 "X11 or Wayland session.",
1328 argv[0]);
1329#else
1330 g_warning("No valid backend was found. Make sure to launch %s from a valid "
1331 "Wayland session.",
1332 argv[0]);
1333
1334#endif
1335#else
1336 g_warning("No valid backend was found. Make sure to launch %s from a valid "
1337 "X11 session.",
1338 argv[0]);
1339#endif
1340 cleanup();
1341 return EXIT_FAILURE;
1342 }
1343
1345 TICK_N("Workers initialize");
1347 TICK_N("Icon fetcher initialize");
1348
1349 gboolean kill_running = FALSE;
1350 if (find_arg("-replace") >= 0) {
1351 kill_running = TRUE;
1352 }
1353 // Create pid file
1354 int pfd = create_pid_file(pidfile, kill_running);
1355 TICK_N("Pid file created");
1356 if (pfd < 0) {
1357 cleanup();
1358 return EXIT_FAILURE;
1359 }
1360 textbox_setup();
1361 TICK_N("Text box setup");
1362
1363 if (!display_late_setup()) {
1364 g_warning("Failed to properly finish display setup");
1365 cleanup();
1366 return EXIT_FAILURE;
1367 }
1368 TICK_N("Setup late Display");
1369
1373 TICK_N("Theme setup");
1374
1375 // Setup signal handling sources.
1376 // SIGINT
1377 g_unix_signal_add(SIGINT, main_loop_signal_handler_int, NULL);
1378
1379 g_idle_add(startup, NULL);
1380
1381 // Start mainloop.
1382 g_main_loop_run(main_loop);
1383 teardown(pfd);
1384 cleanup();
1385
1386 /* dirty hack */
1387 g_free(windowid);
1388 return return_code;
1389}
1390
1392extern GList *list_of_error_msgs;
1393int rofi_theme_rasi_validate(const char *filename) {
1394 rofi_theme_parse_file(filename);
1396 if (list_of_error_msgs == NULL && list_of_warning_msgs == NULL) {
1397 return EXIT_SUCCESS;
1398 }
1399
1400 for (GList *iter = g_list_first(list_of_error_msgs); iter != NULL;
1401 iter = g_list_next(iter)) {
1402 fputs(((GString *)iter->data)->str, stderr);
1403 fputs("\n", stderr);
1404 }
1405 for (GList *iter = g_list_first(list_of_warning_msgs); iter != NULL;
1406 iter = g_list_next(iter)) {
1407 fputs(((GString *)iter->data)->str, stderr);
1408 fputs("\n", stderr);
1409 }
1410
1411 return EXIT_FAILURE;
1412}
1413
1416 if (index != NULL) {
1417 return index;
1418 }
1419 const char *name =
1420 config.completer_mode == NULL ? "(null)" : config.completer_mode;
1421 g_warning("Mode: %s not found or is not valid for use as completer.", name);
1422 return NULL;
1423}
gboolean display_late_setup(void)
Definition display.c:45
void display_early_cleanup(void)
Definition display.c:52
void display_init(const display_proxy *disp_in)
Definition display.c:13
void display_cleanup(void)
Definition display.c:58
guint display_scale(void)
Definition display.c:78
static const display_proxy * proxy
Definition display.c:11
gboolean display_setup(GMainLoop *main_loop, NkBindings *bindings)
Definition display.c:38
void display_dump_monitor_layout(void)
Definition display.c:64
Mode combi_mode
Definition combi.c:347
void config_parse_cmd_options(void)
Definition xrmoptions.c:807
void print_options(void)
void config_parser_add_option(XrmOptionType type, const char *key, void **value, const char *comment)
Definition xrmoptions.c:699
void print_help_msg(const char *option, const char *type, const char *text, const char *def, int isatty)
void config_parse_dump_config_rasi_format(FILE *out, gboolean changes)
Dump configuration in rasi format.
@ xrm_String
Definition xrmoptions.h:73
void config_xresource_free(void)
int dmenu_mode_dialog(void)
Definition dmenu.c:976
void print_dmenu_options(void)
Definition dmenu.c:1070
Mode recursive_browser_mode
Mode file_browser_mode
void cmd_set_arguments(int argc, char **argv)
Definition helper.c:97
const char ** find_arg_strv(const char *const key)
Definition helper.c:344
char * rofi_expand_path(const char *input)
Definition helper.c:784
void remove_pid_file(int fd)
Definition helper.c:644
int find_arg_str(const char *const key, char **val)
Definition helper.c:334
int find_arg_uint(const char *const key, unsigned int *val)
Definition helper.c:373
int find_arg(const char *const key)
Definition helper.c:325
int create_pid_file(const char *pidfile, gboolean kill_running)
Definition helper.c:585
int config_sanity_check(void)
Definition helper.c:671
Mode help_keys_mode
Definition help-keys.c:113
void rofi_icon_fetcher_destroy(void)
void rofi_icon_fetcher_init(void)
gboolean parse_keys_abe(NkBindings *bindings)
Definition keyb.c:450
void setup_abe(void)
Definition keyb.c:416
void abe_list_all_bindings(gboolean is_term)
Definition keyb.c:397
void mode_destroy(Mode *mode)
Definition mode.c:64
const char * mode_get_name(const Mode *mode)
Definition mode.c:157
int mode_init(Mode *mode)
Definition mode.c:44
struct rofi_mode Mode
Definition mode.h:49
void mode_free(Mode **mode)
Definition mode.c:167
int mode_get_abi_version(Mode *const mode)
Definition mode.c:162
ModeMode mode_result(Mode *mode, int menu_retv, char **input, unsigned int selected_line)
Definition mode.c:131
void mode_plugin_set_module(Mode *mode, GModule *mod)
Definition mode.c:253
MenuReturn
Definition mode.h:70
GModule * mode_plugin_get_module(Mode *mode)
Definition mode.c:256
ModeMode
Definition mode.h:54
void mode_set_config(Mode *mode)
Definition mode.c:205
@ MODE_EXIT
Definition mode.h:56
@ NEXT_DIALOG
Definition mode.h:58
@ RELOAD_DIALOG
Definition mode.h:60
@ PREVIOUS_DIALOG
Definition mode.h:62
@ RESET_DIALOG
Definition mode.h:64
const Mode * rofi_get_mode(unsigned int index)
Definition rofi.c:159
void rofi_quit_main_loop(void)
Definition rofi.c:833
#define color_reset
Definition rofi.h:123
#define color_bold
Definition rofi.h:125
unsigned int rofi_get_num_enabled_modes(void)
Definition rofi.c:157
void rofi_clear_error_messages(void)
Definition rofi.c:100
void rofi_clear_warning_messages(void)
Definition rofi.c:113
#define color_red
Definition rofi.h:131
#define ERROR_MSG_MARKUP
Definition rofi.h:144
void rofi_set_return_code(int code)
Definition rofi.c:155
const Mode * rofi_get_completer(void)
Definition rofi.c:1414
Mode * rofi_collect_modes_search(const char *name)
Definition rofi.c:648
int mode_lookup(const char *name)
Definition rofi.c:161
const char * cache_dir
Definition rofi.c:86
void rofi_add_error_message(GString *str)
Definition rofi.c:97
#define color_green
Definition rofi.h:129
void rofi_add_warning_message(GString *str)
Definition rofi.c:110
Mode run_mode
Definition run.c:603
void script_mode_gather_user_scripts(void)
Definition script.c:635
gboolean script_mode_is_valid(const char *token)
Definition script.c:726
void script_user_list(gboolean is_term)
Definition script.c:733
void script_mode_cleanup(void)
Definition script.c:628
Mode * script_mode_parse_setup(const char *str)
Definition script.c:674
Mode ssh_mode
Definition ssh.c:710
#define TICK()
Definition timings.h:64
#define TIMINGS_START()
Definition timings.h:60
#define TIMINGS_STOP()
Definition timings.h:73
#define TICK_N(a)
Definition timings.h:69
void textbox_cleanup(void)
Definition textbox.c:1059
void textbox_setup(void)
Definition textbox.c:1027
void textbox_cursor_end(textbox *tb)
Definition textbox.c:750
void textbox_text(textbox *tb, const char *text)
Definition textbox.c:412
void rofi_view_cleanup(void)
Definition view.c:2217
void __create_window(MenuFlags menu_flags)
Definition view.c:2223
void rofi_view_clear_input(RofiViewState *state)
Definition view.c:2136
void rofi_view_switch_mode(RofiViewState *state, Mode *mode)
Definition view.c:2148
void rofi_view_remove_active(RofiViewState *state)
Definition view.c:340
int rofi_view_error_dialog(const char *msg, int markup)
Definition view.c:1980
void rofi_view_set_active(RofiViewState *state)
Definition view.c:347
RofiViewState * rofi_view_get_active(void)
Definition view.c:321
MenuFlags
Definition view.h:55
MenuReturn rofi_view_get_return_value(const RofiViewState *state)
Definition view.c:410
const char * rofi_view_get_user_input(const RofiViewState *state)
Definition view.c:439
void rofi_view_set_selected_line(RofiViewState *state, unsigned int selected_line)
Definition view.c:369
void rofi_view_free(RofiViewState *state)
Definition view.c:392
RofiViewState * rofi_view_create(Mode *sw, const char *input, MenuFlags menu_flags, void(*finalize)(RofiViewState *))
Definition view.c:1860
unsigned int rofi_view_get_selected_line(const RofiViewState *state)
Definition view.c:414
@ MENU_TRANSIENT_WINDOW
Definition view.h:65
@ MENU_NORMAL_WINDOW
Definition view.h:61
@ MENU_NORMAL
Definition view.h:57
void rofi_capture_screenshot(void)
Definition view.c:154
void rofi_view_workers_initialize(void)
Definition view.c:2057
void rofi_view_workers_finalize(void)
Definition view.c:2085
char * helper_get_theme_path(const char *file, const char **ext, const char *parent_file)
Definition helper.c:1590
#define ABI_VERSION
Definition mode.h:36
static void rofi_collect_modes(void)
Definition rofi.c:718
int main(int argc, char *argv[])
Definition rofi.c:989
GList * list_of_warning_msgs
Definition rofi.c:94
GList * list_of_error_msgs
Definition rofi.c:92
static void help(G_GNUC_UNUSED int argc, char **argv, const gboolean compact)
Definition rofi.c:384
static gboolean record(G_GNUC_UNUSED void *data)
Definition rofi.c:970
G_MODULE_EXPORT char * config_path
Definition rofi.c:125
NkBindings * bindings
Definition rofi.c:140
static void print_main_application_options(int is_term)
Definition rofi.c:314
static void print_list_of_modes(int is_term)
Definition rofi.c:296
static void run_mode_index(ModeMode mode)
Definition rofi.c:201
static void rofi_custom_log_function(const char *log_domain, G_GNUC_UNUSED GLogLevelFlags log_level, const gchar *message, gpointer user_data)
Definition rofi.c:974
gboolean display_setup_success
Definition rofi.c:143
static void help_print_mode_not_found(const char *mode)
Definition rofi.c:547
static void cleanup(void)
Definition rofi.c:600
Mode ** modes
Definition rofi.c:128
static gboolean startup(G_GNUC_UNUSED gpointer data)
Definition rofi.c:860
static void print_backend_info(void)
Definition rofi.c:360
static gboolean setup_modes(void)
Definition rofi.c:812
Mode ** available_modes
Definition rofi.c:131
int rofi_theme_rasi_validate(const char *filename)
Definition rofi.c:1393
unsigned int num_modes
Definition rofi.c:135
static void rofi_collectmodes_setup(void)
Definition rofi.c:762
GMainLoop * main_loop
Definition rofi.c:146
static void teardown(int pfd)
Definition rofi.c:188
static gboolean rofi_collectmodes_add(Mode *mode)
Definition rofi.c:661
static gboolean take_screenshot_quit(G_GNUC_UNUSED void *data)
Definition rofi.c:965
static void rofi_collectmodes_destroy(void)
Definition rofi.c:767
char * pidfile
Definition rofi.c:84
int return_code
Definition rofi.c:151
void process_result(RofiViewState *state)
Definition rofi.c:235
#define ROFI_MAX_DMENU_INPUT
Definition rofi.c:81
static const Mode * mode_available_lookup(const char *name)
Definition rofi.c:176
static int add_mode(const char *token)
Definition rofi.c:790
static gboolean main_loop_signal_handler_int(G_GNUC_UNUSED gpointer data)
Definition rofi.c:835
static void show_error_dialog(void)
Definition rofi.c:840
char * cache_dir_alloc
Definition rofi.c:89
int rofi_is_in_dmenu_mode
Definition rofi.c:149
static void help_print_no_arguments(void)
Definition rofi.c:564
static void help_print_disabled_mode(const char *mode)
Definition rofi.c:534
unsigned int num_available_modes
Definition rofi.c:133
static void rofi_collectmodes_dir(const char *base_dir)
Definition rofi.c:674
unsigned int curr_mode
Definition rofi.c:137
Settings config
@ DISPLAY_WAYLAND
Definition settings.h:54
@ DISPLAY_XCB
Definition settings.h:53
textbox * text
DisplayBackend backend
Definition settings.h:105
char * cache_dir
Definition settings.h:198
char * modes
Definition settings.h:63
char * theme
Definition settings.h:185
char * plugin_path
Definition settings.h:187
char * filter
Definition settings.h:169
unsigned int sidebar_mode
Definition settings.h:150
gboolean benchmark_ui
Definition settings.h:208
char * completer_mode
Definition settings.h:223
char * monitor
Definition settings.h:167
unsigned int num_widgets
Definition rofi-types.h:336
void rofi_theme_free_parsed_files(void)
Definition theme.c:56
void rofi_theme_print_parsed_files(gboolean is_term)
Definition theme.c:66
void rofi_theme_print(ThemeWidget *wid)
Definition theme.c:595
void rofi_theme_parse_process_links(void)
Definition theme.c:1597
void rofi_theme_parse_process_conditionals(void)
Definition theme.c:1601
void rofi_theme_free(ThemeWidget *wid)
Definition theme.c:242
void rofi_theme_reset(void)
Definition theme.c:236
void rofi_theme_set_disp_scale_func(disp_scale_func func)
Definition theme.c:1660
gboolean rofi_theme_parse_string(const char *string)
ThemeWidget * rofi_theme
gboolean rofi_theme_parse_file(const char *file)
display_proxy *const wayland_proxy
Definition display.c:2230
display_proxy *const xcb_proxy
Definition display.c:2060
char * x11_helper_get_window_manager(void)
Definition display.c:1601
ThemeWidget * rofi_configuration
Definition xrmoptions.c:42