rofi  1.7.3
helper.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-2021 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 "Helper"
31 
32 #include "config.h"
33 #include "display.h"
34 #include "helper-theme.h"
35 #include "rofi.h"
36 #include "settings.h"
37 #include "view.h"
38 #include "xcb.h"
39 #include <ctype.h>
40 #include <errno.h>
41 #include <fcntl.h>
42 #include <glib.h>
43 #include <glib/gstdio.h>
44 #include <limits.h>
45 #include <pango/pango-fontmap.h>
46 #include <pango/pango.h>
47 #include <pango/pangocairo.h>
48 #include <pwd.h>
49 #include <stdio.h>
50 #include <stdlib.h>
51 #include <string.h>
52 #include <sys/file.h>
53 #include <sys/stat.h>
54 #include <sys/types.h>
55 #include <unistd.h>
56 
60 const char *const monitor_position_entries[] = {
61  "on focused monitor", "on focused window", "at mouse pointer",
62  "on monitor with focused window", "on monitor that has mouse pointer"};
64 int stored_argc = 0;
66 char **stored_argv = NULL;
67 
68 char *helper_string_replace_if_exists_v(char *string, GHashTable *h);
69 
70 void cmd_set_arguments(int argc, char **argv) {
71  stored_argc = argc;
72  stored_argv = argv;
73 }
74 
75 int helper_parse_setup(char *string, char ***output, int *length, ...) {
76  GError *error = NULL;
77  GHashTable *h;
78  h = g_hash_table_new(g_str_hash, g_str_equal);
79  // By default, we insert terminal and ssh-client
80  g_hash_table_insert(h, "{terminal}", config.terminal_emulator);
81  g_hash_table_insert(h, "{ssh-client}", config.ssh_client);
82  // Add list from variable arguments.
83  va_list ap;
84  va_start(ap, length);
85  while (1) {
86  char *key = va_arg(ap, char *);
87  if (key == (char *)0) {
88  break;
89  }
90  char *value = va_arg(ap, char *);
91  if (value == (char *)0) {
92  break;
93  }
94  g_hash_table_insert(h, key, value);
95  }
96  va_end(ap);
97 
98  char *res = helper_string_replace_if_exists_v(string, h);
99  // Destroy key-value storage.
100  g_hash_table_destroy(h);
101  // Parse the string into shell arguments.
102  if (g_shell_parse_argv(res, length, output, &error)) {
103  g_free(res);
104  return TRUE;
105  }
106  g_free(res);
107  // Throw error if shell parsing fails.
108  if (error) {
109  char *msg = g_strdup_printf("Failed to parse: '%s'\nError: '%s'", string,
110  error->message);
111  rofi_view_error_dialog(msg, FALSE);
112  g_free(msg);
113  // print error.
114  g_error_free(error);
115  }
116  return FALSE;
117 }
118 
120  for (size_t i = 0; tokens && tokens[i]; i++) {
121  g_regex_unref((GRegex *)tokens[i]->regex);
122  g_free(tokens[i]);
123  }
124  g_free(tokens);
125 }
126 
127 static gchar *glob_to_regex(const char *input) {
128  gchar *r = g_regex_escape_string(input, -1);
129  size_t str_l = strlen(r);
130  for (size_t i = 0; i < str_l; i++) {
131  if (r[i] == '\\') {
132  if (r[i + 1] == '*') {
133  r[i] = '.';
134  } else if (r[i + 1] == '?') {
135  r[i + 1] = 'S';
136  }
137  i++;
138  }
139  }
140  return r;
141 }
142 static gchar *fuzzy_to_regex(const char *input) {
143  GString *str = g_string_new("");
144  gchar *r = g_regex_escape_string(input, -1);
145  gchar *iter;
146  int first = 1;
147  for (iter = r; iter && *iter != '\0'; iter = g_utf8_next_char(iter)) {
148  if (first) {
149  g_string_append(str, "(");
150  } else {
151  g_string_append(str, ".*?(");
152  }
153  if (*iter == '\\') {
154  g_string_append_c(str, '\\');
155  iter = g_utf8_next_char(iter);
156  // If EOL, break out of for loop.
157  if ((*iter) == '\0') {
158  break;
159  }
160  }
161  g_string_append_unichar(str, g_utf8_get_char(iter));
162  g_string_append(str, ")");
163  first = 0;
164  }
165  g_free(r);
166  char *retv = str->str;
167  g_string_free(str, FALSE);
168  return retv;
169 }
170 
171 static gchar *prefix_regex(const char *input) {
172  gchar *r = g_regex_escape_string(input, -1);
173  char *retv = g_strconcat("\\b", r, NULL);
174  g_free(r);
175  return retv;
176 }
177 
178 static char *utf8_helper_simplify_string(const char *s) {
179  gunichar buf2[G_UNICHAR_MAX_DECOMPOSITION_LENGTH] = {
180  0,
181  };
182  char buf[6] = {
183  0,
184  };
185  // Compose the string in maximally composed form.
186  ssize_t str_size = (g_utf8_strlen(s, -1) * 6 + 2 + 1) * sizeof(char);
187  char *str = g_malloc0(str_size);
188  char *striter = str;
189  for (const char *iter = s; iter && *iter; iter = g_utf8_next_char(iter)) {
190  gunichar uc = g_utf8_get_char(iter);
191  int l = 0;
192  gsize dl = g_unichar_fully_decompose(uc, FALSE, buf2,
193  G_UNICHAR_MAX_DECOMPOSITION_LENGTH);
194  if (dl) {
195  l = g_unichar_to_utf8(buf2[0], buf);
196  } else {
197  l = g_unichar_to_utf8(uc, buf);
198  }
199  memcpy(striter, buf, l);
200  striter += l;
201  }
202 
203  return str;
204 }
205 
206 // Macro for quickly generating regex for matching.
207 static inline GRegex *R(const char *s, int case_sensitive) {
208  if (config.normalize_match) {
209  char *str = utf8_helper_simplify_string(s);
210 
211  GRegex *r = g_regex_new(
212  str, G_REGEX_OPTIMIZE | ((case_sensitive) ? 0 : G_REGEX_CASELESS), 0,
213  NULL);
214 
215  g_free(str);
216  return r;
217  }
218  return g_regex_new(
219  s, G_REGEX_OPTIMIZE | ((case_sensitive) ? 0 : G_REGEX_CASELESS), 0, NULL);
220 }
221 
222 static rofi_int_matcher *create_regex(const char *input, int case_sensitive) {
223  GRegex *retv = NULL;
224  gchar *r;
225  rofi_int_matcher *rv = g_malloc0(sizeof(rofi_int_matcher));
226  if (input && input[0] == config.matching_negate_char) {
227  rv->invert = 1;
228  input++;
229  }
230  switch (config.matching_method) {
231  case MM_GLOB:
232  r = glob_to_regex(input);
233  retv = R(r, case_sensitive);
234  g_free(r);
235  break;
236  case MM_REGEX:
237  retv = R(input, case_sensitive);
238  if (retv == NULL) {
239  r = g_regex_escape_string(input, -1);
240  retv = R(r, case_sensitive);
241  g_free(r);
242  }
243  break;
244  case MM_FUZZY:
245  r = fuzzy_to_regex(input);
246  retv = R(r, case_sensitive);
247  g_free(r);
248  break;
249  case MM_PREFIX:
250  r = prefix_regex(input);
251  retv = R(r, case_sensitive);
252  g_free(r);
253  break;
254  default:
255  r = g_regex_escape_string(input, -1);
256  retv = R(r, case_sensitive);
257  g_free(r);
258  break;
259  }
260  rv->regex = retv;
261  return rv;
262 }
263 rofi_int_matcher **helper_tokenize(const char *input, int case_sensitive) {
264  if (input == NULL) {
265  return NULL;
266  }
267  size_t len = strlen(input);
268  if (len == 0) {
269  return NULL;
270  }
271 
272  char *saveptr = NULL, *token;
273  rofi_int_matcher **retv = NULL;
274  if (!config.tokenize) {
275  retv = g_malloc0(sizeof(rofi_int_matcher *) * 2);
276  retv[0] = create_regex(input, case_sensitive);
277  return retv;
278  }
279 
280  // First entry is always full (modified) stringtext.
281  int num_tokens = 0;
282 
283  // Copy the string, 'strtok_r' modifies it.
284  char *str = g_strdup(input);
285 
286  // Iterate over tokens.
287  // strtok should still be valid for utf8.
288  const char *const sep = " ";
289  for (token = strtok_r(str, sep, &saveptr); token != NULL;
290  token = strtok_r(NULL, sep, &saveptr)) {
291  retv = g_realloc(retv, sizeof(rofi_int_matcher *) * (num_tokens + 2));
292  retv[num_tokens] = create_regex(token, case_sensitive);
293  retv[num_tokens + 1] = NULL;
294  num_tokens++;
295  }
296  // Free str.
297  g_free(str);
298  return retv;
299 }
300 
301 // cli arg handling
302 int find_arg(const char *const key) {
303  int i;
304 
305  for (i = 0; i < stored_argc && strcasecmp(stored_argv[i], key); i++) {
306  ;
307  }
308 
309  return i < stored_argc ? i : -1;
310 }
311 int find_arg_str(const char *const key, char **val) {
312  int i = find_arg(key);
313 
314  if (val != NULL && i > 0 && i < stored_argc - 1) {
315  *val = stored_argv[i + 1];
316  return TRUE;
317  }
318  return FALSE;
319 }
320 
321 const char **find_arg_strv(const char *const key) {
322  const char **retv = NULL;
323  int length = 0;
324  for (int i = 0; i < stored_argc; i++) {
325  if (i < (stored_argc - 1) && strcasecmp(stored_argv[i], key) == 0) {
326  length++;
327  }
328  }
329  if (length > 0) {
330  retv = g_malloc0((length + 1) * sizeof(char *));
331  int index = 0;
332  for (int i = 0; i < stored_argc; i++) {
333  if (i < (stored_argc - 1) && strcasecmp(stored_argv[i], key) == 0) {
334  retv[index++] = stored_argv[i + 1];
335  }
336  }
337  }
338  return retv;
339 }
340 
341 int find_arg_int(const char *const key, int *val) {
342  int i = find_arg(key);
343 
344  if (val != NULL && i > 0 && i < (stored_argc - 1)) {
345  *val = strtol(stored_argv[i + 1], NULL, 10);
346  return TRUE;
347  }
348  return FALSE;
349 }
350 int find_arg_uint(const char *const key, unsigned int *val) {
351  int i = find_arg(key);
352 
353  if (val != NULL && i > 0 && i < (stored_argc - 1)) {
354  *val = strtoul(stored_argv[i + 1], NULL, 10);
355  return TRUE;
356  }
357  return FALSE;
358 }
359 
360 char helper_parse_char(const char *arg) {
361  const size_t len = strlen(arg);
362  // If the length is 1, it is not escaped.
363  if (len == 1) {
364  return arg[0];
365  }
366  // If the length is 2 and the first character is '\', we unescape it.
367  if (len == 2 && arg[0] == '\\') {
368  switch (arg[1]) {
369  // New line
370  case 'n':
371  return '\n';
372  // Bell
373  case 'a':
374  return '\a';
375  // Backspace
376  case 'b':
377  return '\b';
378  // Tab
379  case 't':
380  return '\t';
381  // Vertical tab
382  case 'v':
383  return '\v';
384  // Form feed
385  case 'f':
386  return '\f';
387  // Carriage return
388  case 'r':
389  return '\r';
390  // Forward slash
391  case '\\':
392  return '\\';
393  // 0 line.
394  case '0':
395  return '\0';
396  default:
397  break;
398  }
399  }
400  if (len > 2 && arg[0] == '\\' && arg[1] == 'x') {
401  return (char)strtol(&arg[2], NULL, 16);
402  }
403  g_warning("Failed to parse character string: \"%s\"", arg);
404  // for now default to newline.
405  return '\n';
406 }
407 
408 int find_arg_char(const char *const key, char *val) {
409  int i = find_arg(key);
410 
411  if (val != NULL && i > 0 && i < (stored_argc - 1)) {
412  *val = helper_parse_char(stored_argv[i + 1]);
413  return TRUE;
414  }
415  return FALSE;
416 }
417 
419  rofi_int_matcher **tokens,
420  const char *input,
421  PangoAttrList *retv) {
422  // Disable highlighting for normalize match, not supported atm.
423  if (config.normalize_match) {
424  return retv;
425  }
426  // Do a tokenized match.
427  if (tokens) {
428  for (int j = 0; tokens[j]; j++) {
429  GMatchInfo *gmi = NULL;
430  if (tokens[j]->invert) {
431  continue;
432  }
433  g_regex_match(tokens[j]->regex, input, G_REGEX_MATCH_PARTIAL, &gmi);
434  while (g_match_info_matches(gmi)) {
435  int count = g_match_info_get_match_count(gmi);
436  for (int index = (count > 1) ? 1 : 0; index < count; index++) {
437  int start, end;
438  g_match_info_fetch_pos(gmi, index, &start, &end);
439  if (th.style & ROFI_HL_BOLD) {
440  PangoAttribute *pa = pango_attr_weight_new(PANGO_WEIGHT_BOLD);
441  pa->start_index = start;
442  pa->end_index = end;
443  pango_attr_list_insert(retv, pa);
444  }
445  if (th.style & ROFI_HL_UNDERLINE) {
446  PangoAttribute *pa =
447  pango_attr_underline_new(PANGO_UNDERLINE_SINGLE);
448  pa->start_index = start;
449  pa->end_index = end;
450  pango_attr_list_insert(retv, pa);
451  }
452  if (th.style & ROFI_HL_STRIKETHROUGH) {
453  PangoAttribute *pa = pango_attr_strikethrough_new(TRUE);
454  pa->start_index = start;
455  pa->end_index = end;
456  pango_attr_list_insert(retv, pa);
457  }
458  if (th.style & ROFI_HL_SMALL_CAPS) {
459  PangoAttribute *pa =
460  pango_attr_variant_new(PANGO_VARIANT_SMALL_CAPS);
461  pa->start_index = start;
462  pa->end_index = end;
463  pango_attr_list_insert(retv, pa);
464  }
465  if (th.style & ROFI_HL_ITALIC) {
466  PangoAttribute *pa = pango_attr_style_new(PANGO_STYLE_ITALIC);
467  pa->start_index = start;
468  pa->end_index = end;
469  pango_attr_list_insert(retv, pa);
470  }
471  if (th.style & ROFI_HL_COLOR) {
472  PangoAttribute *pa = pango_attr_foreground_new(
473  th.color.red * 65535, th.color.green * 65535,
474  th.color.blue * 65535);
475  pa->start_index = start;
476  pa->end_index = end;
477  pango_attr_list_insert(retv, pa);
478 
479  if (th.color.alpha < 1.0) {
480  pa = pango_attr_foreground_alpha_new(th.color.alpha * 65535);
481  pa->start_index = start;
482  pa->end_index = end;
483  pango_attr_list_insert(retv, pa);
484  }
485  }
486  }
487  g_match_info_next(gmi, NULL);
488  }
489  g_match_info_free(gmi);
490  }
491  }
492  return retv;
493 }
494 
495 int helper_token_match(rofi_int_matcher *const *tokens, const char *input) {
496  int match = TRUE;
497  // Do a tokenized match.
498  if (tokens) {
499  if (config.normalize_match) {
500  char *r = utf8_helper_simplify_string(input);
501  for (int j = 0; match && tokens[j]; j++) {
502  match = g_regex_match(tokens[j]->regex, r, 0, NULL);
503  match ^= tokens[j]->invert;
504  }
505  g_free(r);
506  } else {
507  for (int j = 0; match && tokens[j]; j++) {
508  match = g_regex_match(tokens[j]->regex, input, 0, NULL);
509  match ^= tokens[j]->invert;
510  }
511  }
512  }
513  return match;
514 }
515 
516 int execute_generator(const char *cmd) {
517  char **args = NULL;
518  int argv = 0;
519  helper_parse_setup(config.run_command, &args, &argv, "{cmd}", cmd, (char *)0);
520 
521  int fd = -1;
522  GError *error = NULL;
523  g_spawn_async_with_pipes(NULL, args, NULL, G_SPAWN_SEARCH_PATH, NULL, NULL,
524  NULL, NULL, &fd, NULL, &error);
525 
526  if (error != NULL) {
527  char *msg = g_strdup_printf("Failed to execute: '%s'\nError: '%s'", cmd,
528  error->message);
529  rofi_view_error_dialog(msg, FALSE);
530  g_free(msg);
531  // print error.
532  g_error_free(error);
533  fd = -1;
534  }
535  g_strfreev(args);
536  return fd;
537 }
538 
539 int create_pid_file(const char *pidfile, gboolean kill_running) {
540  if (pidfile == NULL) {
541  return -1;
542  }
543 
544  int fd = g_open(pidfile, O_RDWR | O_CREAT, S_IRUSR | S_IWUSR);
545  if (fd < 0) {
546  g_warning("Failed to create pid file: '%s'.", pidfile);
547  return -1;
548  }
549  // Set it to close the File Descriptor on exit.
550  int flags = fcntl(fd, F_GETFD, NULL);
551  flags = flags | FD_CLOEXEC;
552  if (fcntl(fd, F_SETFD, flags, NULL) < 0) {
553  g_warning("Failed to set CLOEXEC on pidfile.");
554  remove_pid_file(fd);
555  return -1;
556  }
557  // Try to get exclusive write lock on FD
558  int retv = flock(fd, LOCK_EX | LOCK_NB);
559  if (retv != 0) {
560  g_warning("Failed to set lock on pidfile: Rofi already running?");
561  g_warning("Got error: %d %s", retv, g_strerror(errno));
562  if (kill_running) {
563  char buffer[64] = {
564  0,
565  };
566  ssize_t l = read(fd, &buffer, 64);
567  if (l > 1) {
568  pid_t pid = g_ascii_strtoll(buffer, NULL, 0);
569  kill(pid, SIGTERM);
570  while (1) {
571  retv = flock(fd, LOCK_EX | LOCK_NB);
572  if (retv == 0) {
573  break;
574  }
575  g_usleep(100);
576  }
577  }
578  remove_pid_file(fd);
579  return create_pid_file(pidfile, FALSE);
580  }
581 
582  remove_pid_file(fd);
583  return -1;
584  }
585  if (ftruncate(fd, (off_t)0) == 0) {
586  // Write pid, not needed, but for completeness sake.
587  char buffer[64];
588  int length = snprintf(buffer, 64, "%i", getpid());
589  ssize_t l = 0;
590  while (l < length) {
591  l += write(fd, &buffer[l], length - l);
592  }
593  }
594  return fd;
595 }
596 
597 void remove_pid_file(int fd) {
598  if (fd >= 0) {
599  if (close(fd)) {
600  g_warning("Failed to close pidfile: '%s'", g_strerror(errno));
601  }
602  }
603 }
604 
605 gboolean helper_validate_font(PangoFontDescription *pfd, const char *font) {
606  const char *fam = pango_font_description_get_family(pfd);
607  int size = pango_font_description_get_size(pfd);
608  if (fam == NULL || size == 0) {
609  g_debug("Pango failed to parse font: '%s'", font);
610  g_debug("Got family: <b>%s</b> at size: <b>%d</b>", fam ? fam : "{unknown}",
611  size);
612  return FALSE;
613  }
614  return TRUE;
615 }
616 
625  int found_error = FALSE;
626  GString *msg =
627  g_string_new("<big><b>The configuration failed to validate:</b></big>\n");
628 
629  if (config.sorting_method) {
630  if (g_strcmp0(config.sorting_method, "normal") == 0) {
632  } else if (g_strcmp0(config.sorting_method, "levenshtein") == 0) {
634  } else if (g_strcmp0(config.sorting_method, "fzf") == 0) {
636  } else {
637  g_string_append_printf(
638  msg,
639  "\t<b>config.sorting_method</b>=%s is not a valid sorting "
640  "strategy.\nValid options are: normal or fzf.\n",
642  found_error = 1;
643  }
644  }
645 
646  if (config.matching) {
647  if (g_strcmp0(config.matching, "regex") == 0) {
649  } else if (g_strcmp0(config.matching, "glob") == 0) {
651  } else if (g_strcmp0(config.matching, "fuzzy") == 0) {
653  } else if (g_strcmp0(config.matching, "normal") == 0) {
655  ;
656  } else if (g_strcmp0(config.matching, "prefix") == 0) {
658  } else {
659  g_string_append_printf(msg,
660  "\t<b>config.matching</b>=%s is not a valid "
661  "matching strategy.\nValid options are: glob, "
662  "regex, fuzzy, prefix or normal.\n",
663  config.matching);
664  found_error = 1;
665  }
666  }
667 
668  if (config.element_height < 1) {
669  g_string_append_printf(msg,
670  "\t<b>config.element_height</b>=%d is invalid. An "
671  "element needs to be at least 1 line high.\n",
674  found_error = TRUE;
675  }
676  if (!(config.location >= 0 && config.location <= 8)) {
677  g_string_append_printf(msg,
678  "\t<b>config.location</b>=%d is invalid. Value "
679  "should be between %d and %d.\n",
680  config.location, 0, 8);
682  found_error = 1;
683  }
684 
685  // Check size
686  {
687  workarea mon;
688  if (!monitor_active(&mon)) {
689  const char *name = config.monitor;
690  if (name && name[0] == '-') {
691  int index = name[1] - '0';
692  if (index < 5 && index > 0) {
693  name = monitor_position_entries[index - 1];
694  }
695  }
696  g_string_append_printf(
697  msg, "\t<b>config.monitor</b>=%s Could not find monitor.\n", name);
698  found_error = TRUE;
699  }
700  }
701 
702  if (g_strcmp0(config.monitor, "-3") == 0) {
703  // On -3, set to location 1.
704  config.location = 1;
705  }
706 
707  if (found_error) {
708  g_string_append(msg, "Please update your configuration.");
710  return TRUE;
711  }
712 
713  g_string_free(msg, TRUE);
714  return FALSE;
715 }
716 
717 char *rofi_expand_path(const char *input) {
718  char **str = g_strsplit(input, G_DIR_SEPARATOR_S, -1);
719  for (unsigned int i = 0; str && str[i]; i++) {
720  // Replace ~ with current user homedir.
721  if (str[i][0] == '~' && str[i][1] == '\0') {
722  g_free(str[i]);
723  str[i] = g_strdup(g_get_home_dir());
724  }
725  // If other user, ask getpwnam.
726  else if (str[i][0] == '~') {
727  struct passwd *p = getpwnam(&(str[i][1]));
728  if (p != NULL) {
729  g_free(str[i]);
730  str[i] = g_strdup(p->pw_dir);
731  }
732  } else if (i == 0) {
733  char *s = str[i];
734  if (input[0] == G_DIR_SEPARATOR) {
735  str[i] = g_strdup_printf("%s%s", G_DIR_SEPARATOR_S, s);
736  g_free(s);
737  }
738  }
739  }
740  char *retv = g_build_filenamev(str);
741  g_strfreev(str);
742  return retv;
743 }
744 
746 #define MIN3(a, b, c) \
747  ((a) < (b) ? ((a) < (c) ? (a) : (c)) : ((b) < (c) ? (b) : (c)))
748 
749 unsigned int levenshtein(const char *needle, const glong needlelen,
750  const char *haystack, const glong haystacklen) {
751  if (needlelen == G_MAXLONG) {
752  // String to long, we cannot handle this.
753  return UINT_MAX;
754  }
755  unsigned int column[needlelen + 1];
756  for (glong y = 0; y < needlelen; y++) {
757  column[y] = y;
758  }
759  // Removed out of the loop, otherwise static code analyzers think it is
760  // unset.. silly but true. old loop: for ( glong y = 0; y <= needlelen; y++)
761  column[needlelen] = needlelen;
762  for (glong x = 1; x <= haystacklen; x++) {
763  const char *needles = needle;
764  column[0] = x;
765  gunichar haystackc = g_utf8_get_char(haystack);
766  if (!config.case_sensitive) {
767  haystackc = g_unichar_tolower(haystackc);
768  }
769  for (glong y = 1, lastdiag = x - 1; y <= needlelen; y++) {
770  gunichar needlec = g_utf8_get_char(needles);
771  if (!config.case_sensitive) {
772  needlec = g_unichar_tolower(needlec);
773  }
774  unsigned int olddiag = column[y];
775  column[y] = MIN3(column[y] + 1, column[y - 1] + 1,
776  lastdiag + (needlec == haystackc ? 0 : 1));
777  lastdiag = olddiag;
778  needles = g_utf8_next_char(needles);
779  }
780  haystack = g_utf8_next_char(haystack);
781  }
782  return column[needlelen];
783 }
784 
785 char *rofi_latin_to_utf8_strdup(const char *input, gssize length) {
786  gsize slength = 0;
787  return g_convert_with_fallback(input, length, "UTF-8", "latin1", "\uFFFD",
788  NULL, &slength, NULL);
789 }
790 
791 char *rofi_force_utf8(const gchar *data, ssize_t length) {
792  if (data == NULL) {
793  return NULL;
794  }
795  const char *end;
796  GString *string;
797 
798  if (g_utf8_validate(data, length, &end)) {
799  return g_memdup(data, length + 1);
800  }
801  string = g_string_sized_new(length + 16);
802 
803  do {
804  /* Valid part of the string */
805  g_string_append_len(string, data, end - data);
806  /* Replacement character */
807  g_string_append(string, "\uFFFD");
808  length -= (end - data) + 1;
809  data = end + 1;
810  } while (!g_utf8_validate(data, length, &end));
811 
812  if (length) {
813  g_string_append_len(string, data, length);
814  }
815 
816  return g_string_free(string, FALSE);
817 }
818 
819 /****
820  * FZF like scorer
821  */
822 
824 #define FUZZY_SCORER_MAX_LENGTH 256
826 #define MIN_SCORE (INT_MIN / 2)
828 #define LEADING_GAP_SCORE -4
830 #define GAP_SCORE -5
832 #define WORD_START_SCORE 50
834 #define NON_WORD_SCORE 40
836 #define CAMEL_SCORE (WORD_START_SCORE + GAP_SCORE - 1)
838 #define CONSECUTIVE_SCORE (WORD_START_SCORE + GAP_SCORE)
840 #define PATTERN_NON_START_MULTIPLIER 1
842 #define PATTERN_START_MULTIPLIER 2
843 
847 enum CharClass {
848  /* Lower case */
850  /* Upper case */
852  /* Number */
854  /* non word character */
855  NON_WORD
856 };
857 
863 static enum CharClass rofi_scorer_get_character_class(gunichar c) {
864  if (g_unichar_islower(c)) {
865  return LOWER;
866  }
867  if (g_unichar_isupper(c)) {
868  return UPPER;
869  }
870  if (g_unichar_isdigit(c)) {
871  return DIGIT;
872  }
873  return NON_WORD;
874 }
875 
884 static int rofi_scorer_get_score_for(enum CharClass prev, enum CharClass curr) {
885  if (prev == NON_WORD && curr != NON_WORD) {
886  return WORD_START_SCORE;
887  }
888  if ((prev == LOWER && curr == UPPER) || (prev != DIGIT && curr == DIGIT)) {
889  return CAMEL_SCORE;
890  }
891  if (curr == NON_WORD) {
892  return NON_WORD_SCORE;
893  }
894  return 0;
895 }
896 
897 int rofi_scorer_fuzzy_evaluate(const char *pattern, glong plen, const char *str,
898  glong slen) {
899  if (slen > FUZZY_SCORER_MAX_LENGTH) {
900  return -MIN_SCORE;
901  }
902  glong pi, si;
903  // whether we are aligning the first character of pattern
904  gboolean pfirst = TRUE;
905  // whether the start of a word in pattern
906  gboolean pstart = TRUE;
907  // score for each position
908  int *score = g_malloc_n(slen, sizeof(int));
909  // dp[i]: maximum value by aligning pattern[0..pi] to str[0..si]
910  int *dp = g_malloc_n(slen, sizeof(int));
911  // uleft: value of the upper left cell; ulefts: maximum value of uleft and
912  // cells on the left. The arbitrary initial values suppress warnings.
913  int uleft = 0, ulefts = 0, left, lefts;
914  const gchar *pit = pattern, *sit;
915  enum CharClass prev = NON_WORD;
916  for (si = 0, sit = str; si < slen; si++, sit = g_utf8_next_char(sit)) {
917  enum CharClass cur = rofi_scorer_get_character_class(g_utf8_get_char(sit));
918  score[si] = rofi_scorer_get_score_for(prev, cur);
919  prev = cur;
920  dp[si] = MIN_SCORE;
921  }
922  for (pi = 0; pi < plen; pi++, pit = g_utf8_next_char(pit)) {
923  gunichar pc = g_utf8_get_char(pit), sc;
924  if (g_unichar_isspace(pc)) {
925  pstart = TRUE;
926  continue;
927  }
928  lefts = MIN_SCORE;
929  for (si = 0, sit = str; si < slen; si++, sit = g_utf8_next_char(sit)) {
930  left = dp[si];
931  lefts = MAX(lefts + GAP_SCORE, left);
932  sc = g_utf8_get_char(sit);
934  ? pc == sc
935  : g_unichar_tolower(pc) == g_unichar_tolower(sc)) {
936  int t = score[si] * (pstart ? PATTERN_START_MULTIPLIER
938  dp[si] = pfirst ? LEADING_GAP_SCORE * si + t
939  : MAX(uleft + CONSECUTIVE_SCORE, ulefts + t);
940  } else {
941  dp[si] = MIN_SCORE;
942  }
943  uleft = left;
944  ulefts = lefts;
945  }
946  pfirst = pstart = FALSE;
947  }
948  lefts = MIN_SCORE;
949  for (si = 0; si < slen; si++) {
950  lefts = MAX(lefts + GAP_SCORE, dp[si]);
951  }
952  g_free(score);
953  g_free(dp);
954  return -lefts;
955 }
956 
968 int utf8_strncmp(const char *a, const char *b, size_t n) {
969  char *na = g_utf8_normalize(a, -1, G_NORMALIZE_ALL_COMPOSE);
970  char *nb = g_utf8_normalize(b, -1, G_NORMALIZE_ALL_COMPOSE);
971  *g_utf8_offset_to_pointer(na, n) = '\0';
972  *g_utf8_offset_to_pointer(nb, n) = '\0';
973  int r = g_utf8_collate(na, nb);
974  g_free(na);
975  g_free(nb);
976  return r;
977 }
978 
979 gboolean helper_execute(const char *wd, char **args, const char *error_precmd,
980  const char *error_cmd,
981  RofiHelperExecuteContext *context) {
982  gboolean retv = TRUE;
983  GError *error = NULL;
984 
985  GSpawnChildSetupFunc child_setup = NULL;
986  gpointer user_data = NULL;
987 
988  display_startup_notification(context, &child_setup, &user_data);
989 
990  g_spawn_async(wd, args, NULL, G_SPAWN_SEARCH_PATH, child_setup, user_data,
991  NULL, &error);
992  if (error != NULL) {
993  char *msg = g_strdup_printf("Failed to execute: '%s%s'\nError: '%s'",
994  error_precmd, error_cmd, error->message);
995  rofi_view_error_dialog(msg, FALSE);
996  g_free(msg);
997  // print error.
998  g_error_free(error);
999  retv = FALSE;
1000  }
1001 
1002  // Free the args list.
1003  g_strfreev(args);
1004  return retv;
1005 }
1006 
1007 gboolean helper_execute_command(const char *wd, const char *cmd,
1008  gboolean run_in_term,
1009  RofiHelperExecuteContext *context) {
1010  char **args = NULL;
1011  int argc = 0;
1012 
1013  if (run_in_term) {
1014  helper_parse_setup(config.run_shell_command, &args, &argc, "{cmd}", cmd,
1015  (char *)0);
1016  } else {
1017  helper_parse_setup(config.run_command, &args, &argc, "{cmd}", cmd,
1018  (char *)0);
1019  }
1020 
1021  if (args == NULL) {
1022  return FALSE;
1023  }
1024 
1025  if (context != NULL) {
1026  if (context->name == NULL) {
1027  context->name = args[0];
1028  }
1029  if (context->binary == NULL) {
1030  context->binary = args[0];
1031  }
1032  if (context->description == NULL) {
1033  gsize l = strlen("Launching '' via rofi") + strlen(cmd) + 1;
1034  gchar *description = g_newa(gchar, l);
1035 
1036  g_snprintf(description, l, "Launching '%s' via rofi", cmd);
1037  context->description = description;
1038  }
1039  if (context->command == NULL) {
1040  context->command = cmd;
1041  }
1042  }
1043 
1044  return helper_execute(wd, args, "", cmd, context);
1045 }
1046 
1047 char *helper_get_theme_path(const char *file, const char *ext) {
1048  char *filename = rofi_expand_path(file);
1049  g_debug("Opening theme, testing: %s\n", filename);
1050  if (g_file_test(filename, G_FILE_TEST_EXISTS)) {
1051  return filename;
1052  }
1053  g_free(filename);
1054 
1055  if (g_str_has_suffix(file, ext)) {
1056  filename = g_strdup(file);
1057  } else {
1058  filename = g_strconcat(file, ext, NULL);
1059  }
1060  // Check config's themes directory.
1061  const char *cpath = g_get_user_config_dir();
1062  if (cpath) {
1063  char *themep = g_build_filename(cpath, "rofi", "themes", filename, NULL);
1064  g_debug("Opening theme, testing: %s\n", themep);
1065  if (themep && g_file_test(themep, G_FILE_TEST_EXISTS)) {
1066  g_free(filename);
1067  return themep;
1068  }
1069  g_free(themep);
1070  }
1071  // Check config directory.
1072  if (cpath) {
1073  char *themep = g_build_filename(cpath, "rofi", filename, NULL);
1074  g_debug("Opening theme, testing: %s\n", themep);
1075  if (g_file_test(themep, G_FILE_TEST_EXISTS)) {
1076  g_free(filename);
1077  return themep;
1078  }
1079  g_free(themep);
1080  }
1081  const char *datadir = g_get_user_data_dir();
1082  if (datadir) {
1083  char *theme_path =
1084  g_build_filename(datadir, "rofi", "themes", filename, NULL);
1085  g_debug("Opening theme, testing: %s\n", theme_path);
1086  if (theme_path) {
1087  if (g_file_test(theme_path, G_FILE_TEST_EXISTS)) {
1088  g_free(filename);
1089  return theme_path;
1090  }
1091  g_free(theme_path);
1092  }
1093  }
1094 
1095  char *theme_path = g_build_filename(THEME_DIR, filename, NULL);
1096  if (theme_path) {
1097  g_debug("Opening theme, testing: %s\n", theme_path);
1098  if (g_file_test(theme_path, G_FILE_TEST_EXISTS)) {
1099  g_free(filename);
1100  return theme_path;
1101  }
1102  g_free(theme_path);
1103  }
1104  return filename;
1105 }
1106 
1107 static gboolean parse_pair(char *input, rofi_range_pair *item) {
1108  // Skip leading blanks.
1109  while (input != NULL && isblank(*input)) {
1110  ++input;
1111  }
1112 
1113  if (input == NULL) {
1114  return FALSE;
1115  }
1116 
1117  const char *sep[] = {"-", ":"};
1118  int pythonic = (strchr(input, ':') || input[0] == '-') ? 1 : 0;
1119  int index = 0;
1120 
1121  for (char *token = strsep(&input, sep[pythonic]); token != NULL;
1122  token = strsep(&input, sep[pythonic])) {
1123  if (index == 0) {
1124  item->start = item->stop = (int)strtol(token, NULL, 10);
1125  index++;
1126  continue;
1127  }
1128 
1129  if (token[0] == '\0') {
1130  item->stop = -1;
1131  continue;
1132  }
1133 
1134  item->stop = (int)strtol(token, NULL, 10);
1135  if (pythonic) {
1136  --item->stop;
1137  }
1138  }
1139  return TRUE;
1140 }
1141 void parse_ranges(char *input, rofi_range_pair **list, unsigned int *length) {
1142  char *endp;
1143  if (input == NULL) {
1144  return;
1145  }
1146  const char *const sep = ",";
1147  for (char *token = strtok_r(input, sep, &endp); token != NULL;
1148  token = strtok_r(NULL, sep, &endp)) {
1149  // Make space.
1150  *list =
1151  g_realloc((*list), ((*length) + 1) * sizeof(struct rofi_range_pair));
1152  // Parse a single pair.
1153  if (parse_pair(token, &((*list)[*length]))) {
1154  (*length)++;
1155  }
1156  }
1157 }
1158 void rofi_output_formatted_line(const char *format, const char *string,
1159  int selected_line, const char *filter) {
1160  for (int i = 0; format && format[i]; i++) {
1161  if (format[i] == 'i') {
1162  fprintf(stdout, "%d", selected_line);
1163  } else if (format[i] == 'd') {
1164  fprintf(stdout, "%d", (selected_line + 1));
1165  } else if (format[i] == 's') {
1166  fputs(string, stdout);
1167  } else if (format[i] == 'p') {
1168  char *esc = NULL;
1169  pango_parse_markup(string, -1, 0, NULL, &esc, NULL, NULL);
1170  if (esc) {
1171  fputs(esc, stdout);
1172  g_free(esc);
1173  } else {
1174  fputs("invalid string", stdout);
1175  }
1176  } else if (format[i] == 'q') {
1177  char *quote = g_shell_quote(string);
1178  fputs(quote, stdout);
1179  g_free(quote);
1180  } else if (format[i] == 'f') {
1181  if (filter) {
1182  fputs(filter, stdout);
1183  }
1184  } else if (format[i] == 'F') {
1185  if (filter) {
1186  char *quote = g_shell_quote(filter);
1187  fputs(quote, stdout);
1188  g_free(quote);
1189  }
1190  } else {
1191  fputc(format[i], stdout);
1192  }
1193  }
1194  fputc('\n', stdout);
1195  fflush(stdout);
1196 }
1197 
1198 static gboolean helper_eval_cb2(const GMatchInfo *info, GString *res,
1199  gpointer data) {
1200  gchar *match;
1201  // Get the match
1202  int num_match = g_match_info_get_match_count(info);
1203  // Just {text} This is inside () 5.
1204  if (num_match == 5) {
1205  match = g_match_info_fetch(info, 4);
1206  if (match != NULL) {
1207  // Lookup the match, so we can replace it.
1208  gchar *r = g_hash_table_lookup((GHashTable *)data, match);
1209  if (r != NULL) {
1210  // Append the replacement to the string.
1211  g_string_append(res, r);
1212  }
1213  // Free match.
1214  g_free(match);
1215  }
1216  }
1217  // {} with [] guard around it.
1218  else if (num_match == 4) {
1219  match = g_match_info_fetch(info, 2);
1220  if (match != NULL) {
1221  // Lookup the match, so we can replace it.
1222  gchar *r = g_hash_table_lookup((GHashTable *)data, match);
1223  if (r != NULL) {
1224  // Add (optional) prefix
1225  gchar *prefix = g_match_info_fetch(info, 1);
1226  g_string_append(res, prefix);
1227  g_free(prefix);
1228  // Append the replacement to the string.
1229  g_string_append(res, r);
1230  // Add (optional) postfix
1231  gchar *post = g_match_info_fetch(info, 3);
1232  g_string_append(res, post);
1233  g_free(post);
1234  }
1235  // Free match.
1236  g_free(match);
1237  }
1238  }
1239  // Else we have an invalid match.
1240  // Continue replacement.
1241  return FALSE;
1242 }
1243 
1244 char *helper_string_replace_if_exists(char *string, ...) {
1245  GHashTable *h;
1246  h = g_hash_table_new(g_str_hash, g_str_equal);
1247  va_list ap;
1248  va_start(ap, string);
1249  // Add list from variable arguments.
1250  while (1) {
1251  char *key = va_arg(ap, char *);
1252  if (key == (char *)0) {
1253  break;
1254  }
1255  char *value = va_arg(ap, char *);
1256  g_hash_table_insert(h, key, value);
1257  }
1258  char *retv = helper_string_replace_if_exists_v(string, h);
1259  va_end(ap);
1260  // Destroy key-value storage.
1261  g_hash_table_destroy(h);
1262  return retv;
1263 }
1279 char *helper_string_replace_if_exists_v(char *string, GHashTable *h) {
1280  GError *error = NULL;
1281  char *res = NULL;
1282 
1283  // Replace hits within {-\w+}.
1284  GRegex *reg = g_regex_new("\\[(.*)({[-\\w]+})(.*)\\]|({[\\w-]+})",
1285  G_REGEX_UNGREEDY, 0, &error);
1286  if (error == NULL) {
1287  res =
1288  g_regex_replace_eval(reg, string, -1, 0, 0, helper_eval_cb2, h, &error);
1289  }
1290  // Free regex.
1291  g_regex_unref(reg);
1292  // Throw error if shell parsing fails.
1293  if (error != NULL) {
1294  char *msg = g_strdup_printf("Failed to parse: '%s'\nError: '%s'", string,
1295  error->message);
1296  rofi_view_error_dialog(msg, FALSE);
1297  g_free(msg);
1298  // print error.
1299  g_error_free(error);
1300  g_free(res);
1301  return NULL;
1302  }
1303  return res;
1304 }
@ WL_CENTER
Definition: rofi-types.h:233
@ MM_NORMAL
Definition: settings.h:39
@ MM_REGEX
Definition: settings.h:40
@ MM_PREFIX
Definition: settings.h:43
@ MM_FUZZY
Definition: settings.h:42
@ MM_GLOB
Definition: settings.h:41
PangoAttrList * helper_token_match_get_pango_attr(RofiHighlightColorStyle th, rofi_int_matcher **tokens, const char *input, PangoAttrList *retv)
Definition: helper.c:418
gboolean helper_validate_font(PangoFontDescription *pfd, const char *font)
Definition: helper.c:605
void parse_ranges(char *input, rofi_range_pair **list, unsigned int *length)
Definition: helper.c:1141
void cmd_set_arguments(int argc, char **argv)
Definition: helper.c:70
int find_arg_char(const char *const key, char *val)
Definition: helper.c:408
gboolean helper_execute_command(const char *wd, const char *cmd, gboolean run_in_term, RofiHelperExecuteContext *context)
Definition: helper.c:1007
void helper_tokenize_free(rofi_int_matcher **tokens)
Definition: helper.c:119
char helper_parse_char(const char *arg)
Definition: helper.c:360
void rofi_output_formatted_line(const char *format, const char *string, int selected_line, const char *filter)
Definition: helper.c:1158
gboolean helper_execute(const char *wd, char **args, const char *error_precmd, const char *error_cmd, RofiHelperExecuteContext *context)
Definition: helper.c:979
unsigned int levenshtein(const char *needle, const glong needlelen, const char *haystack, const glong haystacklen)
Definition: helper.c:749
char * rofi_latin_to_utf8_strdup(const char *input, gssize length)
Definition: helper.c:785
const char ** find_arg_strv(const char *const key)
Definition: helper.c:321
int helper_parse_setup(char *string, char ***output, int *length,...)
Definition: helper.c:75
int execute_generator(const char *cmd)
Definition: helper.c:516
int find_arg_int(const char *const key, int *val)
Definition: helper.c:341
void remove_pid_file(int fd)
Definition: helper.c:597
int rofi_scorer_fuzzy_evaluate(const char *pattern, glong plen, const char *str, glong slen)
Definition: helper.c:897
char * rofi_expand_path(const char *input)
Definition: helper.c:717
int find_arg_str(const char *const key, char **val)
Definition: helper.c:311
rofi_int_matcher ** helper_tokenize(const char *input, int case_sensitive)
Definition: helper.c:263
char * helper_get_theme_path(const char *file, const char *ext)
Definition: helper.c:1047
int find_arg_uint(const char *const key, unsigned int *val)
Definition: helper.c:350
char * helper_string_replace_if_exists(char *string,...)
Definition: helper.c:1244
int find_arg(const char *const key)
Definition: helper.c:302
int helper_token_match(rofi_int_matcher *const *tokens, const char *input)
Definition: helper.c:495
int config_sanity_check(void)
Definition: helper.c:624
int create_pid_file(const char *pidfile, gboolean kill_running)
Definition: helper.c:539
char * rofi_force_utf8(const gchar *data, ssize_t length)
Definition: helper.c:791
void rofi_add_error_message(GString *str)
Definition: rofi.c:89
int rofi_view_error_dialog(const char *msg, int markup)
Definition: view.c:2077
#define CONSECUTIVE_SCORE
Definition: helper.c:838
#define GAP_SCORE
Definition: helper.c:830
#define LEADING_GAP_SCORE
Definition: helper.c:828
char ** stored_argv
Definition: helper.c:66
#define MIN3(a, b, c)
Definition: helper.c:746
#define CAMEL_SCORE
Definition: helper.c:836
const char *const monitor_position_entries[]
Definition: helper.c:60
static char * utf8_helper_simplify_string(const char *s)
Definition: helper.c:178
static enum CharClass rofi_scorer_get_character_class(gunichar c)
Definition: helper.c:863
int utf8_strncmp(const char *a, const char *b, size_t n)
Definition: helper.c:968
static gchar * glob_to_regex(const char *input)
Definition: helper.c:127
#define MIN_SCORE
Definition: helper.c:826
#define PATTERN_NON_START_MULTIPLIER
Definition: helper.c:840
char * helper_string_replace_if_exists_v(char *string, GHashTable *h)
Definition: helper.c:1279
#define WORD_START_SCORE
Definition: helper.c:832
#define FUZZY_SCORER_MAX_LENGTH
Definition: helper.c:824
static gboolean helper_eval_cb2(const GMatchInfo *info, GString *res, gpointer data)
Definition: helper.c:1198
#define PATTERN_START_MULTIPLIER
Definition: helper.c:842
static rofi_int_matcher * create_regex(const char *input, int case_sensitive)
Definition: helper.c:222
#define NON_WORD_SCORE
Definition: helper.c:834
static gchar * prefix_regex(const char *input)
Definition: helper.c:171
static GRegex * R(const char *s, int case_sensitive)
Definition: helper.c:207
CharClass
Definition: helper.c:847
@ DIGIT
Definition: helper.c:853
@ LOWER
Definition: helper.c:849
@ NON_WORD
Definition: helper.c:855
@ UPPER
Definition: helper.c:851
static gchar * fuzzy_to_regex(const char *input)
Definition: helper.c:142
int stored_argc
Definition: helper.c:64
static gboolean parse_pair(char *input, rofi_range_pair *item)
Definition: helper.c:1107
static int rofi_scorer_get_score_for(enum CharClass prev, enum CharClass curr)
Definition: helper.c:884
@ ROFI_HL_STRIKETHROUGH
Definition: rofi-types.h:60
@ ROFI_HL_SMALL_CAPS
Definition: rofi-types.h:62
@ ROFI_HL_ITALIC
Definition: rofi-types.h:64
@ ROFI_HL_UNDERLINE
Definition: rofi-types.h:58
@ ROFI_HL_BOLD
Definition: rofi-types.h:56
@ ROFI_HL_COLOR
Definition: rofi-types.h:66
char * pidfile
Definition: rofi.c:81
Settings config
@ SORT_FZF
Definition: settings.h:49
@ SORT_NORMAL
Definition: settings.h:49
const gchar * binary
Definition: helper.h:290
const gchar * description
Definition: helper.h:292
const gchar * name
Definition: helper.h:288
const gchar * command
Definition: helper.h:300
RofiHighlightStyle style
Definition: rofi-types.h:217
WindowLocation location
Definition: settings.h:84
char * matching
Definition: settings.h:133
MatchingMethod matching_method
Definition: settings.h:134
unsigned int tokenize
Definition: settings.h:135
char * run_command
Definition: settings.h:71
gboolean normalize_match
Definition: settings.h:175
char * terminal_emulator
Definition: settings.h:65
char * run_shell_command
Definition: settings.h:73
unsigned int case_sensitive
Definition: settings.h:114
char * sorting_method
Definition: settings.h:100
char matching_negate_char
Definition: settings.h:160
SortingMethod sorting_method_enum
Definition: settings.h:98
char * ssh_client
Definition: settings.h:67
int element_height
Definition: settings.h:118
char * monitor
Definition: settings.h:137
double blue
Definition: rofi-types.h:160
double green
Definition: rofi-types.h:158
double red
Definition: rofi-types.h:156
double alpha
Definition: rofi-types.h:162
Definition: xcb.h:94
workarea mon
Definition: view.c:111
MenuFlags flags
Definition: view.c:107
unsigned long long count
Definition: view.c:117
int monitor_active(workarea *mon)
Definition: xcb.c:973
void display_startup_notification(RofiHelperExecuteContext *context, GSpawnChildSetupFunc *child_setup, gpointer *user_data)
Definition: xcb.c:692