rofi 2.0.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#define G_LOG_DOMAIN "Rofi"
31
32#include "config.h"
33#include <errno.h>
34#include <gmodule.h>
35#include <locale.h>
36#include <stdint.h>
37#include <stdlib.h>
38#include <string.h>
39#include <sys/stat.h>
40#include <sys/types.h>
41#include <sysexits.h>
42#include <time.h>
43#include <unistd.h>
44
45#include <glib-unix.h>
46
47#ifdef USE_NK_GIT_VERSION
48#include "nkutils-git-version.h"
49#ifdef NK_GIT_VERSION
50#define GIT_VERSION NK_GIT_VERSION
51#endif
52#endif
53
54#include "resources.h"
55
56#include "display.h"
57#include "rofi.h"
58#include "settings.h"
59
60#include "helper.h"
61#include "mode.h"
62#include "modes/modes.h"
63#include "widgets/textbox.h"
64#include "xrmoptions.h"
65
66#include "view-internal.h"
67#include "view.h"
68
69#include "rofi-icon-fetcher.h"
70#include "theme.h"
71
72#include "timings.h"
73
74#ifdef ENABLE_WAYLAND
75#include <wayland-version.h>
76
77#endif
78
80char *pidfile = NULL;
82const char *cache_dir = NULL;
85char *cache_dir_alloc = NULL;
86
88GList *list_of_error_msgs = NULL;
91
92static void rofi_collectmodes_destroy(void);
93void rofi_add_error_message(GString *str) {
94 list_of_error_msgs = g_list_append(list_of_error_msgs, str);
95}
98 for (GList *iter = g_list_first(list_of_error_msgs); iter != NULL;
99 iter = g_list_next(iter)) {
100 g_string_free((GString *)iter->data, TRUE);
101 }
102 g_list_free(list_of_error_msgs);
103 list_of_error_msgs = NULL;
104 }
105}
106void rofi_add_warning_message(GString *str) {
107 list_of_warning_msgs = g_list_append(list_of_warning_msgs, str);
108}
111 for (GList *iter = g_list_first(list_of_warning_msgs); iter != NULL;
112 iter = g_list_next(iter)) {
113 g_string_free((GString *)iter->data, TRUE);
114 }
115 g_list_free(list_of_warning_msgs);
117 }
118}
119
121G_MODULE_EXPORT char *config_path = NULL;
124Mode **modes = NULL;
125
129unsigned int num_available_modes = 0;
131unsigned int num_modes = 0;
133unsigned int curr_mode = 0;
134
136NkBindings *bindings = NULL;
137
139gboolean display_setup_success = FALSE;
140
142GMainLoop *main_loop = NULL;
143
147int return_code = EXIT_SUCCESS;
148
149void process_result(RofiViewState *state);
150
151void rofi_set_return_code(int code) { return_code = code; }
152
153unsigned int rofi_get_num_enabled_modes(void) { return num_modes; }
154
155const Mode *rofi_get_mode(unsigned int index) { return modes[index]; }
156
164static int mode_lookup(const char *name) {
165 for (unsigned int i = 0; i < num_modes; i++) {
166 if (strcmp(mode_get_name(modes[i]), name) == 0) {
167 return i;
168 }
169 }
170 return -1;
171}
172
179static const Mode *mode_available_lookup(const char *name) {
180 for (unsigned int i = 0; i < num_available_modes; i++) {
181 if (strcmp(mode_get_name(available_modes[i]), name) == 0) {
182 return available_modes[i];
183 }
184 }
185 return NULL;
186}
187
191static void teardown(int pfd) {
192 g_debug("Teardown");
193 // Cleanup font setup.
195
197
198 // Cleanup view
200
201 // Cleanup pid file.
202 remove_pid_file(pfd);
203}
204static void run_mode_index(ModeMode mode) {
205 // Otherwise check if requested mode is enabled.
206 for (unsigned int i = 0; i < num_modes; i++) {
207 if (!mode_init(modes[i])) {
208 GString *str = g_string_new("Failed to initialize the mode: ");
209 g_string_append(str, mode_get_name(modes[i]));
210 g_string_append(str, "\n");
211
213 g_string_free(str, FALSE);
214 break;
215 }
216 }
217 // Error dialog must have been created.
218 if (rofi_view_get_active() != NULL) {
219 return;
220 }
221 curr_mode = mode;
222 RofiViewState *state =
223 rofi_view_create(modes[mode], config.filter, 0, process_result);
224
225 // User can pre-select a row.
226 if (find_arg("-selected-row") >= 0) {
227 unsigned int sr = 0;
228 find_arg_uint("-selected-row", &(sr));
230 }
231 if (state) {
233 }
234 if (rofi_view_get_active() == NULL) {
235 g_main_loop_quit(main_loop);
236 }
237}
239 Mode *sw = state->sw;
240 // rofi_view_set_active ( NULL );
241 if (sw != NULL) {
242 unsigned int selected_line = rofi_view_get_selected_line(state);
243 ;
245 char *input = g_strdup(rofi_view_get_user_input(state));
246 ModeMode retv = mode_result(sw, mretv, &input, selected_line);
247 {
248 if (state->text) {
249 if (input == NULL) {
250 textbox_text(state->text, "");
251 } else if (strcmp(rofi_view_get_user_input(state), input) != 0) {
252 textbox_text(state->text, input);
253 textbox_cursor_end(state->text);
254 }
255 }
256 }
257 g_free(input);
258
259 ModeMode mode = curr_mode;
260 // Find next enabled
261 if (retv == NEXT_DIALOG) {
262 mode = (mode + 1) % num_modes;
263 } else if (retv == PREVIOUS_DIALOG) {
264 if (mode == 0) {
265 mode = num_modes - 1;
266 } else {
267 mode = (mode - 1) % num_modes;
268 }
269 } else if (retv == RELOAD_DIALOG) {
270 // do nothing.
271 } else if (retv == RESET_DIALOG) {
273 } else if (retv < MODE_EXIT) {
274 mode = (retv) % num_modes;
275 } else {
276 mode = retv;
277 }
278 if (mode != MODE_EXIT) {
282 rofi_view_switch_mode(state, modes[mode]);
283 curr_mode = mode;
284 return;
285 }
286 // On exit, free current view, and pop to one above.
288 rofi_view_free(state);
289 return;
290 }
291 // rofi_view_set_active ( NULL );
293 rofi_view_free(state);
294}
295
299static void print_list_of_modes(int is_term) {
300 for (unsigned int i = 0; i < num_available_modes; i++) {
301 gboolean active = FALSE;
302 for (unsigned int j = 0; j < num_modes; j++) {
303 if (modes[j] == available_modes[i]) {
304 active = TRUE;
305 break;
306 }
307 }
308 printf(" • %s%s%s%s\n", active ? "+" : "",
309 is_term ? (active ? color_green : color_red) : "",
310 mode_get_name(available_modes[i]), is_term ? color_reset : "");
311 }
312}
313static void print_main_application_options(int is_term) {
314 print_help_msg("-config", "[file]", "Load an alternative configuration.",
315 NULL, is_term);
316 print_help_msg("-no-config", "",
317 "Do not load configuration, use default values.", NULL,
318 is_term);
319 print_help_msg("-v,-version", "", "Print the version number and exit.", NULL,
320 is_term);
321 print_help_msg("-dmenu", "", "Start in dmenu mode.", NULL, is_term);
322 print_help_msg("-display", "[string]", "X server to contact.", "${DISPLAY}",
323 is_term);
324 print_help_msg("-h,-help", "", "This help message.", NULL, is_term);
325 print_help_msg("-e", "[string]",
326 "Show a dialog displaying the passed message and exit.", NULL,
327 is_term);
328 print_help_msg("-markup", "", "Enable pango markup where possible.", NULL,
329 is_term);
330 print_help_msg("-normal-window", "",
331 "Behave as a normal window. (experimental)", NULL, is_term);
332 print_help_msg("-transient-window", "",
333 "Behave as a modal dialog that is transient to the currently "
334 "focused window. (experimental)",
335 NULL, is_term);
336 print_help_msg("-show", "[mode]",
337 "Show the mode 'mode' and exit. The mode has to be enabled.",
338 NULL, is_term);
339 print_help_msg("-no-lazy-grab", "",
340 "Disable lazy grab that, when fail to grab keyboard, does not "
341 "block but retry later.",
342 NULL, is_term);
343 print_help_msg("-no-plugins", "", "Disable loading of external plugins.",
344 NULL, is_term);
345 print_help_msg("-plugin-path", "",
346 "Directory used to search for rofi plugins. *DEPRECATED*",
347 NULL, is_term);
348 print_help_msg("-dump-config", "",
349 "Dump the current configuration in rasi format and exit.",
350 NULL, is_term);
351 print_help_msg("-dump-theme", "",
352 "Dump the current theme in rasi format and exit.", NULL,
353 is_term);
354 print_help_msg("-list-keybindings", "",
355 "Print a list of current keybindings and exit.", NULL,
356 is_term);
357}
358
359static void print_backend_info() {
360 int is_term = isatty(fileno(stdout));
361 printf("Display backends:\n");
362#ifdef ENABLE_XCB
363 printf("\t• xcb");
364 if (config.backend == DISPLAY_XCB) {
365 printf(": %sselected%s\n", is_term ? color_bold : "",
366 is_term ? color_reset : "");
367 } else {
368 printf("\n");
369 }
370#endif
371#ifdef ENABLE_WAYLAND
372 printf("\t• wayland");
373 if (config.backend == DISPLAY_WAYLAND) {
374 printf(": %sselected%s\n", is_term ? color_bold : "",
375 is_term ? color_reset : "");
376 } else {
377 printf("\n");
378 }
379#endif
380 printf("\n");
381}
382
383static void help(G_GNUC_UNUSED int argc, char **argv, const gboolean compact) {
384 int is_term = isatty(fileno(stdout));
385 if (!compact) {
386 printf("%s usage:\n", argv[0]);
387 printf("\t%s [-options ...]\n\n", argv[0]);
388 printf("Command line only options:\n");
390 printf("DMENU command line options:\n");
392 printf("Global options:\n");
394 printf("\n");
395 }
398#ifdef ENABLE_XCB
399 if (config.backend == DISPLAY_XCB) {
400 printf("Detected Window manager:\n");
402 if (wm) {
403 printf("\t• %s\n", wm);
404 g_free(wm);
405 } else {
406 printf("\t• No window manager detected.\n");
407 }
408 printf("\n");
409 }
410#endif
412 printf("\n");
413 }
414 printf("Detected modes:\n");
415 print_list_of_modes(is_term);
416 printf("\n");
417 printf("Detected user scripts:\n");
418 script_user_list(is_term);
419 printf("\n");
420 printf("Compile time options:\n");
421 printf("\t• Pango version %s\n", pango_version_string());
422#ifdef WINDOW_MODE
423 printf("\t• window %senabled%s\n", is_term ? color_green : "",
424 is_term ? color_reset : "");
425#else
426 printf("\t• window %sdisabled%s\n", is_term ? color_red : "",
427 is_term ? color_reset : "");
428#endif
429#ifdef ENABLE_DRUN
430 printf("\t• drun %senabled%s\n", is_term ? color_green : "",
431 is_term ? color_reset : "");
432#else
433 printf("\t• drun %sdisabled%s\n", is_term ? color_red : "",
434 is_term ? color_reset : "");
435#endif
436#ifdef ENABLE_ASAN
437 printf("\t• asan %senabled%s\n", is_term ? color_green : "",
438 is_term ? color_reset : "");
439#else
440 printf("\t• asan %sdisabled%s\n", is_term ? color_red : "",
441 is_term ? color_reset : "");
442#endif
443#ifdef XCB_IMDKIT
444 printf("\t• imdkit %senabled%s\n", is_term ? color_green : "",
445 is_term ? color_reset : "");
446#else
447 printf("\t• imdkit %sdisabled%s\n", is_term ? color_red : "",
448 is_term ? color_reset : "");
449#endif
450#ifdef ENABLE_XCB
451 printf("\t• xcb %senabled%s\n", is_term ? color_green : "",
452 is_term ? color_reset : "");
453#else
454 printf("\t• xcb %sdisabled%s\n", is_term ? color_red : "",
455 is_term ? color_reset : "");
456#endif
457#ifdef ENABLE_WAYLAND
458 printf("\t• wayland %senabled%s (%s)\n", is_term ? color_green : "",
459 is_term ? color_reset : "", WAYLAND_VERSION);
460#else
461 printf("\t• wayland %sdisabled%s\n", is_term ? color_red : "",
462 is_term ? color_reset : "");
463#endif
464 printf("\n");
465 printf("For more information see: %sman rofi%s\n", is_term ? color_bold : "",
466 is_term ? color_reset : "");
467#ifdef GIT_VERSION
468 printf(" Version: %s" GIT_VERSION "%s\n",
469 is_term ? color_bold : "", is_term ? color_reset : "");
470#else
471 printf(" Version: %s" VERSION "%s\n",
472 is_term ? color_bold : "", is_term ? color_reset : "");
473#endif
474 printf(" Bugreports: %s" PACKAGE_BUGREPORT "%s\n",
475 is_term ? color_bold : "", is_term ? color_reset : "");
476 printf(" Support: %s" PACKAGE_URL "%s\n",
477 is_term ? color_bold : "", is_term ? color_reset : "");
478 printf(" %s#rofi @ libera.chat%s\n",
479 is_term ? color_bold : "", is_term ? color_reset : "");
480 if (find_arg("-no-config") < 0) {
481 if (config_path) {
482 printf(" Configuration file: %s%s%s\n", is_term ? color_bold : "",
483 config_path, is_term ? color_reset : "");
484 }
485 } else {
486 printf(" Configuration file: %sDisabled%s\n",
487 is_term ? color_bold : "", is_term ? color_reset : "");
488 }
490}
491
492static void help_print_disabled_mode(const char *mode) {
493 int is_term = isatty(fileno(stdout));
494 // Only output to terminal
495 if (is_term) {
496 fprintf(stderr, "Mode %s%s%s is not enabled. I have enabled it for now.\n",
497 color_red, mode, color_reset);
498 fprintf(stderr,
499 "Please consider adding %s%s%s to the list of enabled modes: "
500 "%smodes: [%s%s%s,%s]%s.\n",
503 }
504}
505static void help_print_mode_not_found(const char *mode) {
506 GString *str = g_string_new("");
507 g_string_printf(
508 str, "Mode %s is not found.\nThe following modes are known:\n", mode);
509 for (unsigned int i = 0; i < num_available_modes; i++) {
510 gboolean active = FALSE;
511 for (unsigned int j = 0; j < num_modes; j++) {
512 if (modes[j] == available_modes[i]) {
513 active = TRUE;
514 break;
515 }
516 }
517 g_string_append_printf(str, " * %s%s\n", active ? "+" : "",
519 }
521}
522static void help_print_no_arguments(void) {
523
524 GString *emesg = g_string_new(
525 "<span size=\"x-large\">Rofi is unsure what to show.</span>\n\n");
526 g_string_append(emesg, "Please specify the mode you want to show.\n\n");
527 g_string_append(
528 emesg, " <b>rofi</b> -show <span color=\"green\">{mode}</span>\n\n");
529 g_string_append(emesg, "The following modes are enabled:\n");
530 for (unsigned int j = 0; j < num_modes; j++) {
531 g_string_append_printf(emesg, " • <span color=\"green\">%s</span>\n",
532 mode_get_name(modes[j]));
533 }
534 g_string_append(emesg, "\nThe following modes can be enabled:\n");
535 for (unsigned int i = 0; i < num_available_modes; i++) {
536 gboolean active = FALSE;
537 for (unsigned int j = 0; j < num_modes; j++) {
538 if (modes[j] == available_modes[i]) {
539 active = TRUE;
540 break;
541 }
542 }
543 if (!active) {
544 g_string_append_printf(emesg, " • <span color=\"red\">%s</span>\n",
546 }
547 }
548 g_string_append(emesg, "\nTo activate a mode, add it to the list in "
549 "the <span color=\"green\">modes</span> "
550 "setting.\n");
552 rofi_set_return_code(EXIT_SUCCESS);
553}
554
558static void cleanup(void) {
559 for (unsigned int i = 0; i < num_modes; i++) {
561 }
563 if (main_loop != NULL) {
564 g_main_loop_unref(main_loop);
565 main_loop = NULL;
566 }
567 // Cleanup
569
570 nk_bindings_free(bindings);
571
572 // Cleaning up memory allocated by the Xresources file.
574 g_free(modes);
575
576 g_free(config_path);
577
580
581 if (rofi_theme) {
583 rofi_theme = NULL;
584 }
585 TIMINGS_STOP();
589
591 if (rofi_configuration) {
593 rofi_configuration = NULL;
594 }
595 // Cleanup memory allocated by rofi_expand_path
596 if (cache_dir_alloc) {
597 g_free(cache_dir_alloc);
598 cache_dir_alloc = NULL;
599 }
600}
601
605
606Mode *rofi_collect_modes_search(const char *name) {
607 for (unsigned int i = 0; i < num_available_modes; i++) {
608 if (g_strcmp0(name, mode_get_name(available_modes[i])) == 0) {
609 return available_modes[i];
610 }
611 }
612 return NULL;
613}
614
619static gboolean rofi_collectmodes_add(Mode *mode) {
621 if (m == NULL) {
623 g_realloc(available_modes, sizeof(Mode *) * (num_available_modes + 1));
624 // Set mode.
627 return TRUE;
628 }
629 return FALSE;
630}
631
632static void rofi_collectmodes_dir(const char *base_dir) {
633 g_debug("Looking into: %s for plugins", base_dir);
634 GDir *dir = g_dir_open(base_dir, 0, NULL);
635 if (dir) {
636 const char *dn = NULL;
637 while ((dn = g_dir_read_name(dir))) {
638 if (!g_str_has_suffix(dn, G_MODULE_SUFFIX)) {
639 continue;
640 }
641 char *fn = g_build_filename(base_dir, dn, NULL);
642 g_debug("Trying to open: %s plugin", fn);
643 GModule *mod =
644 g_module_open(fn, G_MODULE_BIND_LAZY | G_MODULE_BIND_LOCAL);
645 if (mod) {
646 Mode *m = NULL;
647 if (g_module_symbol(mod, "mode", (gpointer *)&m)) {
649 g_warning("ABI version of plugin: '%s' does not match: %08X "
650 "expecting: %08X",
652 g_module_close(mod);
653 } else {
655 if (!rofi_collectmodes_add(m)) {
656 g_module_close(mod);
657 }
658 }
659 } else {
660 g_warning("Symbol 'mode' not found in module: %s", dn);
661 g_module_close(mod);
662 }
663 } else {
664 g_warning("Failed to open 'mode' plugin: '%s', error: %s", dn,
665 g_module_error());
666 }
667 g_free(fn);
668 }
669 g_dir_close(dir);
670 }
671}
672
676static void rofi_collect_modes(void) {
677#ifdef WINDOW_MODE
678#ifdef ENABLE_XCB
679 if (config.backend == DISPLAY_XCB) {
680 rofi_collectmodes_add(&window_mode);
681 rofi_collectmodes_add(&window_mode_cd);
682 }
683#endif
684#ifdef ENABLE_WAYLAND
685 if (config.backend == DISPLAY_WAYLAND) {
686 rofi_collectmodes_add(&wayland_window_mode);
687 }
688#endif
689#endif // WINDOW_MODE
692#ifdef ENABLE_DRUN
693 rofi_collectmodes_add(&drun_mode);
694#endif
699
700 if (find_arg("-no-plugins") < 0) {
701 find_arg_str("-plugin-path", &(config.plugin_path));
702 g_debug("Parse plugin path: %s", config.plugin_path);
703 rofi_collectmodes_dir(config.plugin_path);
704 /* ROFI_PLUGIN_PATH */
705 const char *path = g_getenv("ROFI_PLUGIN_PATH");
706 if (path != NULL) {
707 gchar **paths = g_strsplit(path, ":", -1);
708 for (unsigned int i = 0; paths[i]; i++) {
709 rofi_collectmodes_dir(paths[i]);
710 }
711 g_strfreev(paths);
712 }
713 }
715}
716
720static void rofi_collectmodes_setup(void) {
721 for (unsigned int i = 0; i < num_available_modes; i++) {
723 }
724}
725static void rofi_collectmodes_destroy(void) {
726 for (unsigned int i = 0; i < num_available_modes; i++) {
728 GModule *mod = mode_plugin_get_module(available_modes[i]);
729 available_modes[i] = NULL;
730 g_module_close(mod);
731 }
732 if (available_modes[i]) {
734 }
735 }
736 g_free(available_modes);
737 available_modes = NULL;
739}
740
748static int add_mode(const char *token) {
749 unsigned int index = num_modes;
750 // Resize and add entry.
751 modes = (Mode **)g_realloc(modes, sizeof(Mode *) * (num_modes + 1));
752
753 Mode *mode = rofi_collect_modes_search(token);
754 if (mode) {
755 modes[num_modes] = mode;
756 num_modes++;
757 } else if (script_mode_is_valid(token)) {
758 // If not build in, use custom mode.
759 Mode *sw = script_mode_parse_setup(token);
760 if (sw != NULL) {
761 // Add to available list, so combi can find it.
763 mode_set_config(sw);
764 modes[num_modes] = sw;
765 num_modes++;
766 }
767 }
768 return (index == num_modes) ? -1 : (int)index;
769}
770static gboolean setup_modes(void) {
771 const char *const sep = ",#";
772 char *savept = NULL;
773 // Make a copy, as strtok will modify it.
774 char *mode_str = g_strdup(config.modes);
775 // Split token on ','. This modifies mode_str.
776 for (char *token = strtok_r(mode_str, sep, &savept); token != NULL;
777 token = strtok_r(NULL, sep, &savept)) {
778 if (add_mode(token) == -1) {
780 }
781 }
782 // Free string that was modified by strtok_r
783 g_free(mode_str);
784 return FALSE;
785}
786
791void rofi_quit_main_loop(void) { g_main_loop_quit(main_loop); }
792
793static gboolean main_loop_signal_handler_int(G_GNUC_UNUSED gpointer data) {
794 // Break out of loop.
795 g_main_loop_quit(main_loop);
796 return G_SOURCE_CONTINUE;
797}
798static void show_error_dialog(void) {
799 GString *emesg =
800 g_string_new("The following errors were detected when starting rofi:\n");
801 GList *iter = g_list_first(list_of_error_msgs);
802 int index = 0;
803 for (; iter != NULL && index < 2; iter = g_list_next(iter)) {
804 GString *msg = (GString *)(iter->data);
805 g_string_append(emesg, "\n\n");
806 g_string_append(emesg, msg->str);
807 index++;
808 }
809 if (g_list_length(iter) > 1) {
810 g_string_append_printf(emesg, "\nThere are <b>%u</b> more errors.",
811 g_list_length(iter) - 1);
812 }
814 g_string_free(emesg, TRUE);
815 rofi_set_return_code(EX_DATAERR);
816}
817
818static gboolean startup(G_GNUC_UNUSED gpointer data) {
819 TICK_N("Startup");
820 // flags to run immediately and exit
821 char *sname = NULL;
822 char *msg = NULL;
823 MenuFlags window_flags = MENU_NORMAL;
824
825 if (find_arg("-normal-window") >= 0) {
826 window_flags |= MENU_NORMAL_WINDOW;
827 }
828 if (find_arg("-transient-window") >= 0) {
829 window_flags |= MENU_TRANSIENT_WINDOW;
830 }
831 TICK_N("Grab keyboard");
832 __create_window(window_flags);
833 TICK_N("Create Window");
834 // Parse the keybindings.
835 TICK_N("Parse ABE");
836 // Sanity check
838 TICK_N("Config sanity check");
839
840 if (list_of_error_msgs != NULL) {
842 return G_SOURCE_REMOVE;
843 }
844 if (list_of_warning_msgs != NULL) {
845 for (GList *iter = g_list_first(list_of_warning_msgs); iter != NULL;
846 iter = g_list_next(iter)) {
847 fputs(((GString *)iter->data)->str, stderr);
848 fputs("\n", stderr);
849 }
850 }
851 // Dmenu mode.
852 if (rofi_is_in_dmenu_mode == TRUE) {
853 // force off sidebar mode:
854 config.sidebar_mode = FALSE;
855 int retv = dmenu_mode_dialog();
856 if (retv) {
857 rofi_set_return_code(EXIT_SUCCESS);
858 // Directly exit.
859 g_main_loop_quit(main_loop);
860 }
861 } else if (find_arg_str("-e", &(msg))) {
862 int markup = FALSE;
863 if (find_arg("-markup") >= 0) {
864 markup = TRUE;
865 }
866 // When we pass -, we read from stdin.
867 if (g_strcmp0(msg, "-") == 0) {
868 size_t index = 0, i = 0;
869 size_t length = 1024;
870 msg = malloc(length * sizeof(char));
871 while ((i = fread(&msg[index], 1, 1024, stdin)) > 0) {
872 index += i;
873 length += i;
874 msg = realloc(msg, length * sizeof(char));
875 }
876
877 msg[index] = 0;
878
879 if (!rofi_view_error_dialog(msg, markup)) {
880 g_main_loop_quit(main_loop);
881 }
882 g_free(msg);
883 } else {
884 // Normal version
885 if (!rofi_view_error_dialog(msg, markup)) {
886 g_main_loop_quit(main_loop);
887 }
888 }
889 } else if (find_arg_str("-show", &sname) == TRUE) {
890 int index = mode_lookup(sname);
891 if (index < 0) {
892 // Add it to the list
893 index = add_mode(sname);
894 // Complain
895 if (index >= 0) {
897 }
898 // Run it anyway if found.
899 }
900 if (index >= 0) {
901 run_mode_index(index);
902 } else {
905 return G_SOURCE_REMOVE;
906 }
907 } else if (find_arg("-show") >= 0 && num_modes > 0) {
909 } else {
911
912 // g_main_loop_quit(main_loop);
913 }
914
915 return G_SOURCE_REMOVE;
916}
917
918static gboolean take_screenshot_quit(G_GNUC_UNUSED void *data) {
921 return G_SOURCE_REMOVE;
922}
923static gboolean record(G_GNUC_UNUSED void *data) {
925 return G_SOURCE_CONTINUE;
926}
927static void rofi_custom_log_function(const char *log_domain,
928 G_GNUC_UNUSED GLogLevelFlags log_level,
929 const gchar *message, gpointer user_data) {
930 int fp = GPOINTER_TO_INT(user_data);
931 dprintf(fp, "[%s]: %s\n", log_domain == NULL ? "default" : log_domain,
932 message);
933}
934
942int main(int argc, char *argv[]) {
943 cmd_set_arguments(argc, argv);
944 if (find_arg("-log") >= 0) {
945 char *logfile = NULL;
946 find_arg_str("-log", &logfile);
947 if (logfile != NULL) {
948 int fp = open(logfile, O_CLOEXEC | O_APPEND | O_CREAT | O_WRONLY,
949 S_IRUSR | S_IWUSR);
950 if (fp != -1) {
951 g_log_set_default_handler(rofi_custom_log_function,
952 GINT_TO_POINTER(fp));
953
954 } else {
955 g_error("Failed to open logfile '%s': %s.", logfile, strerror(errno));
956 }
957
958 } else {
959 g_warning("Option '-log' should pass in a filename.");
960 }
961 }
963
964 // Version
965 if (find_arg("-v") >= 0 || find_arg("-version") >= 0) {
966#ifdef GIT_VERSION
967 g_print("Version: " GIT_VERSION "\n");
968#else
969 g_print("Version: " VERSION "\n");
970#endif
971 return EXIT_SUCCESS;
972 }
973
974 if (find_arg("-rasi-validate") >= 0) {
975 char *str = NULL;
976 find_arg_str("-rasi-validate", &str);
977 if (str != NULL) {
978 int retv = rofi_theme_rasi_validate(str);
979 cleanup();
980 return retv;
981 }
982 fprintf(stderr, "Usage: %s -rasi-validate my-theme.rasi", argv[0]);
983 return EXIT_FAILURE;
984 }
985
986 {
987 const char *ro_pid = g_getenv("ROFI_OUTSIDE");
988 if (ro_pid != NULL) {
989 pid_t ro_pidi = (pid_t)g_ascii_strtoll(ro_pid, NULL, 0);
990 if (kill(ro_pidi, 0) == 0) {
991 printf("Do not launch rofi from inside rofi.\r\n");
992 return EXIT_FAILURE;
993 }
994 }
995 }
996
997 // Detect if we are in dmenu mode.
998 // This has two possible causes.
999 // 1 the user specifies it on the command-line.
1000 if (find_arg("-dmenu") >= 0) {
1001 rofi_is_in_dmenu_mode = TRUE;
1002 }
1003 // 2 the binary that executed is called dmenu (e.g. symlink to rofi)
1004 else {
1005 // Get the base name of the executable called.
1006 char *base_name = g_path_get_basename(argv[0]);
1007 const char *const dmenu_str = "dmenu";
1008 rofi_is_in_dmenu_mode = (strcmp(base_name, dmenu_str) == 0);
1009 // Free the basename for dmenu detection.
1010 g_free(base_name);
1011 }
1012 TICK();
1013
1014 // Create pid file path.
1015 const char *path = g_get_user_runtime_dir();
1016 if (path) {
1017 if (g_mkdir_with_parents(path, 0700) < 0) {
1018 g_warning("Failed to create user runtime directory: %s with error: %s",
1019 path, g_strerror(errno));
1020 pidfile = g_build_filename(g_get_home_dir(), ".rofi.pid", NULL);
1021 } else {
1022 pidfile = g_build_filename(path, "rofi.pid", NULL);
1023 }
1024 }
1026 "Pidfile location");
1027
1029 if (find_arg("-no-default-config") < 0) {
1030 GBytes *theme_data = g_resource_lookup_data(
1031 resources_get_resource(), "/org/qtools/rofi/default_configuration.rasi",
1032 G_RESOURCE_LOOKUP_FLAGS_NONE, NULL);
1033 if (theme_data) {
1034 const char *theme = g_bytes_get_data(theme_data, NULL);
1035 if (rofi_theme_parse_string((const char *)theme)) {
1036 g_warning("Failed to parse default configuration. Giving up..");
1037 if (list_of_error_msgs) {
1038 for (GList *iter = g_list_first(list_of_error_msgs); iter != NULL;
1039 iter = g_list_next(iter)) {
1040 g_warning("Error: %s%s%s", color_bold, ((GString *)iter->data)->str,
1041 color_reset);
1042 }
1043 }
1044 rofi_configuration = NULL;
1045 cleanup();
1046 return EXIT_FAILURE;
1047 }
1048 g_bytes_unref(theme_data);
1049 }
1050 }
1051
1052 if (find_arg("-config") < 0) {
1053 const char *cpath = g_get_user_config_dir();
1054 if (cpath) {
1055 config_path = g_build_filename(cpath, "rofi", "config.rasi", NULL);
1056 }
1057 } else {
1058 char *c = NULL;
1059 find_arg_str("-config", &c);
1061 }
1062 TICK();
1063
1064 const struct _display_proxy *proxy = NULL;
1065#ifdef ENABLE_XCB
1066 proxy = xcb_proxy;
1067 config.backend = DISPLAY_XCB;
1068#endif
1069
1070#ifdef ENABLE_WAYLAND
1071#ifdef ENABLE_XCB
1072 const gchar *wl_display = g_getenv("WAYLAND_DISPLAY");
1073 if (find_arg("-x11") < 0 && find_arg("-xcb") < 0 && wl_display != NULL &&
1074 strlen(wl_display) > 0) {
1076 config.backend = DISPLAY_WAYLAND;
1077 }
1078#else
1080 config.backend = DISPLAY_WAYLAND;
1081#endif
1082#endif
1083
1085
1086 if (setlocale(LC_ALL, "") == NULL) {
1087 g_warning("Failed to set locale.");
1088 cleanup();
1089 return EXIT_FAILURE;
1090 }
1091
1092 TICK_N("Setup Locale");
1094 TICK_N("Collect MODES");
1096 TICK_N("Setup MODES");
1097
1098 main_loop = g_main_loop_new(NULL, FALSE);
1099
1100 TICK_N("Setup mainloop");
1101
1102 bindings = nk_bindings_new(0lu);
1103 TICK_N("NK Bindings");
1104
1105 // Setup keybinding
1106 setup_abe();
1107 TICK_N("Setup abe");
1108
1109 if (find_arg("-no-config") < 0) {
1110 // Load distro default settings
1111 gboolean found_system = FALSE;
1112 const char *const *dirs = g_get_system_config_dirs();
1113 if (dirs) {
1114 for (unsigned int i = 0; !found_system && dirs[i]; i++) {
1116 gchar *etc = g_build_filename(dirs[i], "rofi.rasi", NULL);
1117 g_debug("Look for default config file: %s", etc);
1118 if (g_file_test(etc, G_FILE_TEST_IS_REGULAR)) {
1119 g_debug("Parsing: %s", etc);
1121 found_system = TRUE;
1122 }
1123 g_free(etc);
1124 }
1125 }
1126 if (!found_system) {
1128 gchar *etc = g_build_filename(SYSCONFDIR, "rofi.rasi", NULL);
1129 g_debug("Look for default config file: %s", etc);
1130 if (g_file_test(etc, G_FILE_TEST_IS_REGULAR)) {
1131 g_debug("Look for default config file: %s", etc);
1133 }
1134 g_free(etc);
1135 }
1136
1137 if (config_path) {
1138 // Try to resolve the path.
1139 extern const char *rasi_theme_file_extensions[];
1140 char *file2 =
1141 helper_get_theme_path(config_path, rasi_theme_file_extensions, NULL);
1142 GFile *gf = g_file_new_for_path(file2);
1143 char *filename = g_file_get_path(gf);
1144 g_object_unref(gf);
1145 g_free(file2);
1146 if (filename && g_file_test(filename, G_FILE_TEST_EXISTS)) {
1147 if (rofi_theme_parse_file(filename)) {
1149 rofi_theme = NULL;
1150 }
1151 }
1152 g_free(filename);
1153 }
1154 }
1155 find_arg_str("-theme", &(config.theme));
1156 if (config.theme) {
1157 TICK_N("Parse theme");
1159 if (rofi_theme_parse_file(config.theme)) {
1160 g_warning("Failed to parse theme: \"%s\"", config.theme);
1161 // TODO: instantiate fallback theme.?
1163 rofi_theme = NULL;
1164 }
1165 TICK_N("Parsed theme");
1166 }
1167 // Parse command line for settings, independent of other -no-config.
1168 if (list_of_error_msgs == NULL) {
1169 // Only call this when there are no errors.
1170 // This might clear existing errors.
1172 }
1173
1174 if (rofi_theme == NULL || rofi_theme->num_widgets == 0) {
1175 g_debug("Failed to load theme. Try to load default: ");
1176 rofi_theme_parse_string("@theme \"default\"");
1177 }
1178 TICK_N("Load cmd config ");
1179
1180 // Get the path to the cache dir.
1181 cache_dir = g_get_user_cache_dir();
1182
1183 if (config.cache_dir != NULL) {
1185 }
1186
1187 if (g_mkdir_with_parents(cache_dir, 0700) < 0) {
1188 g_warning("Failed to create cache directory: %s", g_strerror(errno));
1189 return EXIT_FAILURE;
1190 }
1191
1193 char *windowid = NULL;
1194 if (!rofi_is_in_dmenu_mode) {
1195 // setup_modes
1196 if (setup_modes()) {
1197 cleanup();
1198 return EXIT_FAILURE;
1199 }
1200 TICK_N("Setup Modes");
1201 } else {
1202 // Hack for dmenu compatibility.
1203 if (find_arg_str("-w", &windowid) == TRUE) {
1204 config.monitor = g_strdup_printf("wid:%s", windowid);
1205 windowid = config.monitor;
1206 }
1207 }
1208
1212 const char **theme_str = find_arg_strv("-theme-str");
1213 if (theme_str) {
1214 for (int index = 0; theme_str[index]; index++) {
1215 if (rofi_theme_parse_string(theme_str[index])) {
1216 g_warning("Failed to parse -theme-str option: \"%s\"",
1217 theme_str[index]);
1219 rofi_theme = NULL;
1220 }
1221 }
1222 g_free(theme_str);
1223 }
1224
1226 if (find_arg("-dump-theme") >= 0) {
1228 cleanup();
1229 return EXIT_SUCCESS;
1230 }
1231 if (find_arg("-dump-processed-theme") >= 0) {
1234 cleanup();
1235 return EXIT_SUCCESS;
1236 }
1237 if (find_arg("-dump-config") >= 0) {
1239 cleanup();
1240 return EXIT_SUCCESS;
1241 }
1242
1243 if (find_arg("-list-keybindings") >= 0) {
1244 int is_term = isatty(fileno(stdout));
1245 abe_list_all_bindings(is_term);
1246 return EXIT_SUCCESS;
1247 }
1248
1249 unsigned int interval = 1;
1250 if (find_arg_uint("-record-screenshots", &interval)) {
1251 g_timeout_add((guint)(1000 / (double)interval), record, NULL);
1252 }
1253 if (find_arg_uint("-take-screenshot-quit", &interval)) {
1254 g_timeout_add(interval, take_screenshot_quit, NULL);
1255 }
1256 if (find_arg("-benchmark-ui") >= 0) {
1257 config.benchmark_ui = TRUE;
1258 }
1259
1261 TICK_N("Setup Display");
1262
1263 // catch help request
1264 if (find_arg("-h") >= 0 || find_arg("-help") >= 0 ||
1265 find_arg("--help") >= 0) {
1266 help(argc, argv, FALSE);
1267 cleanup();
1268 return EXIT_SUCCESS;
1269 }
1270 if (find_arg("-info") >= 0 || find_arg("--info") >= 0) {
1271 help(argc, argv, TRUE);
1272 cleanup();
1273 return EXIT_SUCCESS;
1274 }
1275
1276 if (!display_setup_success) {
1277#ifdef ENABLE_WAYLAND
1278#ifdef ENABLE_XCB
1279 g_warning("No valid backend was found. Make sure to launch %s from a valid "
1280 "X11 or Wayland session.",
1281 argv[0]);
1282#else
1283 g_warning("No valid backend was found. Make sure to launch %s from a valid "
1284 "Wayland session.",
1285 argv[0]);
1286
1287#endif
1288#else
1289 g_warning("No valid backend was found. Make sure to launch %s from a valid "
1290 "X11 session.",
1291 argv[0]);
1292#endif
1293 cleanup();
1294 return EXIT_FAILURE;
1295 }
1296
1298 TICK_N("Workers initialize");
1300 TICK_N("Icon fetcher initialize");
1301
1302 gboolean kill_running = FALSE;
1303 if (find_arg("-replace") >= 0) {
1304 kill_running = TRUE;
1305 }
1306 // Create pid file
1307 int pfd = create_pid_file(pidfile, kill_running);
1308 TICK_N("Pid file created");
1309 if (pfd < 0) {
1310 cleanup();
1311 return EXIT_FAILURE;
1312 }
1313 textbox_setup();
1314 TICK_N("Text box setup");
1315
1316 if (!display_late_setup()) {
1317 g_warning("Failed to properly finish display setup");
1318 cleanup();
1319 return EXIT_FAILURE;
1320 }
1321 TICK_N("Setup late Display");
1322
1326 TICK_N("Theme setup");
1327
1328 // Setup signal handling sources.
1329 // SIGINT
1330 g_unix_signal_add(SIGINT, main_loop_signal_handler_int, NULL);
1331
1332 g_idle_add(startup, NULL);
1333
1334 // Start mainloop.
1335 g_main_loop_run(main_loop);
1336 teardown(pfd);
1337 cleanup();
1338
1339 /* dirty hack */
1340 g_free(windowid);
1341 return return_code;
1342}
1343
1345extern GList *list_of_error_msgs;
1346int rofi_theme_rasi_validate(const char *filename) {
1347 rofi_theme_parse_file(filename);
1349 if (list_of_error_msgs == NULL && list_of_warning_msgs == NULL) {
1350 return EXIT_SUCCESS;
1351 }
1352
1353 for (GList *iter = g_list_first(list_of_error_msgs); iter != NULL;
1354 iter = g_list_next(iter)) {
1355 fputs(((GString *)iter->data)->str, stderr);
1356 fputs("\n", stderr);
1357 }
1358 for (GList *iter = g_list_first(list_of_warning_msgs); iter != NULL;
1359 iter = g_list_next(iter)) {
1360 fputs(((GString *)iter->data)->str, stderr);
1361 fputs("\n", stderr);
1362 }
1363
1364 return EXIT_FAILURE;
1365}
1366
1368 const Mode *index = mode_available_lookup(config.completer_mode);
1369 if (index != NULL) {
1370 return index;
1371 }
1372 const char *name =
1373 config.completer_mode == NULL ? "(null)" : config.completer_mode;
1374 g_warning("Mode: %s not found or is not valid for use as completer.", name);
1375 return NULL;
1376}
gboolean display_late_setup(void)
Definition display.c:28
void display_early_cleanup(void)
Definition display.c:30
void display_init(const display_proxy *disp_in)
Definition display.c:13
void display_cleanup(void)
Definition display.c:32
guint display_scale(void)
Definition display.c:42
static const display_proxy * proxy
Definition display.c:11
gboolean display_setup(GMainLoop *main_loop, NkBindings *bindings)
Definition display.c:24
void display_dump_monitor_layout(void)
Definition display.c:34
Mode combi_mode
Definition combi.c:333
void config_parse_cmd_options(void)
Definition xrmoptions.c:633
void print_options(void)
void config_parser_add_option(XrmOptionType type, const char *key, void **value, const char *comment)
Definition xrmoptions.c:525
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.
Definition xrmoptions.c:894
@ xrm_String
Definition xrmoptions.h:73
void config_xresource_free(void)
Definition xrmoptions.c:832
int dmenu_mode_dialog(void)
Definition dmenu.c:925
void print_dmenu_options(void)
Definition dmenu.c:1019
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:782
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:445
void setup_abe(void)
Definition keyb.c:411
void abe_list_all_bindings(gboolean is_term)
Definition keyb.c:392
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:155
void rofi_quit_main_loop(void)
Definition rofi.c:791
#define color_reset
Definition rofi.h:114
#define color_bold
Definition rofi.h:116
unsigned int rofi_get_num_enabled_modes(void)
Definition rofi.c:153
void rofi_clear_error_messages(void)
Definition rofi.c:96
void rofi_clear_warning_messages(void)
Definition rofi.c:109
#define color_red
Definition rofi.h:122
#define ERROR_MSG_MARKUP
Definition rofi.h:135
void rofi_set_return_code(int code)
Definition rofi.c:151
const Mode * rofi_get_completer(void)
Definition rofi.c:1367
Mode * rofi_collect_modes_search(const char *name)
Definition rofi.c:606
const char * cache_dir
Definition rofi.c:82
void rofi_add_error_message(GString *str)
Definition rofi.c:93
#define color_green
Definition rofi.h:120
void rofi_add_warning_message(GString *str)
Definition rofi.c:106
Mode run_mode
Definition run.c:603
void script_mode_gather_user_scripts(void)
Definition script.c:561
gboolean script_mode_is_valid(const char *token)
Definition script.c:652
void script_user_list(gboolean is_term)
Definition script.c:659
void script_mode_cleanup(void)
Definition script.c:554
Mode * script_mode_parse_setup(const char *str)
Definition script.c:600
Mode ssh_mode
Definition ssh.c:637
#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:998
void textbox_setup(void)
Definition textbox.c:966
void textbox_cursor_end(textbox *tb)
Definition textbox.c:738
void textbox_text(textbox *tb, const char *text)
Definition textbox.c:403
void rofi_view_cleanup(void)
Definition view.c:2153
void __create_window(MenuFlags menu_flags)
Definition view.c:2159
void rofi_view_clear_input(RofiViewState *state)
Definition view.c:2072
void rofi_view_switch_mode(RofiViewState *state, Mode *mode)
Definition view.c:2084
void rofi_view_remove_active(RofiViewState *state)
Definition view.c:301
int rofi_view_error_dialog(const char *msg, int markup)
Definition view.c:1915
void rofi_view_set_active(RofiViewState *state)
Definition view.c:308
RofiViewState * rofi_view_get_active(void)
Definition view.c:299
MenuFlags
Definition view.h:54
MenuReturn rofi_view_get_return_value(const RofiViewState *state)
Definition view.c:371
const char * rofi_view_get_user_input(const RofiViewState *state)
Definition view.c:392
void rofi_view_set_selected_line(RofiViewState *state, unsigned int selected_line)
Definition view.c:330
void rofi_view_free(RofiViewState *state)
Definition view.c:353
RofiViewState * rofi_view_create(Mode *sw, const char *input, MenuFlags menu_flags, void(*finalize)(RofiViewState *))
Definition view.c:1795
unsigned int rofi_view_get_selected_line(const RofiViewState *state)
Definition view.c:375
@ MENU_TRANSIENT_WINDOW
Definition view.h:64
@ MENU_NORMAL_WINDOW
Definition view.h:60
@ MENU_NORMAL
Definition view.h:56
void rofi_capture_screenshot(void)
Definition view.c:132
void rofi_view_workers_initialize(void)
Definition view.c:1992
void rofi_view_workers_finalize(void)
Definition view.c:2021
char * helper_get_theme_path(const char *file, const char **ext, const char *parent_file)
Definition helper.c:1198
#define ABI_VERSION
Definition mode.h:36
static void rofi_collect_modes(void)
Definition rofi.c:676
int main(int argc, char *argv[])
Definition rofi.c:942
GList * list_of_warning_msgs
Definition rofi.c:90
GList * list_of_error_msgs
Definition rofi.c:88
static void help(G_GNUC_UNUSED int argc, char **argv, const gboolean compact)
Definition rofi.c:383
static gboolean record(G_GNUC_UNUSED void *data)
Definition rofi.c:923
G_MODULE_EXPORT char * config_path
Definition rofi.c:121
NkBindings * bindings
Definition rofi.c:136
static void print_main_application_options(int is_term)
Definition rofi.c:313
static void print_list_of_modes(int is_term)
Definition rofi.c:299
static void run_mode_index(ModeMode mode)
Definition rofi.c:204
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:927
gboolean display_setup_success
Definition rofi.c:139
static void help_print_mode_not_found(const char *mode)
Definition rofi.c:505
static void cleanup(void)
Definition rofi.c:558
Mode ** modes
Definition rofi.c:124
static gboolean startup(G_GNUC_UNUSED gpointer data)
Definition rofi.c:818
static gboolean setup_modes(void)
Definition rofi.c:770
Mode ** available_modes
Definition rofi.c:127
int rofi_theme_rasi_validate(const char *filename)
Definition rofi.c:1346
unsigned int num_modes
Definition rofi.c:131
static void rofi_collectmodes_setup(void)
Definition rofi.c:720
GMainLoop * main_loop
Definition rofi.c:142
static void teardown(int pfd)
Definition rofi.c:191
static gboolean rofi_collectmodes_add(Mode *mode)
Definition rofi.c:619
static gboolean take_screenshot_quit(G_GNUC_UNUSED void *data)
Definition rofi.c:918
static void print_backend_info()
Definition rofi.c:359
static void rofi_collectmodes_destroy(void)
Definition rofi.c:725
char * pidfile
Definition rofi.c:80
int return_code
Definition rofi.c:147
void process_result(RofiViewState *state)
Definition rofi.c:238
static const Mode * mode_available_lookup(const char *name)
Definition rofi.c:179
static int add_mode(const char *token)
Definition rofi.c:748
static gboolean main_loop_signal_handler_int(G_GNUC_UNUSED gpointer data)
Definition rofi.c:793
static void show_error_dialog(void)
Definition rofi.c:798
char * cache_dir_alloc
Definition rofi.c:85
int rofi_is_in_dmenu_mode
Definition rofi.c:145
static void help_print_no_arguments(void)
Definition rofi.c:522
static int mode_lookup(const char *name)
Definition rofi.c:164
static void help_print_disabled_mode(const char *mode)
Definition rofi.c:492
unsigned int num_available_modes
Definition rofi.c:129
static void rofi_collectmodes_dir(const char *base_dir)
Definition rofi.c:632
unsigned int curr_mode
Definition rofi.c:133
Settings config
@ DISPLAY_WAYLAND
Definition settings.h:54
@ DISPLAY_XCB
Definition settings.h:53
textbox * text
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:1599
void rofi_theme_parse_process_conditionals(void)
Definition theme.c:1603
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:1661
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:1857
display_proxy *const xcb_proxy
Definition display.c:2048
char * x11_helper_get_window_manager(void)
Definition display.c:1592
ThemeWidget * rofi_configuration
Definition xrmoptions.c:42