rofi  1.6.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-2020 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 <stdio.h>
34 #include <stdlib.h>
35 #include <string.h>
36 #include <unistd.h>
37 #include <stdint.h>
38 #include <errno.h>
39 #include <time.h>
40 #include <locale.h>
41 #include <gmodule.h>
42 #include <xcb/xcb.h>
43 #include <sys/types.h>
44 #include <sysexits.h>
45 
46 #include <glib-unix.h>
47 
48 #include <libgwater-xcb.h>
49 
50 #ifdef USE_NK_GIT_VERSION
51 #include "nkutils-git-version.h"
52 #ifdef NK_GIT_VERSION
53 #define GIT_VERSION NK_GIT_VERSION
54 #endif
55 #endif
56 
57 #include "resources.h"
58 
59 #include "rofi.h"
60 #include "display.h"
61 
62 #include "settings.h"
63 #include "mode.h"
64 #include "helper.h"
65 #include "widgets/textbox.h"
66 #include "xrmoptions.h"
67 #include "dialogs/dialogs.h"
68 
69 #include "view.h"
70 #include "view-internal.h"
71 
72 #include "theme.h"
73 #include "rofi-icon-fetcher.h"
74 
75 #include "timings.h"
76 
77 // Plugin abi version.
78 // TODO: move this check to mode.c
79 #include "mode-private.h"
80 
82 char *pidfile = NULL;
84 const char *cache_dir = NULL;
85 
87 GList *list_of_error_msgs = NULL;
88 
89 static void rofi_collect_modi_destroy ( void );
90 void rofi_add_error_message ( GString *str )
91 {
92  list_of_error_msgs = g_list_append ( list_of_error_msgs, str );
93 }
94 
96 G_MODULE_EXPORT char *config_path = NULL;
98 G_MODULE_EXPORT char *config_path_new = NULL;
100 Mode **modi = NULL;
101 
105 unsigned int num_available_modi = 0;
107 unsigned int num_modi = 0;
109 unsigned int curr_switcher = 0;
110 
112 NkBindings *bindings = NULL;
113 
115 GMainLoop *main_loop = NULL;
116 
118 static int dmenu_mode = FALSE;
120 int return_code = EXIT_SUCCESS;
121 
122 static gboolean old_config_format = FALSE;
123 
124 void process_result ( RofiViewState *state );
125 
126 void rofi_set_return_code ( int code )
127 {
128  return_code = code;
129 }
130 
131 unsigned int rofi_get_num_enabled_modi ( void )
132 {
133  return num_modi;
134 }
135 
136 const Mode * rofi_get_mode ( unsigned int index )
137 {
138  return modi[index];
139 }
140 
148 static int switcher_get ( const char *name )
149 {
150  for ( unsigned int i = 0; i < num_modi; i++ ) {
151  if ( strcmp ( mode_get_name ( modi[i] ), name ) == 0 ) {
152  return i;
153  }
154  }
155  return -1;
156 }
157 
161 static void teardown ( int pfd )
162 {
163  g_debug ( "Teardown" );
164  // Cleanup font setup.
165  textbox_cleanup ( );
166 
168 
169  // Cleanup view
171  // Cleanup pid file.
172  remove_pid_file ( pfd );
173 }
174 static void run_switcher ( ModeMode mode )
175 {
176  // Otherwise check if requested mode is enabled.
177  for ( unsigned int i = 0; i < num_modi; i++ ) {
178  if ( !mode_init ( modi[i] ) ) {
179  GString *str = g_string_new ( "Failed to initialize the mode: " );
180  g_string_append ( str, modi[i]->name );
181  g_string_append ( str, "\n" );
182 
184  g_string_free ( str, FALSE );
185  break;
186  }
187  }
188  // Error dialog must have been created.
189  if ( rofi_view_get_active () != NULL ) {
190  return;
191  }
192  curr_switcher = mode;
194 
195  // User can pre-select a row.
196  if ( find_arg ( "-selected-row" ) >= 0 ) {
197  unsigned int sr = 0;
198  find_arg_uint ( "-selected-row", &( sr ) );
199  rofi_view_set_selected_line ( state, sr );
200  }
201  if ( state ) {
202  rofi_view_set_active ( state );
203  }
204  if ( rofi_view_get_active () == NULL ) {
205  g_main_loop_quit ( main_loop );
206  }
207 }
209 {
210  Mode *sw = state->sw;
211  rofi_view_set_active ( NULL );
212  if ( sw != NULL ) {
213  unsigned int selected_line = rofi_view_get_selected_line ( state );;
214  MenuReturn mretv = rofi_view_get_return_value ( state );
215  char *input = g_strdup ( rofi_view_get_user_input ( state ) );
216  ModeMode retv = mode_result ( sw, mretv, &input, selected_line );
217  g_free ( input );
218 
219  ModeMode mode = curr_switcher;
220  // Find next enabled
221  if ( retv == NEXT_DIALOG ) {
222  mode = ( mode + 1 ) % num_modi;
223  }
224  else if ( retv == PREVIOUS_DIALOG ) {
225  if ( mode == 0 ) {
226  mode = num_modi - 1;
227  }
228  else {
229  mode = ( mode - 1 ) % num_modi;
230  }
231  }
232  else if ( retv == RELOAD_DIALOG ) {
233  // do nothing.
234  }
235  else if ( retv == RESET_DIALOG ) {
236  rofi_view_clear_input ( state );
237  }
238  else if ( retv < MODE_EXIT ) {
239  mode = ( retv ) % num_modi;
240  }
241  else {
242  mode = retv;
243  }
244  if ( mode != MODE_EXIT ) {
248  rofi_view_switch_mode ( state, modi[mode] );
249  rofi_view_set_active ( state );
250  curr_switcher = mode;
251  return;
252  }
253  }
254  rofi_view_free ( state );
255 }
256 
260 static void print_list_of_modi ( int is_term )
261 {
262  for ( unsigned int i = 0; i < num_available_modi; i++ ) {
263  gboolean active = FALSE;
264  for ( unsigned int j = 0; j < num_modi; j++ ) {
265  if ( modi[j] == available_modi[i] ) {
266  active = TRUE;
267  break;
268  }
269  }
270  printf ( " * %s%s%s%s\n",
271  active ? "+" : "",
272  is_term ? ( active ? color_green : color_red ) : "",
273  available_modi[i]->name,
274  is_term ? color_reset : ""
275  );
276  }
277 }
278 static void print_main_application_options ( int is_term )
279 {
280  print_help_msg ( "-no-config", "", "Do not load configuration, use default values.", NULL, is_term );
281  print_help_msg ( "-v,-version", "", "Print the version number and exit.", NULL, is_term );
282  print_help_msg ( "-dmenu", "", "Start in dmenu mode.", NULL, is_term );
283  print_help_msg ( "-display", "[string]", "X server to contact.", "${DISPLAY}", is_term );
284  print_help_msg ( "-h,-help", "", "This help message.", NULL, is_term );
285  print_help_msg ( "-dump-xresources", "", "Dump the current configuration in Xresources format and exit.", NULL, is_term );
286  print_help_msg ( "-e", "[string]", "Show a dialog displaying the passed message and exit.", NULL, is_term );
287  print_help_msg ( "-markup", "", "Enable pango markup where possible.", NULL, is_term );
288  print_help_msg ( "-normal-window", "", "Behave as a normal window. (experimental)", NULL, is_term );
289  print_help_msg ( "-show", "[mode]", "Show the mode 'mode' and exit. The mode has to be enabled.", NULL, is_term );
290  print_help_msg ( "-no-lazy-grab", "", "Disable lazy grab that, when fail to grab keyboard, does not block but retry later.", NULL, is_term );
291  print_help_msg ( "-no-plugins", "", "Disable loading of external plugins.", NULL, is_term );
292  print_help_msg ( "-plugin-path", "", "Directory used to search for rofi plugins. *DEPRECATED*", NULL, is_term );
293  print_help_msg ( "-dump-config", "", "Dump the current configuration in rasi format and exit.", NULL, is_term );
294  print_help_msg ( "-upgrade-config", "", "Upgrade the old-style configuration fiel in the new rasi format and exit.", NULL, is_term );
295  print_help_msg ( "-dump-theme", "", "Dump the current theme in rasi format and exit.", NULL, is_term );
296 }
297 static void help ( G_GNUC_UNUSED int argc, char **argv )
298 {
299  int is_term = isatty ( fileno ( stdout ) );
300  printf ( "%s usage:\n", argv[0] );
301  printf ( "\t%s [-options ...]\n\n", argv[0] );
302  printf ( "Command line only options:\n" );
303  print_main_application_options ( is_term );
304  printf ( "DMENU command line options:\n" );
306  printf ( "Global options:\n" );
307  print_options ();
308  printf ( "\n" );
310  printf ( "\n" );
311  printf ( "Detected modi:\n" );
312  print_list_of_modi ( is_term );
313  printf ( "\n" );
314  printf ( "Compile time options:\n" );
315 #ifdef WINDOW_MODE
316  printf ( "\t* window %senabled%s\n", is_term ? color_green : "", is_term ? color_reset : "" );
317 #else
318  printf ( "\t* window %sdisabled%s\n", is_term ? color_red : "", is_term ? color_reset : "" );
319 #endif
320 #ifdef ENABLE_DRUN
321  printf ( "\t* drun %senabled%s\n", is_term ? color_green : "", is_term ? color_reset : "" );
322 #else
323  printf ( "\t* drun %sdisabled%s\n", is_term ? color_red : "", is_term ? color_reset : "" );
324 #endif
325 #ifdef ENABLE_GCOV
326  printf ( "\t* gcov %senabled%s\n", is_term ? color_green : "", is_term ? color_reset : "" );
327 #else
328  printf ( "\t* gcov %sdisabled%s\n", is_term ? color_red : "", is_term ? color_reset : "" );
329 #endif
330 #ifdef ENABLE_ASAN
331  printf ( "\t* asan %senabled%s\n", is_term ? color_green : "", is_term ? color_reset : "" );
332 #else
333  printf ( "\t* asan %sdisabled%s\n", is_term ? color_red : "", is_term ? color_reset : "" );
334 #endif
335  printf ( "\n" );
336  printf ( "For more information see: %sman rofi%s\n", is_term ? color_bold : "", is_term ? color_reset : "" );
337 #ifdef GIT_VERSION
338  printf ( " Version: %s"GIT_VERSION "%s\n", is_term ? color_bold : "", is_term ? color_reset : "" );
339 #else
340  printf ( " Version: %s"VERSION "%s\n", is_term ? color_bold : "", is_term ? color_reset : "" );
341 #endif
342  printf ( " Bugreports: %s"PACKAGE_BUGREPORT "%s\n", is_term ? color_bold : "", is_term ? color_reset : "" );
343  printf ( " Support: %s"PACKAGE_URL "%s\n", is_term ? color_bold : "", is_term ? color_reset : "" );
344  printf ( " %s#rofi @ freenode.net%s\n", is_term ? color_bold : "", is_term ? color_reset : "" );
345  if ( find_arg ( "-no-config" ) < 0 ) {
346  if ( config_path_new ) {
347  printf ( " Configuration file: %s%s%s\n", is_term ? color_bold : "", config_path_new, is_term ? color_reset : "" );
348  }
349  else {
350  printf ( " Configuration file: %s%s%s\n", is_term ? color_bold : "", config_path, is_term ? color_reset : "" );
351  }
352  }
353  else {
354  printf ( " Configuration file: %sDisabled%s\n", is_term ? color_bold : "", is_term ? color_reset : "" );
355  }
356 }
357 
358 static void help_print_disabled_mode ( const char *mode )
359 {
360  int is_term = isatty ( fileno ( stdout ) );
361  // Only output to terminal
362  if ( is_term ) {
363  fprintf ( stderr, "Mode %s%s%s is not enabled. I have enabled it for now.\n",
364  color_red, mode, color_reset );
365  fprintf ( stderr, "Please consider adding %s%s%s to the list of enabled modi: %smodi: %s%s%s,%s%s.\n",
366  color_red, mode, color_reset,
368  color_red, mode, color_reset
369  );
370  }
371 }
372 static void help_print_mode_not_found ( const char *mode )
373 {
374  GString *str = g_string_new ( "" );
375  g_string_printf ( str, "Mode %s is not found.\nThe following modi are known:\n", mode );
376  for ( unsigned int i = 0; i < num_available_modi; i++ ) {
377  gboolean active = FALSE;
378  for ( unsigned int j = 0; j < num_modi; j++ ) {
379  if ( modi[j] == available_modi[i] ) {
380  active = TRUE;
381  break;
382  }
383  }
384  g_string_append_printf ( str, " * %s%s\n",
385  active ? "+" : "",
386  available_modi[i]->name
387  );
388  }
389  rofi_add_error_message ( str );
390 }
391 static void help_print_no_arguments ( void )
392 {
393  int is_term = isatty ( fileno ( stdout ) );
394  // Daemon mode
395  fprintf ( stderr, "Rofi is unsure what to show.\n" );
396  fprintf ( stderr, "Please specify the mode you want to show.\n\n" );
397  fprintf ( stderr, " %srofi%s -show %s{mode}%s\n\n",
398  is_term ? color_bold : "", is_term ? color_reset : "",
399  is_term ? color_green : "", is_term ? color_reset : "" );
400  fprintf ( stderr, "The following modi are enabled:\n" );
401  for ( unsigned int j = 0; j < num_modi; j++ ) {
402  fprintf ( stderr, " * %s%s%s\n",
403  is_term ? color_green : "",
404  modi[j]->name,
405  is_term ? color_reset : "" );
406  }
407  fprintf ( stderr, "\nThe following can be enabled:\n" );
408  for ( unsigned int i = 0; i < num_available_modi; i++ ) {
409  gboolean active = FALSE;
410  for ( unsigned int j = 0; j < num_modi; j++ ) {
411  if ( modi[j] == available_modi[i] ) {
412  active = TRUE;
413  break;
414  }
415  }
416  if ( !active ) {
417  fprintf ( stderr, " * %s%s%s\n",
418  is_term ? color_red : "",
419  available_modi[i]->name,
420  is_term ? color_reset : "" );
421  }
422  }
423  fprintf ( stderr, "\nTo activate a mode, add it to the list of modi in the %smodi%s setting.\n",
424  is_term ? color_green : "", is_term ? color_reset : "" );
425 }
426 
430 static void cleanup ()
431 {
432  for ( unsigned int i = 0; i < num_modi; i++ ) {
433  mode_destroy ( modi[i] );
434  }
436  if ( main_loop != NULL ) {
437  g_main_loop_unref ( main_loop );
438  main_loop = NULL;
439  }
440  // Cleanup
441  display_cleanup ();
442 
443  nk_bindings_free ( bindings );
444 
445  // Cleaning up memory allocated by the Xresources file.
447  g_free ( modi );
448 
449  g_free ( config_path );
450  g_free ( config_path_new );
451 
452  if ( list_of_error_msgs ) {
453  for ( GList *iter = g_list_first ( list_of_error_msgs );
454  iter != NULL; iter = g_list_next ( iter ) ) {
455  g_string_free ( (GString *) iter->data, TRUE );
456  }
457  g_list_free ( list_of_error_msgs );
458  }
459 
460  if ( rofi_theme ) {
462  rofi_theme = NULL;
463  }
464  TIMINGS_STOP ();
467 }
468 
478 Mode * rofi_collect_modi_search ( const char *name )
479 {
480  for ( unsigned int i = 0; i < num_available_modi; i++ ) {
481  if ( g_strcmp0 ( name, available_modi[i]->name ) == 0 ) {
482  return available_modi[i];
483  }
484  }
485  return NULL;
486 }
492 static gboolean rofi_collect_modi_add ( Mode *mode )
493 {
494  Mode *m = rofi_collect_modi_search ( mode->name );
495  if ( m == NULL ) {
496  available_modi = g_realloc ( available_modi, sizeof ( Mode * ) * ( num_available_modi + 1 ) );
497  // Set mode.
500  return TRUE;
501  }
502  return FALSE;
503 }
504 
505 static void rofi_collect_modi_dir ( const char *base_dir )
506 {
507  g_debug ( "Looking into: %s for plugins", base_dir );
508  GDir *dir = g_dir_open ( base_dir, 0, NULL );
509  if ( dir ) {
510  const char *dn = NULL;
511  while ( ( dn = g_dir_read_name ( dir ) ) ) {
512  if ( !g_str_has_suffix ( dn, G_MODULE_SUFFIX ) ) {
513  continue;
514  }
515  char *fn = g_build_filename ( base_dir, dn, NULL );
516  g_debug ( "Trying to open: %s plugin", fn );
517  GModule *mod = g_module_open ( fn, G_MODULE_BIND_LAZY | G_MODULE_BIND_LOCAL );
518  if ( mod ) {
519  Mode *m = NULL;
520  if ( g_module_symbol ( mod, "mode", (gpointer *) &m ) ) {
521  if ( m->abi_version != ABI_VERSION ) {
522  g_warning ( "ABI version of plugin: '%s' does not match: %08X expecting: %08X", dn, m->abi_version, ABI_VERSION );
523  g_module_close ( mod );
524  }
525  else {
526  m->module = mod;
527  if ( !rofi_collect_modi_add ( m ) ) {
528  g_module_close ( mod );
529  }
530  }
531  }
532  else {
533  g_warning ( "Symbol 'mode' not found in module: %s", dn );
534  g_module_close ( mod );
535  }
536  }
537  else {
538  g_warning ( "Failed to open 'mode' plugin: '%s', error: %s", dn, g_module_error () );
539  }
540  g_free ( fn );
541  }
542  g_dir_close ( dir );
543  }
544 }
545 
549 static void rofi_collect_modi ( void )
550 {
551 #ifdef WINDOW_MODE
552  rofi_collect_modi_add ( &window_mode );
553  rofi_collect_modi_add ( &window_mode_cd );
554 #endif
557 #ifdef ENABLE_DRUN
558  rofi_collect_modi_add ( &drun_mode );
559 #endif
562 
563  if ( find_arg ( "-no-plugins" ) < 0 ) {
564  find_arg_str ( "-plugin-path", &( config.plugin_path ) );
565  g_debug ( "Parse plugin path: %s", config.plugin_path );
567  /* ROFI_PLUGIN_PATH */
568  const char *path = g_getenv ( "ROFI_PLUGIN_PATH" );
569  if ( path != NULL ) {
570  gchar ** paths = g_strsplit ( path, ":", -1 );
571  for ( unsigned int i = 0; paths[i]; i++ ) {
572  rofi_collect_modi_dir ( paths[i] );
573  }
574  g_strfreev ( paths );
575  }
576  }
577 }
578 
582 static void rofi_collect_modi_setup ( void )
583 {
584  for ( unsigned int i = 0; i < num_available_modi; i++ ) {
586  }
587 }
588 static void rofi_collect_modi_destroy ( void )
589 {
590  for ( unsigned int i = 0; i < num_available_modi; i++ ) {
591  if ( available_modi[i]->module ) {
592  GModule *mod = available_modi[i]->module;
593  available_modi[i] = NULL;
594  g_module_close ( mod );
595  }
596  if ( available_modi[i] ) {
597  mode_free ( &( available_modi[i] ) );
598  }
599  }
600  g_free ( available_modi );
601  available_modi = NULL;
602  num_available_modi = 0;
603 }
604 
612 static int add_mode ( const char * token )
613 {
614  unsigned int index = num_modi;
615  // Resize and add entry.
616  modi = (Mode * *) g_realloc ( modi, sizeof ( Mode* ) * ( num_modi + 1 ) );
617 
618  Mode *mode = rofi_collect_modi_search ( token );
619  if ( mode ) {
620  modi[num_modi] = mode;
621  num_modi++;
622  }
623  else if ( script_switcher_is_valid ( token ) ) {
624  // If not build in, use custom modi.
625  Mode *sw = script_switcher_parse_setup ( token );
626  if ( sw != NULL ) {
627  // Add to available list, so combi can find it.
628  rofi_collect_modi_add ( sw );
629  modi[num_modi] = sw;
630  num_modi++;
631  }
632  }
633  return ( index == num_modi ) ? -1 : (int) index;
634 }
635 static gboolean setup_modi ( void )
636 {
637  const char *const sep = ",#";
638  char *savept = NULL;
639  // Make a copy, as strtok will modify it.
640  char *switcher_str = g_strdup ( config.modi );
641  // Split token on ','. This modifies switcher_str.
642  for ( char *token = strtok_r ( switcher_str, sep, &savept ); token != NULL; token = strtok_r ( NULL, sep, &savept ) ) {
643  if ( add_mode ( token ) == -1 ) {
644  help_print_mode_not_found ( token );
645  }
646  }
647  // Free string that was modified by strtok_r
648  g_free ( switcher_str );
649  return FALSE;
650 }
651 
656 void rofi_quit_main_loop ( void )
657 {
658  g_main_loop_quit ( main_loop );
659 }
660 
661 static gboolean main_loop_signal_handler_int ( G_GNUC_UNUSED gpointer data )
662 {
663  // Break out of loop.
664  g_main_loop_quit ( main_loop );
665  return G_SOURCE_CONTINUE;
666 }
667 static void show_error_dialog ()
668 {
669  GString *emesg = g_string_new ( "The following errors were detected when starting rofi:\n" );
670  GList *iter = g_list_first ( list_of_error_msgs );
671  int index = 0;
672  for (; iter != NULL && index < 2; iter = g_list_next ( iter ) ) {
673  GString *msg = (GString *) ( iter->data );
674  g_string_append ( emesg, "\n\n" );
675  g_string_append ( emesg, msg->str );
676  index++;
677  }
678  if ( g_list_length ( iter ) > 1 ) {
679  g_string_append_printf ( emesg, "\nThere are <b>%d</b> more errors.", g_list_length ( iter ) - 1 );
680  }
682  g_string_free ( emesg, TRUE );
683  rofi_set_return_code ( EX_DATAERR );
684 }
685 
686 static gboolean startup ( G_GNUC_UNUSED gpointer data )
687 {
688  TICK_N ( "Startup" );
689  // flags to run immediately and exit
690  char *sname = NULL;
691  char *msg = NULL;
692  MenuFlags window_flags = MENU_NORMAL;
693 
694  if ( find_arg ( "-normal-window" ) >= 0 ) {
695  window_flags |= MENU_NORMAL_WINDOW;
696  }
697  TICK_N ( "Grab keyboard" );
698  __create_window ( window_flags );
699  TICK_N ( "Create Window" );
700  // Parse the keybindings.
701  TICK_N ( "Parse ABE" );
702  // Sanity check
704  TICK_N ( "Config sanity check" );
705 
706  if ( list_of_error_msgs != NULL ) {
708  return G_SOURCE_REMOVE;
709  }
710  // Dmenu mode.
711  if ( dmenu_mode == TRUE ) {
712  // force off sidebar mode:
713  config.sidebar_mode = FALSE;
714  int retv = dmenu_switcher_dialog ();
715  if ( retv ) {
716  rofi_set_return_code ( EXIT_SUCCESS );
717  // Directly exit.
718  g_main_loop_quit ( main_loop );
719  }
720  }
721  else if ( find_arg_str ( "-e", &( msg ) ) ) {
722  int markup = FALSE;
723  if ( find_arg ( "-markup" ) >= 0 ) {
724  markup = TRUE;
725  }
726  if ( !rofi_view_error_dialog ( msg, markup ) ) {
727  g_main_loop_quit ( main_loop );
728  }
729  }
730  else if ( find_arg_str ( "-show", &sname ) == TRUE ) {
731  int index = switcher_get ( sname );
732  if ( index < 0 ) {
733  // Add it to the list
734  index = add_mode ( sname );
735  // Complain
736  if ( index >= 0 ) {
737  help_print_disabled_mode ( sname );
738  }
739  // Run it anyway if found.
740  }
741  if ( index >= 0 ) {
742  run_switcher ( index );
743  }
744  else {
745  help_print_mode_not_found ( sname );
747  return G_SOURCE_REMOVE;
748  }
749  }
750  else if ( find_arg ( "-show" ) >= 0 && num_modi > 0 ) {
751  run_switcher ( 0 );
752  }
753  else{
755 
756  g_main_loop_quit ( main_loop );
757  }
758 
759  return G_SOURCE_REMOVE;
760 }
761 
762 static gboolean record ( G_GNUC_UNUSED void *data )
763 {
765  return G_SOURCE_CONTINUE;
766 }
775 int main ( int argc, char *argv[] )
776 {
777  TIMINGS_START ();
778 
779  cmd_set_arguments ( argc, argv );
780 
781  // Version
782  if ( find_arg ( "-v" ) >= 0 || find_arg ( "-version" ) >= 0 ) {
783 #ifdef GIT_VERSION
784  g_print ( "Version: "GIT_VERSION "\n" );
785 #else
786  g_print ( "Version: "VERSION "\n" );
787 #endif
788  return EXIT_SUCCESS;
789  }
790 
791  {
792  const char *ro_pid = g_getenv ( "ROFI_OUTSIDE" );
793  if ( ro_pid != NULL ) {
794  int ro_pidi = g_ascii_strtoll ( ro_pid, NULL, 0 );
795  if ( kill ( ro_pidi, 0 ) == 0 ) {
796  printf ( "Do not launch rofi from inside rofi.\r\n" );
797  return EXIT_FAILURE;
798  }
799  }
800  }
801 
802  // Detect if we are in dmenu mode.
803  // This has two possible causes.
804  // 1 the user specifies it on the command-line.
805  if ( find_arg ( "-dmenu" ) >= 0 ) {
806  dmenu_mode = TRUE;
807  }
808  // 2 the binary that executed is called dmenu (e.g. symlink to rofi)
809  else{
810  // Get the base name of the executable called.
811  char *base_name = g_path_get_basename ( argv[0] );
812  const char * const dmenu_str = "dmenu";
813  dmenu_mode = ( strcmp ( base_name, dmenu_str ) == 0 );
814  // Free the basename for dmenu detection.
815  g_free ( base_name );
816  }
817  TICK ();
818 
819  // Create pid file path.
820  const char *path = g_get_user_runtime_dir ();
821  if ( path ) {
822  if ( g_mkdir_with_parents ( path, 0700 ) < 0 ) {
823  g_warning ( "Failed to create user runtime directory: %s with error: %s", path, g_strerror ( errno ) );
824  pidfile = g_build_filename ( g_get_home_dir (), ".rofi.pid", NULL );
825  }
826  else {
827  pidfile = g_build_filename ( path, "rofi.pid", NULL );
828  }
829  }
830  config_parser_add_option ( xrm_String, "pid", (void * *) &pidfile, "Pidfile location" );
831 
832  if ( find_arg ( "-config" ) < 0 ) {
833  const char *cpath = g_get_user_config_dir ();
834  if ( cpath ) {
835  config_path = g_build_filename ( cpath, "rofi", "config", NULL );
836  config_path_new = g_strconcat ( config_path, ".rasi", NULL );
837  }
838  }
839  else {
840  char *c = NULL;
841  find_arg_str ( "-config", &c );
842  if ( g_str_has_suffix ( c, ".rasi" ) ) {
844  }
845  else {
847  }
848  }
849 
850  TICK ();
851  if ( setlocale ( LC_ALL, "" ) == NULL ) {
852  g_warning ( "Failed to set locale." );
853  cleanup ();
854  return EXIT_FAILURE;
855  }
856 
857  TICK_N ( "Setup Locale" );
859  TICK_N ( "Collect MODI" );
861  TICK_N ( "Setup MODI" );
862 
863  main_loop = g_main_loop_new ( NULL, FALSE );
864 
865  TICK_N ( "Setup mainloop" );
866 
867  bindings = nk_bindings_new ( 0 );
868  TICK_N ( "NK Bindings" );
869 
870  if ( !display_setup ( main_loop, bindings ) ) {
871  g_warning ( "Connection has error" );
872  cleanup ();
873  return EXIT_FAILURE;
874  }
875  TICK_N ( "Setup Display" );
876 
877  // Setup keybinding
878  setup_abe ();
879  TICK_N ( "Setup abe" );
880 
881  if ( find_arg ( "-no-config" ) < 0 ) {
882  // Load distro default settings
883  gboolean found_system = FALSE;
884  const char * const * dirs = g_get_system_config_dirs ();
885  if ( dirs ) {
886  for ( unsigned int i = 0; !found_system && dirs[i]; i++ ) {
888  gchar *etc = g_build_filename ( dirs[i], "rofi.rasi", NULL );
889  g_debug ( "Look for default config file: %s", etc );
890  if ( g_file_test ( etc, G_FILE_TEST_IS_REGULAR ) ) {
891  g_debug ( "Parsing: %s", etc );
892  rofi_theme_parse_file ( etc );
893  found_system = TRUE;
894  }
895  else {
897  gchar *xetc = g_build_filename ( dirs[i], "rofi.conf", NULL );
898  g_debug ( "Look for default config file: %s", xetc );
899  if ( g_file_test ( xetc, G_FILE_TEST_IS_REGULAR ) ) {
901  old_config_format = TRUE;
902  found_system = TRUE;
903  }
904  g_free ( xetc );
905  }
906  g_free ( etc );
907  }
908  }
909  if ( !found_system ) {
911  gchar *etc = g_build_filename ( SYSCONFDIR, "rofi.rasi", NULL );
912  g_debug ( "Look for default config file: %s", etc );
913  if ( g_file_test ( etc, G_FILE_TEST_IS_REGULAR ) ) {
914  g_debug ( "Look for default config file: %s", etc );
915  rofi_theme_parse_file ( etc );
916  }
917  else {
919  gchar *xetc = g_build_filename ( SYSCONFDIR, "rofi.conf", NULL );
920  g_debug ( "Look for default config file: %s", xetc );
921  if ( g_file_test ( xetc, G_FILE_TEST_IS_REGULAR ) ) {
923  old_config_format = TRUE;
924  }
925  g_free ( xetc );
926  }
927  g_free ( etc );
928  }
929  // Load in config from X resources.
931 
932  if ( config_path_new && g_file_test ( config_path_new, G_FILE_TEST_IS_REGULAR ) ) {
935  rofi_theme = NULL;
936  }
937  }
938  else {
939  g_free ( config_path_new );
940  config_path_new = NULL;
941  if ( g_file_test ( config_path, G_FILE_TEST_IS_REGULAR ) ) {
943  old_config_format = TRUE;
944  }
945  }
946  }
947  find_arg_str ( "-theme", &( config.theme ) );
948  if ( config.theme ) {
949  TICK_N ( "Parse theme" );
950  if ( rofi_theme_parse_file ( config.theme ) ) {
951  // TODO: instantiate fallback theme.?
953  rofi_theme = NULL;
954  }
955  TICK_N ( "Parsed theme" );
956  }
957  // Parse command line for settings, independent of other -no-config.
959  TICK_N ( "Load cmd config " );
960 
961  if ( old_config_format ) {
962  g_warning ( "The old Xresources based configuration format is deprecated." );
963  g_warning ( "Please upgrade: rofi -upgrade-config." );
964  }
966 
967  // Get the path to the cache dir.
968  cache_dir = g_get_user_cache_dir ();
969 
970  if ( config.cache_dir != NULL ) {
972  }
973 
974  if ( g_mkdir_with_parents ( cache_dir, 0700 ) < 0 ) {
975  g_warning ( "Failed to create cache directory: %s", g_strerror ( errno ) );
976  return EXIT_FAILURE;
977  }
978 
980  char *windowid = NULL;
981  if ( !dmenu_mode ) {
982  // setup_modi
983  if ( setup_modi () ) {
984  cleanup ();
985  return EXIT_FAILURE;
986  }
987  TICK_N ( "Setup Modi" );
988  }
989  else {
990  // Hack for dmenu compatibility.
991  if ( find_arg_str ( "-w", &windowid ) == TRUE ) {
992  config.monitor = g_strdup_printf ( "wid:%s", windowid );
993  windowid = config.monitor;
994  }
995  }
996  if ( rofi_theme_is_empty ( ) ) {
997  GBytes *theme_data = g_resource_lookup_data (
998  resources_get_resource (),
999  "/org/qtools/rofi/default_theme.rasi",
1000  G_RESOURCE_LOOKUP_FLAGS_NONE,
1001  NULL );
1002  if ( theme_data ) {
1003  const char *theme = g_bytes_get_data ( theme_data, NULL );
1004  if ( rofi_theme_parse_string ( (const char *) theme ) ) {
1005  g_warning ( "Failed to parse default theme. Giving up.." );
1006  if ( list_of_error_msgs ) {
1007  for ( GList *iter = g_list_first ( list_of_error_msgs );
1008  iter != NULL; iter = g_list_next ( iter ) ) {
1009  g_warning ( "Error: %s%s%s",
1010  color_bold, ( (GString *) iter->data )->str, color_reset );
1011  }
1012  }
1013  rofi_theme = NULL;
1014  cleanup ();
1015  return EXIT_FAILURE;
1016  }
1017  g_bytes_unref ( theme_data );
1018  }
1019  rofi_theme_convert_old ();
1020  }
1021 
1025  const char ** theme_str = find_arg_strv ( "-theme-str" );
1026  if ( theme_str ) {
1027  for ( int index = 0; theme_str && theme_str[index]; index++ ) {
1028  if ( rofi_theme_parse_string ( theme_str[index] ) ) {
1030  rofi_theme = NULL;
1031  }
1032  }
1033  g_free ( theme_str );
1034  }
1035 
1036  if ( find_arg ( "-dump-theme" ) >= 0 ) {
1038  cleanup ();
1039  return EXIT_SUCCESS;
1040  }
1041  if ( find_arg ( "-upgrade-config" ) >= 0 ) {
1042  setup_modi ();
1043 
1044  for ( unsigned int i = 0; i < num_modi; i++ ) {
1045  mode_init ( modi[i] );
1046  }
1047 
1048  const char *cpath = g_get_user_config_dir ();
1049  if ( cpath ) {
1050  char *fcpath = g_build_filename ( cpath, "rofi", NULL );
1051  if ( !g_file_test ( fcpath, G_FILE_TEST_IS_DIR ) && g_mkdir_with_parents ( fcpath, 0700 ) < 0 ) {
1052  g_warning ( "Failed to create rofi configuration directory: %s", fcpath );
1053  cleanup ();
1054  g_free ( fcpath );
1055  return EXIT_FAILURE;
1056  }
1057  g_free ( fcpath );
1058  fcpath = g_build_filename ( cpath, "rofi", "config.rasi", NULL );
1059  if ( g_file_test ( fcpath, G_FILE_TEST_IS_REGULAR ) ) {
1060  g_warning ( "New configuration file already exists: %s", fcpath );
1061  cleanup ();
1062  g_free ( fcpath );
1063  return EXIT_FAILURE;
1064  }
1065  FILE *fd = fopen ( fcpath, "w" );
1066  if ( fd == NULL ) {
1067  g_warning ( "Failed to open new rofi configuration file: %s: %s", fcpath, strerror ( errno ) );
1068  cleanup ();
1069  g_free ( fcpath );
1070  return EXIT_FAILURE;
1071  }
1073  fprintf ( stdout, "\n***** Generated configuration file in: %s *****\n", fcpath );
1074 
1075  fflush ( fd );
1076  fclose ( fd );
1077  g_free ( fcpath );
1078  }
1079  else {
1080  g_warning ( "Failed to get user configuration directory." );
1081  cleanup ();
1082  return EXIT_FAILURE;
1083  }
1084  cleanup ();
1085  return EXIT_SUCCESS;
1086  }
1087  if ( find_arg ( "-dump-config" ) >= 0 ) {
1088  config_parse_dump_config_rasi_format ( stdout, FALSE );
1089  cleanup ();
1090  return EXIT_SUCCESS;
1091  }
1092  // Dump.
1093  // catch help request
1094  if ( find_arg ( "-h" ) >= 0 || find_arg ( "-help" ) >= 0 || find_arg ( "--help" ) >= 0 ) {
1095  help ( argc, argv );
1096  cleanup ();
1097  return EXIT_SUCCESS;
1098  }
1099  if ( find_arg ( "-dump-xresources" ) >= 0 ) {
1101  cleanup ();
1102  return EXIT_SUCCESS;
1103  }
1104 
1105  unsigned int interval = 1;
1106  if ( find_arg_uint ( "-record-screenshots", &interval ) ) {
1107  g_timeout_add ( 1000 / (double) interval, record, NULL );
1108  }
1109  if ( find_arg ( "-benchmark-ui" ) >= 0 ) {
1110  config.benchmark_ui = TRUE;
1111  }
1112 
1114  TICK_N ( "Workers initialize" );
1116  TICK_N ( "Icon fetcher initialize" );
1117 
1118  // Create pid file
1119  int pfd = create_pid_file ( pidfile );
1120  TICK_N ( "Pid file created" );
1121  if ( pfd < 0 ) {
1122  cleanup ();
1123  return EXIT_FAILURE;
1124  }
1125  textbox_setup ();
1126  TICK_N ( "Text box setup" );
1127 
1128  if ( !display_late_setup () ) {
1129  g_warning ( "Failed to properly finish display setup" );
1130  cleanup ();
1131  return EXIT_FAILURE;
1132  }
1133  TICK_N ( "Setup late Display" );
1134 
1136  TICK_N ( "Theme setup" );
1137 
1138  // Setup signal handling sources.
1139  // SIGINT
1140  g_unix_signal_add ( SIGINT, main_loop_signal_handler_int, NULL );
1141 
1142  g_idle_add ( startup, NULL );
1143 
1144  // Start mainloop.
1145  g_main_loop_run ( main_loop );
1146  teardown ( pfd );
1147  cleanup ();
1148 
1149  /* dirty hack */
1150  g_free ( windowid );
1151  return return_code;
1152 }
TIMINGS_START
#define TIMINGS_START()
Definition: timings.h:60
RofiViewState::sw
Mode * sw
Definition: view-internal.h:50
RESET_DIALOG
@ RESET_DIALOG
Definition: mode.h:60
ERROR_MSG_MARKUP
#define ERROR_MSG_MARKUP
Definition: rofi.h:110
dmenu_switcher_dialog
int dmenu_switcher_dialog(void)
Definition: dmenu.c:659
Settings::cache_dir
char * cache_dir
Definition: settings.h:195
find_arg_strv
const char ** find_arg_strv(const char *const key)
Definition: helper.c:287
MenuFlags
MenuFlags
Definition: view.h:44
xcb
xcb_stuff * xcb
Definition: xcb.c:87
xrmoptions.h
TIMINGS_STOP
#define TIMINGS_STOP()
Definition: timings.h:73
print_main_application_options
static void print_main_application_options(int is_term)
Definition: rofi.c:278
config_parse_dump_config_rasi_format
void config_parse_dump_config_rasi_format(FILE *out, gboolean changes)
Dump configuration in rasi format.
Definition: xrmoptions.c:636
rofi_collect_modi_add
static gboolean rofi_collect_modi_add(Mode *mode)
Definition: rofi.c:492
parse_keys_abe
gboolean parse_keys_abe(NkBindings *bindings)
Definition: keyb.c:148
list_of_error_msgs
GList * list_of_error_msgs
Definition: rofi.c:87
cache_dir
const char * cache_dir
Definition: rofi.c:84
dialogs.h
num_available_modi
unsigned int num_available_modi
Definition: rofi.c:105
rofi_view_workers_initialize
void rofi_view_workers_initialize(void)
Definition: view.c:1975
rofi_capture_screenshot
void rofi_capture_screenshot(void)
Definition: view.c:177
pidfile
char * pidfile
Definition: rofi.c:82
rofi_mode::name
char * name
Definition: mode-private.h:156
settings.h
main_loop_signal_handler_int
static gboolean main_loop_signal_handler_int(G_GNUC_UNUSED gpointer data)
Definition: rofi.c:661
color_red
#define color_red
Definition: rofi.h:98
rofi_view_clear_input
void rofi_view_clear_input(RofiViewState *state)
Definition: view.c:2029
dmenu_mode
static int dmenu_mode
Definition: rofi.c:118
help
static void help(G_GNUC_UNUSED int argc, char **argv)
Definition: rofi.c:297
rofi_view_get_active
RofiViewState * rofi_view_get_active(void)
Definition: view.c:488
cleanup
static void cleanup()
Definition: rofi.c:430
config_path
G_MODULE_EXPORT char * config_path
Definition: rofi.c:96
Settings::monitor
char * monitor
Definition: settings.h:156
rofi_theme
ThemeWidget * rofi_theme
display_late_setup
gboolean display_late_setup(void)
Definition: xcb.c:1359
main
int main(int argc, char *argv[])
Definition: rofi.c:775
PREVIOUS_DIALOG
@ PREVIOUS_DIALOG
Definition: mode.h:58
mode.h
textbox_setup
void textbox_setup(void)
Definition: textbox.c:817
rofi_view_error_dialog
int rofi_view_error_dialog(const char *msg, int markup)
Definition: view.c:1886
display_cleanup
void display_cleanup(void)
Definition: xcb.c:1404
rofi_get_mode
const Mode * rofi_get_mode(unsigned int index)
Definition: rofi.c:136
config_parse_xresource_dump
void config_parse_xresource_dump(void)
Definition: xrmoptions.c:574
Settings::plugin_path
char * plugin_path
Definition: settings.h:186
print_help_msg
void print_help_msg(const char *option, const char *type, const char *text, const char *def, int isatty)
Definition: xrmoptions.c:773
rofi_view_get_selected_line
unsigned int rofi_view_get_selected_line(const RofiViewState *state)
Definition: view.c:556
mode_init
int mode_init(Mode *mode)
Definition: mode.c:42
config_parse_xresource_options_file
void config_parse_xresource_options_file(const char *filename)
Definition: xrmoptions.c:345
NEXT_DIALOG
@ NEXT_DIALOG
Definition: mode.h:54
MENU_NORMAL
@ MENU_NORMAL
Definition: view.h:46
remove_pid_file
void remove_pid_file(int fd)
Definition: helper.c:525
__create_window
void __create_window(MenuFlags menu_flags)
Definition: view.c:719
find_arg
int find_arg(const char *const key)
Definition: helper.c:266
rofi_view_free
void rofi_view_free(RofiViewState *state)
Definition: view.c:532
MenuReturn
MenuReturn
Definition: mode.h:67
rofi_icon_fetcher_destroy
void rofi_icon_fetcher_destroy(void)
Definition: rofi-icon-fetcher.c:122
rofi_theme_parse_file
gboolean rofi_theme_parse_file(const char *file)
timings.h
Settings::theme
char * theme
Definition: settings.h:184
cmd_set_arguments
void cmd_set_arguments(int argc, char **argv)
Definition: helper.c:76
rofi_view_get_return_value
MenuReturn rofi_view_get_return_value(const RofiViewState *state)
Definition: view.c:551
Settings::sidebar_mode
unsigned int sidebar_mode
Definition: settings.h:141
theme.h
mode-private.h
rofi_quit_main_loop
void rofi_quit_main_loop(void)
Definition: rofi.c:656
rofi_view_set_active
void rofi_view_set_active(RofiViewState *state)
Definition: view.c:493
mode_get_name
const char * mode_get_name(const Mode *mode)
Definition: mode.c:112
ABI_VERSION
#define ABI_VERSION
Definition: mode-private.h:34
script_switcher_parse_setup
Mode * script_switcher_parse_setup(const char *str)
Definition: script.c:428
rofi_collect_modi_destroy
static void rofi_collect_modi_destroy(void)
Definition: rofi.c:588
old_config_format
static gboolean old_config_format
Definition: rofi.c:122
mode_free
void mode_free(Mode **mode)
Definition: mode.c:118
rofi_theme_print
void rofi_theme_print(ThemeWidget *widget)
Definition: theme.c:518
MODE_EXIT
@ MODE_EXIT
Definition: mode.h:52
help_print_no_arguments
static void help_print_no_arguments(void)
Definition: rofi.c:391
help_keys_mode
Mode help_keys_mode
Definition: help-keys.c:122
find_arg_uint
int find_arg_uint(const char *const key, unsigned int *val)
Definition: helper.c:318
modi
Mode ** modi
Definition: rofi.c:100
rofi_theme_free
void rofi_theme_free(ThemeWidget *widget)
Definition: theme.c:246
TICK_N
#define TICK_N(a)
Definition: timings.h:69
color_bold
#define color_bold
Definition: rofi.h:92
display_dump_monitor_layout
void display_dump_monitor_layout(void)
Definition: xcb.c:496
view-internal.h
mode_destroy
void mode_destroy(Mode *mode)
Definition: mode.c:49
rofi_collect_modi_search
Mode * rofi_collect_modi_search(const char *name)
Definition: rofi.c:478
print_list_of_modi
static void print_list_of_modi(int is_term)
Definition: rofi.c:260
rofi_theme_parse_string
gboolean rofi_theme_parse_string(const char *string)
teardown
static void teardown(int pfd)
Definition: rofi.c:161
record
static gboolean record(G_GNUC_UNUSED void *data)
Definition: rofi.c:762
Settings::benchmark_ui
gboolean benchmark_ui
Definition: settings.h:205
rofi_expand_path
char * rofi_expand_path(const char *input)
Definition: helper.c:664
rofi_collect_modi_dir
static void rofi_collect_modi_dir(const char *base_dir)
Definition: rofi.c:505
rofi_theme_parse_process_conditionals
void rofi_theme_parse_process_conditionals(void)
Definition: theme.c:1208
show_error_dialog
static void show_error_dialog()
Definition: rofi.c:667
config_sanity_check
int config_sanity_check(void)
Definition: helper.c:552
print_dmenu_options
void print_dmenu_options(void)
Definition: dmenu.c:755
rofi_mode
Definition: mode-private.h:152
config_xresource_free
void config_xresource_free(void)
Definition: xrmoptions.c:516
rofi.h
rofi_theme_is_empty
gboolean rofi_theme_is_empty(void)
Definition: theme.c:1012
ssh_mode
Mode ssh_mode
Definition: ssh.c:655
config_parse_cmd_options
void config_parse_cmd_options(void)
Definition: xrmoptions.c:413
config_parser_add_option
void config_parser_add_option(XrmOptionType type, const char *key, void **value, const char *comment)
Definition: xrmoptions.c:241
create_pid_file
int create_pid_file(const char *pidfile)
Definition: helper.c:486
textbox_cleanup
void textbox_cleanup(void)
Definition: textbox.c:835
combi_mode
Mode combi_mode
Definition: combi.c:309
Settings::modi
char * modi
Definition: settings.h:62
rofi_add_error_message
void rofi_add_error_message(GString *str)
Definition: rofi.c:90
rofi_get_num_enabled_modi
unsigned int rofi_get_num_enabled_modi(void)
Definition: rofi.c:131
find_arg_str
int find_arg_str(const char *const key, char **val)
Definition: helper.c:276
xrm_String
@ xrm_String
Definition: xrmoptions.h:72
display_setup
gboolean display_setup(GMainLoop *main_loop, NkBindings *bindings)
Definition: xcb.c:1164
display.h
setup_modi
static gboolean setup_modi(void)
Definition: rofi.c:635
available_modi
Mode ** available_modi
Definition: rofi.c:103
MENU_NORMAL_WINDOW
@ MENU_NORMAL_WINDOW
Definition: view.h:50
bindings
NkBindings * bindings
Definition: rofi.c:112
num_modi
unsigned int num_modi
Definition: rofi.c:107
display_early_cleanup
void display_early_cleanup(void)
Definition: xcb.c:1397
script_switcher_is_valid
gboolean script_switcher_is_valid(const char *token)
Definition: script.c:465
config_parse_xresource_options
void config_parse_xresource_options(xcb_stuff *xcb)
Definition: xrmoptions.c:336
run_mode
Mode run_mode
Definition: run.c:412
view.h
run_switcher
static void run_switcher(ModeMode mode)
Definition: rofi.c:174
rofi_set_return_code
void rofi_set_return_code(int code)
Definition: rofi.c:126
Settings::filter
char * filter
Definition: settings.h:161
textbox.h
rofi-icon-fetcher.h
help_print_disabled_mode
static void help_print_disabled_mode(const char *mode)
Definition: rofi.c:358
ModeMode
ModeMode
Definition: mode.h:50
TICK
#define TICK()
Definition: timings.h:64
rofi_mode::module
GModule * module
Definition: mode-private.h:197
rofi_view_create
RofiViewState * rofi_view_create(Mode *sw, const char *input, MenuFlags menu_flags, void(*finalize)(RofiViewState *))
Definition: view.c:1809
main_loop
GMainLoop * main_loop
Definition: rofi.c:115
RELOAD_DIALOG
@ RELOAD_DIALOG
Definition: mode.h:56
curr_switcher
unsigned int curr_switcher
Definition: rofi.c:109
add_mode
static int add_mode(const char *token)
Definition: rofi.c:612
rofi_view_get_user_input
const char * rofi_view_get_user_input(const RofiViewState *state)
Definition: view.c:576
switcher_get
static int switcher_get(const char *name)
Definition: rofi.c:148
color_reset
#define color_reset
Definition: rofi.h:90
rofi_view_workers_finalize
void rofi_view_workers_finalize(void)
Definition: view.c:2002
rofi_view_cleanup
void rofi_view_cleanup()
Definition: view.c:1937
mode_result
ModeMode mode_result(Mode *mode, int menu_retv, char **input, unsigned int selected_line)
Definition: mode.c:97
helper.h
startup
static gboolean startup(G_GNUC_UNUSED gpointer data)
Definition: rofi.c:686
setup_abe
void setup_abe(void)
Definition: keyb.c:134
rofi_icon_fetcher_init
void rofi_icon_fetcher_init(void)
Definition: rofi-icon-fetcher.c:102
RofiViewState
Definition: view-internal.h:48
rofi_collect_modi_setup
static void rofi_collect_modi_setup(void)
Definition: rofi.c:582
config
Settings config
print_options
void print_options(void)
Definition: xrmoptions.c:755
help_print_mode_not_found
static void help_print_mode_not_found(const char *mode)
Definition: rofi.c:372
color_green
#define color_green
Definition: rofi.h:96
mode_set_config
void mode_set_config(Mode *mode)
Definition: mode.c:151
rofi_view_set_selected_line
void rofi_view_set_selected_line(RofiViewState *state, unsigned int selected_line)
Definition: view.c:516
rofi_collect_modi
static void rofi_collect_modi(void)
Definition: rofi.c:549
return_code
int return_code
Definition: rofi.c:120
config_path_new
G_MODULE_EXPORT char * config_path_new
Definition: rofi.c:98
rofi_view_switch_mode
void rofi_view_switch_mode(RofiViewState *state, Mode *mode)
Definition: view.c:2042
process_result
void process_result(RofiViewState *state)
Definition: rofi.c:208