main.c
This file
Path
main.c
2,452 lines · 90.1 KiB · C
Last changed by
cache: fix incorrect cache write error messageNicholas Rodrigues Lordellobefore adoptionb320e2f
History of this fileTake it
The walk stopped after 200 commits: lines older than 6a4c416 point at it.
changelog: add missing refDaniel Eklöfbefore adoption6a4c416
lines 1–17why, one step back1#include <stdlib.h>2#include <stdio.h>3#include <stdbool.h>4#include <string.h>5#include <getopt.h>6#include <errno.h>7#include <threads.h>89#include <locale.h>10#include <libgen.h>1112#include <sys/types.h>13#include <sys/mman.h>14#include <sys/stat.h>15#include <sys/file.h>16#include <sys/epoll.h>17#include <sys/eventfd.h>debug: add a --print-timing-info command line optionDaniel Eklöfbefore adoption1ea01b1
line 18why, one step back18#include <sys/time.h>changelog: add missing refDaniel Eklöfbefore adoption6a4c416
lines 19–44why, one step back19#include <fcntl.h>20#include <dirent.h>2122#include <tllist.h>23#include <fcft/fcft.h>2425#define LOG_MODULE "fuzzel"26#define LOG_ENABLE_DBG 027#include "log.h"28#include "application.h"29#include "char32.h"30#include "config.h"31#include "dmenu.h"32#include "event.h"33#include "fdm.h"34#include "key-binding.h"35#include "match.h"36#include "path.h"37#include "render.h"38#include "shm.h"39#include "version.h"40#include "wayland.h"41#include "xdg.h"42#include "xmalloc.h"43#include "xsnprintf.h"44timing: new minimal timing frameworkDaniel Eklöfbefore adoption0221d35
lines 45–46why, one step back45#include "timing.h"46changelog: add missing refDaniel Eklöfbefore adoption6a4c416
line 47why, one step back47#define max(x, y) ((x) > (y) ? (x) : (y))Add new --minimal-flag optionMark Stosbergbefore adoption6200008
line 48why, one step back48#define min(x, y) ((x) < (y) ? (x) : (y))changelog: add missing refDaniel Eklöfbefore adoption6a4c416
lines 49–50why, one step back4950struct context {Add new --minimal-flag optionMark Stosbergbefore adoption6200008
line 51why, one step back51 struct config *conf;changelog: add missing refDaniel Eklöfbefore adoption6a4c416
lines 52–66why, one step back52 const char *cache_path;53 struct wayland *wayl;54 struct render *render;55 struct matches *matches;56 struct application_list *apps;5758 icon_theme_list_t *themes;59 int icon_size;60 mtx_t *icon_lock;6162 const char *select_initial;63 const size_t select_initial_idx;6465 int event_fd;66 int dmenu_abort_fd;debug: add a --print-timing-info command line optionDaniel Eklöfbefore adoption1ea01b1
lines 67–69why, one step back6768 struct {69 struct {timing: rename time_end() -> time_finish()Daniel Eklöfbefore adoptiond226f7f
lines 70–71why, one step back70 struct timespec *start;71 struct timespec *stop;debug: add a --print-timing-info command line optionDaniel Eklöfbefore adoption1ea01b1
lines 72–73why, one step back72 } apps;73 struct {timing: rename time_end() -> time_finish()Daniel Eklöfbefore adoptiond226f7f
lines 74–75why, one step back74 struct timespec *start;75 struct timespec *stop;debug: add a --print-timing-info command line optionDaniel Eklöfbefore adoption1ea01b1
lines 76–77why, one step back76 } icons_theme;77 struct {timing: rename time_end() -> time_finish()Daniel Eklöfbefore adoptiond226f7f
lines 78–79why, one step back78 struct timespec *start;79 struct timespec *stop;debug: add a --print-timing-info command line optionDaniel Eklöfbefore adoption1ea01b1
lines 80–81why, one step back80 } icons;81 } timing;changelog: add missing refDaniel Eklöfbefore adoption6a4c416
lines 82–107why, one step back82};8384struct cache_entry {85 char *id;86 char32_t *title;87 size_t count;88};8990static void91read_cache(const char *path, struct application_list *apps, bool dmenu)92{93 if (path == NULL && dmenu) {94 /* Don't thrash "normal" cache in dmenu mode */95 return;96 }9798 struct stat st;99 FILE *f = NULL;100101 if (path == NULL) {102 path = xdg_cache_dir();103 if (path == NULL) {104 LOG_WARN("failed to get cache directory: not saving popularity cache");105 return;106 }107main: open all FDs with O_CLOEXECDaniel Eklöfbefore adoptione7d074c
line 108why, one step back108 int cache_dir_fd = open(path, O_DIRECTORY | O_CLOEXEC);changelog: add missing refDaniel Eklöfbefore adoption6a4c416
lines 109–115why, one step back109 if (cache_dir_fd == -1) {110 LOG_ERRNO("%s: failed to open", path);111 return;112 }113114 int fd = -1;115 if (fstatat(cache_dir_fd, "fuzzel", &st, 0) < 0 ||main: open all FDs with O_CLOEXECDaniel Eklöfbefore adoptione7d074c
line 116why, one step back116 (fd = openat(cache_dir_fd, "fuzzel", O_RDONLY | O_CLOEXEC)) < 0 ||changelog: add missing refDaniel Eklöfbefore adoption6a4c416
lines 117–128why, one step back117 (f = fdopen(fd, "r")) == NULL)118 {119 close(cache_dir_fd);120 if (fd >= 0)121 close(fd);122123 if (errno != ENOENT)124 LOG_ERRNO("%s/fuzzel: failed to open", path);125 return;126 }127 close(cache_dir_fd);128 } else {main: open all FDs with O_CLOEXECDaniel Eklöfbefore adoptione7d074c
line 129why, one step back129 if (stat(path, &st) < 0 || (f = fopen(path, "re")) == NULL)changelog: add missing refDaniel Eklöfbefore adoption6a4c416
lines 130–234why, one step back130 {131 if (errno != ENOENT)132 LOG_ERRNO("%s: failed to open", path);133 return;134 }135 }136137 tll(struct cache_entry) cache_entries = tll_init();138139 size_t line_sz = 0;140 char *line = NULL;141142 while (true) {143 errno = 0;144 ssize_t bytes = getline(&line, &line_sz, f);145146 if (bytes < 0) {147 if (errno != 0) {148 LOG_ERRNO("failed to read cache");149 fclose(f);150 free(line);151 return;152 }153154 /* Done */155 break;156 }157158 if (line[bytes - 1] == '\n')159 line[bytes - 1] = '\0';160161 /* Parse each line ("<title>|<count>") */162 char *ptr = NULL;163 const char *id = strtok_r(line, "|", &ptr);164 const char *count_str = strtok_r(NULL, "|", &ptr);165166 if (id == NULL || count_str == NULL) {167 LOG_ERR("invalid cache entry (cache corrupt?): %s", line);168 continue;169 }170171 int count;172 sscanf(count_str, "%u", &count);173174 struct cache_entry entry = {175 .id = dmenu ? NULL : xstrdup(id),176 .title = dmenu ? ambstoc32(id) : NULL,177 .count = count,178 };179 tll_push_back(cache_entries, entry);180 }181182 free(line);183 fclose(f);184185 /* Loop all applications, and search for a matching cache entry */186 for (size_t i = 0; i < apps->count; i++) {187 struct application *app = apps->v[i];188189 if ((!dmenu && app->id == NULL) || (dmenu && app->title == NULL)) {190 continue;191 }192193 tll_foreach(cache_entries, it) {194 const struct cache_entry *e = &it->item;195 if ((!dmenu && e->id == NULL) || (dmenu && e->title == NULL))196 continue;197198 if ((!dmenu && strcmp(app->id, e->id) == 0) ||199 (dmenu && c32cmp(app->title, e->title) == 0))200 {201 app->count = e->count;202203 free(e->id);204 free(e->title);205 tll_remove(cache_entries, it);206 break;207 }208 }209 }210211 /* Free all un-matched cache entries */212 tll_foreach(cache_entries, it) {213 free(it->item.id);214 tll_remove(cache_entries, it);215 }216}217218static void219write_cache(const char *path, const struct application_list *apps, bool dmenu)220{221 if (path == NULL && dmenu) {222 /* Don't thrash "normal" cache in dmenu mode */223 return;224 }225226 int fd = -1;227228 if (path == NULL) {229 path = xdg_cache_dir();230 if (path == NULL) {231 LOG_WARN("failed to get cache directory: not saving popularity cache");232 return;233 }234main: open all FDs with O_CLOEXECDaniel Eklöfbefore adoptione7d074c
line 235why, one step back235 int cache_dir_fd = open(path, O_DIRECTORY | O_CLOEXEC);changelog: add missing refDaniel Eklöfbefore adoption6a4c416
lines 236–240why, one step back236 if (cache_dir_fd == -1) {237 LOG_ERRNO("%s: failed to open", path);238 return;239 }240cache: fix incorrect cache write error messageNicholas Rodrigues Lordellobefore adoptionb320e2f
lines 241–245why, one step back241 if ((fd = openat(cache_dir_fd, "fuzzel", O_WRONLY | O_CREAT | O_TRUNC | O_CLOEXEC, 0644)) == -1) {242 close(cache_dir_fd);243 LOG_ERRNO("%s/fuzzel: failed to open", path);244 return;245 }changelog: add missing refDaniel Eklöfbefore adoption6a4c416
lines 246–247why, one step back246 close(cache_dir_fd);247 } else {cache: fix incorrect cache write error messageNicholas Rodrigues Lordellobefore adoptionb320e2f
lines 248–251why, one step back248 if ((fd = open(path, O_WRONLY | O_CREAT | O_TRUNC | O_CLOEXEC, 0644)) == -1) {249 LOG_ERRNO("%s: failed to open", path);250 return;251 }changelog: add missing refDaniel Eklöfbefore adoption6a4c416
lines 252–325why, one step back252 }253254 for (size_t i = 0; i < apps->count; i++) {255 if (apps->v[i]->count == 0)256 continue;257258 if (!apps->v[i]->visible)259 continue;260261 if (!dmenu && apps->v[i]->id == NULL)262 continue;263264 if (dmenu && apps->v[i]->title == NULL)265 continue;266267 if (!dmenu) {268 const char *id = apps->v[i]->id;269 const size_t id_len = strlen(id);270271 if (write(fd, id, id_len) != id_len) {272 LOG_ERRNO("failed to write cache");273 break;274 }275 } else {276 const char32_t *title = apps->v[i]->title;277 char *u8_title = ac32tombs(title);278279 if (u8_title != NULL) {280 const size_t title_len = strlen(u8_title);281 if (write(fd, u8_title, title_len) != title_len) {282 LOG_ERRNO("failed to write cache");283 break;284 }285286 free(u8_title);287 }288 }289290 char count_as_str[11];291 const size_t count_len = xsnprintf(292 count_as_str, sizeof(count_as_str), "%u", apps->v[i]->count);293294 if (write(fd, "|", 1) != 1 ||295 write(fd, count_as_str, count_len) != count_len ||296 write(fd, "\n", 1) != 1)297 {298 LOG_ERRNO("failed to write cache");299 break;300 }301 }302303 close(fd);304}305306static const char *307version_and_features(void)308{309 static char buf[256];310 xsnprintf(buf, sizeof(buf), "version: %s %ccairo %cpng %csvg%s %cassertions",311 FUZZEL_VERSION,312#if defined(FUZZEL_ENABLE_CAIRO)313 '+',314#else315 '-',316#endif317#if defined(FUZZEL_ENABLE_PNG_LIBPNG)318 '+',319#else320 '-',321#endif322#if defined(FUZZEL_ENABLE_SVG_NANOSVG)323 '+', "(nanosvg)",324#elif defined(FUZZEL_ENABLE_SVG_LIBRSVG)325 '+', "(librsvg)",✨ Add resvg as SVG render option.Mark Stosbergbefore adoptionfaf6fea
lines 326–327why, one step back326#elif defined(FUZZEL_ENABLE_SVG_RESVG)327 '+', "(resvg)",changelog: add missing refDaniel Eklöfbefore adoption6a4c416
lines 328–351why, one step back328#else329 '-', "",330#endif331#if !defined(NDEBUG)332 '+'333#else334 '-'335#endif336 );337 return buf;338}339340static void341print_usage(const char *prog_name)342{343 printf("Usage: %s [OPTION]...\n", prog_name);344 printf("\n");345 printf("Options:\n");346 printf(" --config=PATH load configuration from PATH\n"347 " (XDG_CONFIG_HOME/fuzzel/fuzzel.ini)\n"348 " --check-config verify configuration, exit with 0 if ok,\n"349 " otherwise exit with 1\n"350 " --cache=PATH load most recently launched applications from\n"351 " PATH (XDG_CACHE_HOME/fuzzel)\n"main: add --override=[section.]key=value command line optionDaniel Eklöfbefore adoption5df0df2
line 352why, one step back352 " --override=[section.].key=VALUE override configuration value\n"wayland: allow setting namespace in config and from the command linefrostybefore adoption5255c0a
line 353why, one step back353 " -n,--namespace=NAMESPACE layer shell surface namespace\n"changelog: add missing refDaniel Eklöfbefore adoption6a4c416
lines 354–358why, one step back354 " -o,--output=OUTPUT output (monitor) to display on (none)\n"355 " -f,--font=FONT font name and style, in FontConfig format\n"356 " (monospace)\n"357 " --use-bold allow fuzzel to use bold fonts\n"358 " -D,--dpi-aware=no|yes|auto enable or disable DPI aware rendering (auto)\n"config: change default icon theme from 'hicolor' to 'default'Daniel Eklöfbefore adoptionc24a0da
line 359why, one step back359 " --icon-theme=NAME icon theme name (\"default\")\n"changelog: add missing refDaniel Eklöfbefore adoption6a4c416
lines 360–369why, one step back360 " -I,--no-icons do not render any icons\n"361 " --hide-before-typing hide application list until something is typed\n"362 " -F,--fields=FIELDS comma separated list of XDG Desktop entry\n"363 " fields to match\n"364 " -p,--prompt=PROMPT string to use as input prompt (\"> \")\n"365 " --prompt-only=PROMPT same as --prompt, but in dmenu mode it does not\n"366 " wait for STDIN, and implies --lines=0\n"367 " --placeholder=TEXT placeholder text in input box\n"368 " --search=TEXT initial search/filter string\n"369 " --password=[CHARACTER] render all input as CHARACTER ('*' by default)\n"config: add --mesg, --mesg-mode and --message-color command line optionsSlayerOfTheBadbefore adoption9fb7e6c
lines 370–372why, one step back370 " --mesg show informational message above the prompt\n"371 " --mesg-mode=wrap|expand how to deal with message lines longer than\n"372 " the ui (wrap)\n"changelog: add missing refDaniel Eklöfbefore adoption6a4c416
lines 373–380why, one step back373 " -T,--terminal terminal command to use when launching\n"374 " 'terminal' programs, e.g. \"xterm -e\".\n"375 " Not used in dmenu mode (not set)\n"376 " -a,--anchor window anchor (center)\n"377 " --x-margin=MARGIN horizontal margin, in pixels (0)\n"378 " --y-margin=MARGIN vertical margin, in pixels (0)\n"379 " --select=STRING select first entry that matches the given\n"380 " string\n"✨ Add --auto-select opt. When one entry is left, automatically select it.Mark Stosbergbefore adoption5751a65
lines 381–382why, one step back381 " --auto-select automatically select when only one match\n"382 " remains\n"changelog: add missing refDaniel Eklöfbefore adoption6a4c416
lines 383–384why, one step back383 " --select-index=INDEX select the entry with index, not compatible with --select\n"384 " -l,--lines number of matches to show\n"Add new --minimal-flag optionMark Stosbergbefore adoption6200008
lines 385–387why, one step back385 " --minimal-lines adjust the number of lines to the\n"386 " minimum of --lines and the number\n"387 " of input lines (dmenu mode only)\n"✨ New Feature: Hide Input Line (#597)Mark Stosbergbefore adoption1ea0283
lines 388–389why, one step back388 " --hide-prompt hide the prompt line, making the window\n"389 " smaller (input still accepted)\n"changelog: add missing refDaniel Eklöfbefore adoption6a4c416
lines 390–400why, one step back390 " -w,--width window width, in characters (margins and\n"391 " borders not included)\n"392 " --tabs=INT number of spaces a tab is expanded to (8)\n"393 " -x,--horizontal-pad=PAD horizontal padding, in pixels (40)\n"394 " -y,--vertical-pad=PAD vertical padding, in pixels (8)\n"395 " -P,--inner-pad=PAD vertical padding between prompt and match list,\n"396 " in pixels (0)\n"397 " -b,--background-color=HEX background color (fdf6e3ff)\n"398 " -t,--text-color=HEX text color of matched entries (657b83ff)\n"399 " --prompt-color=HEX text color of the prompt (586e75ff)\n"400 " --placeholder-color=HEX text color of the placeholder text (93a1a1)\n"config: add --mesg, --mesg-mode and --message-color command line optionsSlayerOfTheBadbefore adoption9fb7e6c
line 401why, one step back401 " --message-color=HEX text color of the message (657b83ff)\n"changelog: add missing refDaniel Eklöfbefore adoption6a4c416
lines 402–407why, one step back402 " --input-color=HEX text color of the input string (657b83ff)\n"403 " -m,--match-color=HEX color of matched substring (cb4b16ff)\n"404 " -s,--selection-color=HEX background color of selected item (eee8d5ff)\n"405 " -S,--selection-text-color=HEX text color of selected item (586e75ff)\n"406 " -M,--selection-match-color=HEX color of matched substring in selection\n"407 " (cb4b16ff)\n"feat: border radius for selected entrieswisplbefore adoption9836d81
line 408why, one step back408 " --selection-radius border radius of the selected entry (0)\n"changelog: add missing refDaniel Eklöfbefore adoption6a4c416
lines 409–428why, one step back409 " --counter-color color of the match count (93a1a1)\n"410 " -B,--border-width=INT width of border, in pixels (1)\n"411 " -r,--border-radius=INT amount of corner \"roundness\" (10)\n"412 " -C,--border-color=HEX border color (002b36ff)\n"413 " --show-actions include desktop actions in the list\n"414 " --match-mode=exact|fzf|fuzzy how to match what you type against the entries\n"415 " --filter-desktop filter desktop entries based on XDG_CURRENT\n"416 " --fuzzy-min-length=VALUE search strings shorter than this will not be\n"417 " fuzzy matched (3)\n"418 " --fuzzy-max-length-discrepancy=VALUE maximum allowed length discrepancy\n"419 " between a fuzzy match and the search\n"420 " criteria. Larger values mean more\n"421 " fuzzy matches (2)\n"422 " --fuzzy-max-distance=VALUE maximum levenshtein distance between a fuzzy\n"423 " match and the search criteria. Larger values\n"424 " mean more fuzzy matches\n"425 " --line-height=HEIGHT override line height from font metrics\n"426 " --letter-spacing=AMOUNT additional letter spacing\n"427 " --layer=top|overlay which layer to render the fuzzel window on\n"428 " (top)\n"Add `keyboard-focus=exclusive|on-demand` command line and config optionbbb651before adoption9a0a38d
line 429why, one step back429 " --keyboard-focus=exclusive|on-demand keyboard focus mode (exclusive)\n"changelog: add missing refDaniel Eklöfbefore adoption6a4c416
lines 430–440why, one step back430 " --no-exit-on-keyboard-focus-loss do not exit when losing keyboard focus\n"431 " --launch-prefix=COMMAND prefix to add before argv of executed program\n"432 " --list-executables-in-path include executables from PATH in the list\n"433 " --render-workers=N number of threads to use for rendering\n"434 " --match-workers=N number of threads to use for matching\n"435 " --no-sort do not sort the result\n"436 " --counter display the match count\n"437 " --delayed-filter-ms=TIME_MS time in ms before refiltering after a keystroke\n"438 " (300)\n"439 " --delayed-filter-limit=N used delayed refiltering when the number of\n"440 " matches exceeds this number (10000)\n"config: add scaling-filter optionDaniel Eklöfbefore adoption3866f60
line 441why, one step back441 " --scaling-filter=FILTER filter to use when down scaling PNGs\n"changelog: add missing refDaniel Eklöfbefore adoption6a4c416
lines 442–446why, one step back442 " -d,--dmenu dmenu compatibility mode\n"443 " --dmenu0 like --dmenu, but input is NUL separated\n"444 " instead of newline separated\n"445 " --index print selected entry's index instead of of the \n"446 " entry's text (dmenu mode only)\n"config: --nth-delimiter=CHRDaniel Eklöfbefore adoption2dd56d8
lines 447–450why, one step back447 " --with-nth=N|FMT display the N:th column (tab separated by\n"448 " default) of each input line (dmenu only)\n"449 " --accept-nth=N|FMT output the N:th column (tab separated by\n"450 " default) of each input line (dmenu only)\n"dmenu: add support for --match-nthDaniel Eklöfbefore adoptionc006428
lines 451–453why, one step back451 " --match-nth=N|FMT match against the N:th column (tab separated by\n"452 " default) of each input line, instead of what is\n"453 " being displayed (dmenu only)\n"config: --nth-delimiter=CHRDaniel Eklöfbefore adoption2dd56d8
lines 454–455why, one step back454 " --nth-delimiter=CHARACTER field (column) character, for --with-nth and\n"455 " --accept-nth\n"dmenu: add --only-matchDaniel Eklöfbefore adoptionce5dd7f
lines 456–457why, one step back456 " --only-match do not allow custom entries, only return a\n"457 " selected item\n"changelog: add missing refDaniel Eklöfbefore adoption6a4c416
lines 458–465why, one step back458 " -R,--no-run-if-empty exit immediately without showing UI if stdin\n"459 " is empty (dmenu mode only)\n"460 " --log-level={info|warning|error|none}\n"461 " log level (warning)\n"462 " --log-colorize=[never|always|auto]\n"463 " enable/disable colorization of log output on\n"464 " stderr\n"465 " --log-no-syslog disable syslog logging\n"debug: add a --print-timing-info command line optionDaniel Eklöfbefore adoption1ea01b1
lines 466–467why, one step back466 " --print-timing-info print timing information, to help debug\n"467 " performance issues\n"feat: config/cli option to disable mouse inputGingehbefore adoption8c9e76d
line 468why, one step back468 " --no-mouse disable mouse input\n"changelog: add missing refDaniel Eklöfbefore adoption6a4c416
line 469why, one step back469 " -v,--version show the version number and quit\n");config: add --mesg, --mesg-mode and --message-color command line optionsSlayerOfTheBadbefore adoption9fb7e6c
line 470why, one step back470changelog: add missing refDaniel Eklöfbefore adoption6a4c416
lines 471–490why, one step back471 printf("\n");472 printf("All colors are RGBA - i.e. 8-digit hex values, without prefix.\n");473}474475static void476font_reloaded(struct wayland *wayl, struct fcft_font *font, void *data)477{478 struct context *ctx = data;479 const struct config *conf = ctx->conf;480481 applications_flush_text_run_cache(ctx->apps);482 render_flush_text_run_cache(ctx->render);483484 mtx_lock(ctx->icon_lock);485 {486 ctx->icon_size = render_icon_size(ctx->render);487488 if (conf->icons_enabled) {489 icon_lookup_application_icons(490 *ctx->themes, ctx->icon_size, ctx->apps);dmenu: add support for fallbacks in icon metadatae-thobefore adoptionb789998
lines 491–494why, one step back491492 if (conf->dmenu.enabled) {493 dmenu_try_icon_list(ctx->apps, *ctx->themes, ctx->icon_size);494 }changelog: add missing refDaniel Eklöfbefore adoption6a4c416
lines 495–582why, one step back495 }496 }497 mtx_unlock(ctx->icon_lock);498}499500static bool501pt_or_px_from_string(const char *s, struct pt_or_px *res)502{503 const size_t len = strlen(s);504 if (len >= 2 && s[len - 2] == 'p' && s[len - 1] == 'x') {505 errno = 0;506 char *end = NULL;507508 long value = strtol(s, &end, 10);509 if (!(errno == 0 && end == s + len - 2)) {510 fprintf(stderr, "%s: not a valid pixel value\n", s);511 return false;512 }513514 res->pt = 0;515 res->px = value;516 } else {517 errno = 0;518 char *end = NULL;519520 float value = strtof(s, &end);521 if (!(errno == 0 && *end == '\0')) {522 fprintf(stderr, "%s: not a valid point value\n", s);523 return false;524 }525 res->pt = value;526 res->px = 0;527 }528529 return true;530}531532static char *533lock_file_name(void)534{535 const char *xdg_runtime_dir = getenv("XDG_RUNTIME_DIR");536 if (xdg_runtime_dir == NULL)537 xdg_runtime_dir = "/tmp";538539 const char *wayland_display = getenv("WAYLAND_DISPLAY");540 if (wayland_display == NULL)541 return NULL;542543 char *path = xasprintf("%s/fuzzel-%s.lock", xdg_runtime_dir, wayland_display);544 LOG_DBG("lock file: %s", path);545 return path;546}547548static bool549acquire_file_lock(const char *path, int *fd)550{551 *fd = open(path, O_WRONLY | O_CREAT | O_CLOEXEC, 0644);552 if (*fd < 0) {553 /* Warn, but allow running anyway */554 LOG_WARN("%s: failed to create lock file: %s", path, strerror(errno));555 return true;556 }557558 if (flock(*fd, LOCK_EX | LOCK_NB) < 0) {559 if (errno == EWOULDBLOCK) {560 /* The file is locked and the LOCK_NB flag was selected */561 LOG_ERR("%s: failed to acquire lock: fuzzel already running?", path);562 return false;563 }564 }565566 return true;567}568569/* THREAD */570static int571populate_apps(void *_ctx)572{573 struct context *ctx = _ctx;574 const char *cache_path = ctx->cache_path;575 struct application_list *apps = ctx->apps;576 const struct config *conf = ctx->conf;577 const char *icon_theme = conf->icon_theme;578 const char *terminal = conf->terminal;579 bool actions_enabled = conf->actions_enabled;580 bool dmenu_enabled = conf->dmenu.enabled;581 bool icons_enabled = conf->icons_enabled;582 char dmenu_delim = conf->dmenu.delim;config: --nth-delimiter=CHRDaniel Eklöfbefore adoption2dd56d8
lines 583–584why, one step back583 char dmenu_nth_delim = conf->dmenu.nth_delim;584 const char *dmenu_with_nth_format = conf->dmenu.with_nth_format;dmenu: add support for --match-nthDaniel Eklöfbefore adoptionc006428
line 585why, one step back585 const char *dmenu_match_nth_format = conf->dmenu.match_nth_format;changelog: add missing refDaniel Eklöfbefore adoption6a4c416
lines 586–604why, one step back586 bool filter_desktop = conf->filter_desktop;587 bool list_exec_in_path = conf->list_executables_in_path;588 char_list_t desktops = tll_init();589 char *saveptr = NULL;590591 if (filter_desktop) {592 char *xdg_current_desktop = getenv("XDG_CURRENT_DESKTOP");593 if (xdg_current_desktop && strlen(xdg_current_desktop) != 0) {594 xdg_current_desktop = xstrdup(xdg_current_desktop);595 for (char *desktop = strtok_r(xdg_current_desktop, ":", &saveptr);596 desktop != NULL;597 desktop = strtok_r(NULL, ":", &saveptr))598 {599 tll_push_back(desktops, xstrdup(desktop));600 }601 free(xdg_current_desktop);602 }603 }604timing: rename time_end() -> time_finish()Daniel Eklöfbefore adoptiond226f7f
lines 605–606why, one step back605 ctx->timing.apps.start = time_begin();606changelog: add missing refDaniel Eklöfbefore adoption6a4c416
lines 607–608why, one step back607 if (dmenu_enabled) {608 if (!conf->prompt_only) {config: --nth-delimiter=CHRDaniel Eklöfbefore adoption2dd56d8
line 609why, one step back609 dmenu_load_entries(dmenu: add support for --match-nthDaniel Eklöfbefore adoptionc006428
lines 610–611why, one step back610 apps, dmenu_delim, dmenu_with_nth_format, dmenu_match_nth_format,611 dmenu_nth_delim, ctx->event_fd, ctx->dmenu_abort_fd);changelog: add missing refDaniel Eklöfbefore adoption6a4c416
lines 612–621why, one step back612 read_cache(cache_path, apps, true);613 }614 } else {615 xdg_find_programs(terminal, actions_enabled, filter_desktop, &desktops, apps);616 if (list_exec_in_path)617 path_find_programs(apps);618 read_cache(cache_path, apps, false);619 }620 tll_free_and_free(desktops, free);621timing: rename time_end() -> time_finish()Daniel Eklöfbefore adoptiond226f7f
lines 622–623why, one step back622 ctx->timing.apps.stop = time_end();623changelog: add missing refDaniel Eklöfbefore adoption6a4c416
lines 624–628why, one step back624 int r = send_event(ctx->event_fd, EVENT_APPS_ALL_LOADED);625 if (r != 0)626 return r;627628 if (icons_enabled) {timing: rename time_end() -> time_finish()Daniel Eklöfbefore adoptiond226f7f
line 629why, one step back629 ctx->timing.icons_theme.start = time_begin();icon: in application mode (not dmenu), filter out non-application icon theme dirsDaniel Eklöfbefore adoption40964b5
line 630why, one step back630 icon_theme_list_t icon_themes = icon_load_theme(icon_theme, !dmenu_enabled);changelog: add missing refDaniel Eklöfbefore adoption6a4c416
lines 631–634why, one step back631 if (tll_length(icon_themes) > 0)632 LOG_INFO("theme: %s", tll_front(icon_themes).name);633 else634 LOG_WARN("%s: icon theme not found", icon_theme);timing: rename time_end() -> time_finish()Daniel Eklöfbefore adoptiond226f7f
line 635why, one step back635 ctx->timing.icons_theme.stop = time_end();changelog: add missing refDaniel Eklöfbefore adoption6a4c416
line 636why, one step back636timing: rename time_end() -> time_finish()Daniel Eklöfbefore adoptiond226f7f
line 637why, one step back637 ctx->timing.icons.start = time_begin();changelog: add missing refDaniel Eklöfbefore adoption6a4c416
lines 638–643why, one step back638 mtx_lock(ctx->icon_lock);639 {640 *ctx->themes = icon_themes;641 if (ctx->icon_size > 0) {642 icon_lookup_application_icons(643 *ctx->themes, ctx->icon_size, apps);dmenu: add support for fallbacks in icon metadatae-thobefore adoptionb789998
lines 644–647why, one step back644645 if (dmenu_enabled) {646 dmenu_try_icon_list(apps, *ctx->themes, ctx->icon_size);647 }changelog: add missing refDaniel Eklöfbefore adoption6a4c416
lines 648–650why, one step back648 }649 }650 mtx_unlock(ctx->icon_lock);timing: rename time_end() -> time_finish()Daniel Eklöfbefore adoptiond226f7f
line 651why, one step back651 ctx->timing.icons.stop = time_end();changelog: add missing refDaniel Eklöfbefore adoption6a4c416
lines 652–673why, one step back652653 r = send_event(ctx->event_fd, EVENT_ICONS_LOADED);654 if (r != 0)655 return r;656 }657658 return 0;659}660661static bool662process_event(struct context *ctx, enum event_type event)663{664 const struct config *conf = ctx->conf;665 struct wayland *wayl = ctx->wayl;666 struct application_list *apps = ctx->apps;667 struct matches *matches = ctx->matches;668 const char *select = ctx->select_initial;669 const size_t select_idx = ctx->select_initial_idx;670671 switch (event) {672 case EVENT_APPS_SOME_LOADED:673 case EVENT_APPS_ALL_LOADED: {timing: rename time_end() -> time_finish()Daniel Eklöfbefore adoptiond226f7f
lines 674–676why, one step back674 if (event == EVENT_APPS_ALL_LOADED) {675 time_finish(676 ctx->timing.apps.start, ctx->timing.apps.stop, "apps loaded");debug: add a --print-timing-info command line optionDaniel Eklöfbefore adoption1ea01b1
line 677why, one step back677 }changelog: add missing refDaniel Eklöfbefore adoption6a4c416
lines 678–681why, one step back678 /* Update matches list, then refresh the GUI */679 matches_set_applications(matches, apps);680681 if (event == EVENT_APPS_ALL_LOADED) {wayland: dmenu: prevent window from being displayed until we have loaded at least one entryDaniel Eklöfbefore adoption63cd8ea
line 682why, one step back682 if (conf->dmenu.exit_immediately_if_empty && apps->count == 0)changelog: add missing refDaniel Eklöfbefore adoption6a4c416
line 683why, one step back683 return false;Add new --minimal-flag optionMark Stosbergbefore adoption6200008
line 684why, one step back684changelog: add missing refDaniel Eklöfbefore adoption6a4c416
line 685why, one step back685 matches_all_applications_loaded(matches);Add new --minimal-flag optionMark Stosbergbefore adoption6200008
lines 686–693why, one step back686687 if (conf->dmenu.enabled && conf->minimal_lines) {688 const size_t effective_lines = min(apps->count, conf->lines);689 matches_max_matches_per_page_set(matches, effective_lines);690 ctx->conf->lines = effective_lines;691 wayl_resized(wayl);692 }693wayland: dmenu: prevent window from being displayed until we have loaded at least one entryDaniel Eklöfbefore adoption63cd8ea
line 694why, one step back694 wayl_ready_to_display(wayl);changelog: add missing refDaniel Eklöfbefore adoption6a4c416
lines 695–718why, one step back695 }696697 const size_t match_count = matches_get_count(matches);698 const size_t matches_per_page = matches_max_matches_per_page(matches);699700 if (conf->match_counter ||701 event == EVENT_APPS_ALL_LOADED ||702 match_count < matches_per_page)703 {704 /*705 * Only update matches if706 * a) we're displaying a match counter707 * b) all applications have been loaded708 * c) a partial load will cause more matches to be displayed709 */710 matches_update_no_delay(matches);711 if (select_idx != 0) {712 if (!matches_selected_set(matches, select_idx)) {713 LOG_ERR("couldn't select entry at index %zu", select_idx);714 return false;715 }716 }717 else718 matches_selected_select(matches, select);Add new --minimal-flag optionMark Stosbergbefore adoption6200008
line 719why, one step back719 }wayland: dmenu: prevent window from being displayed until we have loaded at least one entryDaniel Eklöfbefore adoption63cd8ea
line 720why, one step back720Add new --minimal-flag optionMark Stosbergbefore adoption6200008
lines 721–735why, one step back721 /*722 * Allow displaying the menu if:723 * --no-run-if-empty is NOT enabled, OR we have at least one entry724 * AND725 * --minimal-lines is NOT enabled, OR we have at least --lines number of entries726 *727 * In short, display the window as soon as we are sure we728 * won't exit automatically (due to --no-run-if-empty), and we729 * know its final size.730 */731 if ((!conf->dmenu.exit_immediately_if_empty || apps->count > 0) &&732 (!(conf->dmenu.enabled && conf->minimal_lines) ||733 apps->count >= conf->lines))734 {735 wayl_ready_to_display(wayl);changelog: add missing refDaniel Eklöfbefore adoption6a4c416
lines 736–741why, one step back736 }737 break;738 }739740 case EVENT_ICONS_LOADED:741 /* Just need to refresh the GUI */timing: rename time_end() -> time_finish()Daniel Eklöfbefore adoptiond226f7f
lines 742–745why, one step back742 time_finish(ctx->timing.icons_theme.start, ctx->timing.icons_theme.stop,743 "icon themes loaded");744 time_finish(ctx->timing.icons.start, ctx->timing.icons.stop,745 "icon paths resolved");changelog: add missing refDaniel Eklöfbefore adoption6a4c416
lines 746–754why, one step back746 matches_icons_loaded(matches);747 break;748749 default:750 LOG_ERR("unknown event: %llx", (long long)event);751 return false;752 }753754 wayl_refresh(wayl);main: fix --auto-select combined with --searchDaniel Eklöfbefore adoptionc751abd
lines 755–758why, one step back755756 if (event == EVENT_APPS_ALL_LOADED)757 wayl_check_auto_select(wayl);758changelog: add missing refDaniel Eklöfbefore adoption6a4c416
lines 759–813why, one step back759 return true;760}761762/*763 * Called when the application list has been populated764 */765static bool766fdm_apps_populated(struct fdm *fdm, int fd, int events, void *data)767{768 struct context *ctx = data;769 uint64_t last_event = EVENT_INVALID;770 uint64_t event = EVENT_INVALID;771772 while (true) {773 ssize_t bytes = read(fd, &event, sizeof(event));774 if (bytes == 0) {775 if (event != EVENT_INVALID) {776 if (!process_event(ctx, event))777 return false;778 }779 break;780 }781782 if (bytes != (ssize_t)sizeof(event)) {783 if (bytes < 0) {784 if (errno == EAGAIN) {785 if (event != EVENT_INVALID) {786 if (!process_event(ctx, event))787 return false;788 }789 break;790 }791 LOG_ERRNO("failed to read event FD");792 } else793 LOG_ERR("partial read from event FD");794 return false;795 }796797 /* Coalesce multiple, identical events */798 if (last_event != EVENT_INVALID) {799 if (event != last_event) {800 if (!process_event(ctx, last_event))801 return false;802 }803 }804805 last_event = event;806 }807808 return true;809}810811int812main(int argc, char *const *argv)813{timing: new minimal timing frameworkDaniel Eklöfbefore adoption0221d35
lines 814–815why, one step back814 time_init();815changelog: add missing refDaniel Eklöfbefore adoption6a4c416
lines 816–830why, one step back816 #define OPT_LETTER_SPACING 256817 #define OPT_LAUNCH_PREFIX 257818 #define OPT_SHOW_ACTIONS 258819 #define OPT_MATCH_MODE 259820 #define OPT_FUZZY_MIN_LENGTH 260821 #define OPT_FUZZY_MAX_LENGTH_DISCREPANCY 261822 #define OPT_FUZZY_MAX_DISTANCE 262823 #define OPT_DMENU_INDEX 263824 #define OPT_LOG_LEVEL 264825 #define OPT_LOG_COLORIZE 265826 #define OPT_LOG_NO_SYSLOG 266827 #define OPT_PASSWORD 267828 #define OPT_CONFIG 268829 #define OPT_LAYER 269830 #define OPT_ICON_THEME 270Add `keyboard-focus=exclusive|on-demand` command line and config optionbbb651before adoption9a0a38d
lines 831–859why, one step back831 #define OPT_KEYBOARD_FOCUS 271832 #define OPT_NO_EXIT_ON_KB_LOSS 272833 #define OPT_TABS 273834 #define OPT_DMENU_NULL 274835 #define OPT_FILTER_DESKTOP 275836 #define OPT_CHECK_CONFIG 276837 #define OPT_SELECT 277838 #define OPT_SELECT_INDEX 278839 #define OPT_LIST_EXECS_IN_PATH 279840 #define OPT_X_MARGIN 280841 #define OPT_Y_MARGIN 281842 #define OPT_CACHE 282843 #define OPT_RENDER_WORKERS 283844 #define OPT_PROMPT_COLOR 284845 #define OPT_INPUT_COLOR 285846 #define OPT_PROMPT_ONLY 286847 #define OPT_COUNTER_COLOR 287848 #define OPT_USE_BOLD 288849 #define OPT_MATCH_WORKERS 289850 #define OPT_NO_SORT 290851 #define OPT_DELAYED_FILTER_MS 291852 #define OPT_DELAYED_FILTER_LIMIT 292853 #define OPT_PLACEHOLDER 293854 #define OPT_PLACEHOLDER_COLOR 294855 #define OPT_SEARCH_TEXT 295856 #define OPT_COUNTER 296857 #define OPT_HIDE_WHEN_PROMPT_EMPTY 297858 #define OPT_DMENU_WITH_NTH 298859 #define OPT_DMENU_ACCEPT_NTH 299Implement gamma-correct blendingDaniel Eklöfbefore adoption2d19826
line 860why, one step back860 #define OPT_GAMMA_CORRECT 300debug: add a --print-timing-info command line optionDaniel Eklöfbefore adoption1ea01b1
line 861why, one step back861 #define OPT_PRINT_TIMINGS 301config: add scaling-filter optionDaniel Eklöfbefore adoption3866f60
line 862why, one step back862 #define OPT_SCALING_FILTER 302Add new --minimal-flag optionMark Stosbergbefore adoption6200008
line 863why, one step back863 #define OPT_MINIMAL_LINES 303✨ New Feature: Hide Input Line (#597)Mark Stosbergbefore adoption1ea0283
line 864why, one step back864 #define OPT_HIDE_PROMPT 304✨ Add --auto-select opt. When one entry is left, automatically select it.Mark Stosbergbefore adoption5751a65
line 865why, one step back865 #define OPT_AUTO_SELECT 305feat: border radius for selected entrieswisplbefore adoption9836d81
line 866why, one step back866 #define OPT_SELECTION_RADIUS 306feat: config/cli option to disable mouse inputGingehbefore adoption8c9e76d
line 867why, one step back867 #define OPT_NO_MOUSE 307config: --nth-delimiter=CHRDaniel Eklöfbefore adoption2dd56d8
line 868why, one step back868 #define OPT_DMENU_NTH_DELIM 308dmenu: add support for --match-nthDaniel Eklöfbefore adoptionc006428
line 869why, one step back869 #define OPT_DMENU_MATCH_NTH 309dmenu: add --only-matchDaniel Eklöfbefore adoptionce5dd7f
line 870why, one step back870 #define OPT_DMENU_ONLY_MATCH 310config: add --mesg, --mesg-mode and --message-color command line optionsSlayerOfTheBadbefore adoption9fb7e6c
lines 871–873why, one step back871 #define OPT_DMENU_MESSAGE 311872 #define OPT_DMENU_MESSAGE_MODE 312873 #define OPT_MESSAGE_COLOR 313main: add --override=[section.]key=value command line optionDaniel Eklöfbefore adoption5df0df2
line 874why, one step back874 #define OPT_GENERIC_OVERRIDE 314changelog: add missing refDaniel Eklöfbefore adoption6a4c416
lines 875–878why, one step back875876 static const struct option longopts[] = {877 {"config", required_argument, 0, OPT_CONFIG},878 {"check-config", no_argument, 0, OPT_CHECK_CONFIG},wayland: allow setting namespace in config and from the command linefrostybefore adoption5255c0a
line 879why, one step back879 {"namespace", required_argument, 0, 'n'},changelog: add missing refDaniel Eklöfbefore adoption6a4c416
lines 880–884why, one step back880 {"cache", required_argument, 0, OPT_CACHE},881 {"output" , required_argument, 0, 'o'},882 {"font", required_argument, 0, 'f'},883 {"use-bold", no_argument, 0, OPT_USE_BOLD},884 {"dpi-aware", required_argument, 0, 'D'},Implement gamma-correct blendingDaniel Eklöfbefore adoption2d19826
line 885why, one step back885 {"gamma-correct", no_argument, 0, OPT_GAMMA_CORRECT},changelog: add missing refDaniel Eklöfbefore adoption6a4c416
lines 886–896why, one step back886 {"icon-theme", required_argument, 0, OPT_ICON_THEME},887 {"no-icons", no_argument, 0, 'I'},888 {"hide-before-typing", no_argument, 0, OPT_HIDE_WHEN_PROMPT_EMPTY},889 {"fields", required_argument, 0, 'F'},890 {"password", optional_argument, 0, OPT_PASSWORD},891 {"anchor", required_argument, 0, 'a'},892 {"x-margin", required_argument, 0, OPT_X_MARGIN},893 {"y-margin", required_argument, 0, OPT_Y_MARGIN},894 {"select", required_argument, 0, OPT_SELECT},895 {"select-index", required_argument, 0, OPT_SELECT_INDEX},896 {"lines", required_argument, 0, 'l'},Add new --minimal-flag optionMark Stosbergbefore adoption6200008
line 897why, one step back897 {"minimal-lines", no_argument, 0, OPT_MINIMAL_LINES},✨ New Feature: Hide Input Line (#597)Mark Stosbergbefore adoption1ea0283
line 898why, one step back898 {"hide-prompt", no_argument, 0, OPT_HIDE_PROMPT},changelog: add missing refDaniel Eklöfbefore adoption6a4c416
lines 899–905why, one step back899 {"width", required_argument, 0, 'w'},900 {"tabs", required_argument, 0, OPT_TABS},901 {"horizontal-pad", required_argument, 0, 'x'},902 {"vertical-pad", required_argument, 0, 'y'},903 {"inner-pad", required_argument, 0, 'P'},904 {"background-color", required_argument, 0, 'b'},905 {"text-color", required_argument, 0, 't'},config: add --mesg, --mesg-mode and --message-color command line optionsSlayerOfTheBadbefore adoption9fb7e6c
line 906why, one step back906 {"message-color", required_argument, 0, OPT_MESSAGE_COLOR},changelog: add missing refDaniel Eklöfbefore adoption6a4c416
lines 907–913why, one step back907 {"prompt-color", required_argument, 0, OPT_PROMPT_COLOR},908 {"placeholder-color", required_argument, 0, OPT_PLACEHOLDER_COLOR},909 {"input-color", required_argument, 0, OPT_INPUT_COLOR},910 {"match-color", required_argument, 0, 'm'},911 {"selection-color", required_argument, 0, 's'},912 {"selection-text-color", required_argument, 0, 'S'},913 {"selection-match-color",required_argument, 0, 'M'},feat: border radius for selected entrieswisplbefore adoption9836d81
line 914why, one step back914 {"selection-radius", required_argument, 0, OPT_SELECTION_RADIUS},changelog: add missing refDaniel Eklöfbefore adoption6a4c416
lines 915–933why, one step back915 {"counter-color", required_argument, 0, OPT_COUNTER_COLOR},916 {"border-width", required_argument, 0, 'B'},917 {"border-radius", required_argument, 0, 'r'},918 {"border-color", required_argument, 0, 'C'},919 {"prompt", required_argument, 0, 'p'},920 {"prompt-only", required_argument, 0, OPT_PROMPT_ONLY},921 {"placeholder", required_argument, 0, OPT_PLACEHOLDER},922 {"search", required_argument, 0, OPT_SEARCH_TEXT},923 {"terminal", required_argument, 0, 'T'},924 {"show-actions", no_argument, 0, OPT_SHOW_ACTIONS},925 {"match-mode", required_argument, 0, OPT_MATCH_MODE},926 {"filter-desktop", optional_argument, 0, OPT_FILTER_DESKTOP},927 {"fuzzy-min-length", required_argument, 0, OPT_FUZZY_MIN_LENGTH},928 {"fuzzy-max-length-discrepancy", required_argument, 0, OPT_FUZZY_MAX_LENGTH_DISCREPANCY},929 {"fuzzy-max-distance", required_argument, 0, OPT_FUZZY_MAX_DISTANCE},930 {"line-height", required_argument, 0, 'H'},931 {"letter-spacing", required_argument, 0, OPT_LETTER_SPACING},932 {"launch-prefix", required_argument, 0, OPT_LAUNCH_PREFIX},933 {"layer", required_argument, 0, OPT_LAYER},Add `keyboard-focus=exclusive|on-demand` command line and config optionbbb651before adoption9a0a38d
lines 934–936why, one step back934 {"keyboard-focus", required_argument, 0, OPT_KEYBOARD_FOCUS},935 {"no-exit-on-keyboard-focus-loss", no_argument, 0, OPT_NO_EXIT_ON_KB_LOSS},936 {"list-executables-in-path", no_argument, 0, OPT_LIST_EXECS_IN_PATH},changelog: add missing refDaniel Eklöfbefore adoption6a4c416
lines 937–942why, one step back937 {"render-workers", required_argument, 0, OPT_RENDER_WORKERS},938 {"match-workers", required_argument, 0, OPT_MATCH_WORKERS},939 {"no-sort", no_argument, 0, OPT_NO_SORT},940 {"counter", no_argument, 0, OPT_COUNTER},941 {"delayed-filter-ms", required_argument, 0, OPT_DELAYED_FILTER_MS},942 {"delayed-filter-limit", required_argument, 0, OPT_DELAYED_FILTER_LIMIT},config: add scaling-filter optionDaniel Eklöfbefore adoption3866f60
line 943why, one step back943 {"scaling-filter", required_argument, 0, OPT_SCALING_FILTER},✨ Add --auto-select opt. When one entry is left, automatically select it.Mark Stosbergbefore adoption5751a65
line 944why, one step back944 {"auto-select", no_argument, 0, OPT_AUTO_SELECT},feat: config/cli option to disable mouse inputGingehbefore adoption8c9e76d
line 945why, one step back945 {"no-mouse", no_argument, 0, OPT_NO_MOUSE},changelog: add missing refDaniel Eklöfbefore adoption6a4c416
lines 946–951why, one step back946947 /* dmenu mode */948 {"dmenu", no_argument, 0, 'd'},949 {"dmenu0", no_argument, 0, OPT_DMENU_NULL},950 {"no-run-if-empty", no_argument, 0, 'R'},951 {"index", no_argument, 0, OPT_DMENU_INDEX},config: --nth-delimiter=CHRDaniel Eklöfbefore adoption2dd56d8
line 952why, one step back952 {"nth-delimiter", required_argument, 0, OPT_DMENU_NTH_DELIM},changelog: add missing refDaniel Eklöfbefore adoption6a4c416
line 953why, one step back953 {"with-nth", required_argument, 0, OPT_DMENU_WITH_NTH},Add `--accept-nth` command line option to select column to outputbbb651before adoption33c9b8e
line 954why, one step back954 {"accept-nth", required_argument, 0, OPT_DMENU_ACCEPT_NTH},dmenu: add support for --match-nthDaniel Eklöfbefore adoptionc006428
line 955why, one step back955 {"match-nth", required_argument, 0, OPT_DMENU_MATCH_NTH},dmenu: add --only-matchDaniel Eklöfbefore adoptionce5dd7f
line 956why, one step back956 {"only-match", no_argument, 0, OPT_DMENU_ONLY_MATCH},config: add --mesg, --mesg-mode and --message-color command line optionsSlayerOfTheBadbefore adoption9fb7e6c
lines 957–958why, one step back957 {"mesg", required_argument, 0, OPT_DMENU_MESSAGE},958 {"mesg-mode", required_argument, 0, OPT_DMENU_MESSAGE_MODE},changelog: add missing refDaniel Eklöfbefore adoption6a4c416
lines 959–960why, one step back959960 /* Misc */main: add --override=[section.]key=value command line optionDaniel Eklöfbefore adoption5df0df2
line 961why, one step back961 {"override", required_argument, 0, OPT_GENERIC_OVERRIDE},changelog: add missing refDaniel Eklöfbefore adoption6a4c416
lines 962–965why, one step back962 {"log-level", required_argument, 0, OPT_LOG_LEVEL},963 {"log-colorize", optional_argument, 0, OPT_LOG_COLORIZE},964 {"log-no-syslog", no_argument, 0, OPT_LOG_NO_SYSLOG},965 {"version", no_argument, 0, 'v'},debug: add a --print-timing-info command line optionDaniel Eklöfbefore adoption1ea01b1
line 966why, one step back966 {"print-timing-info", no_argument, 0, OPT_PRINT_TIMINGS},changelog: add missing refDaniel Eklöfbefore adoption6a4c416
lines 967–977why, one step back967 {"help", no_argument, 0, 'h'},968 {NULL, no_argument, 0, 0},969 };970971 bool check_config = false;972 const char *config_path = NULL;973 enum log_class log_level = LOG_CLASS_WARNING;974 enum log_colorize log_colorize = LOG_COLORIZE_AUTO;975 bool log_syslog = true;976 const char *select = NULL;977 size_t select_idx = 0;main: add --override=[section.]key=value command line optionDaniel Eklöfbefore adoption5df0df2
line 978why, one step back978 config_override_t generic_overrides = tll_init();changelog: add missing refDaniel Eklöfbefore adoption6a4c416
lines 979–983why, one step back979980 struct {981 struct config conf;982983 bool dpi_aware_set:1;Implement gamma-correct blendingDaniel Eklöfbefore adoption2d19826
line 984why, one step back984 bool gamma_correct_set:1;changelog: add missing refDaniel Eklöfbefore adoption6a4c416
lines 985–991why, one step back985 bool match_fields_set:1;986 bool icons_disabled_set:1;987 bool hide_when_prompt_empty_set:1;988 bool anchor_set:1;989 bool x_margin_set : 1;990 bool y_margin_set : 1;991 bool lines_set:1;Add new --minimal-flag optionMark Stosbergbefore adoption6200008
line 992why, one step back992 bool minimal_lines_set:1;✨ New Feature: Hide Input Line (#597)Mark Stosbergbefore adoption1ea0283
line 993why, one step back993 bool hide_prompt_set:1;changelog: add missing refDaniel Eklöfbefore adoption6a4c416
lines 994–1000why, one step back994 bool chars_set:1;995 bool tabs_set:1;996 bool pad_x_set:1;997 bool pad_y_set:1;998 bool pad_inner_set:1;999 bool background_color_set:1;1000 bool text_color_set:1;config: add --mesg, --mesg-mode and --message-color command line optionsSlayerOfTheBadbefore adoption9fb7e6c
line 1001why, one step back1001 bool message_color_set:1;changelog: add missing refDaniel Eklöfbefore adoption6a4c416
lines 1002–1007why, one step back1002 bool prompt_color_set:1;1003 bool input_color_set:1;1004 bool match_color_set:1;1005 bool selection_color_set:1;1006 bool selection_text_color_set:1;1007 bool selection_match_color_set:1;feat: border radius for selected entrieswisplbefore adoption9836d81
line 1008why, one step back1008 bool selection_border_radius_set:1;changelog: add missing refDaniel Eklöfbefore adoption6a4c416
lines 1009–1024why, one step back1009 bool counter_color_set:1;1010 bool border_color_set:1;1011 bool border_size_set:1;1012 bool border_radius_set:1;1013 bool actions_enabled_set:1;1014 bool filter_desktop_set:1;1015 bool match_mode_set:1;1016 bool fuzzy_min_length_set:1;1017 bool fuzzy_max_length_discrepancy_set:1;1018 bool fuzzy_max_distance_set:1;1019 bool line_height_set:1;1020 bool letter_spacing_set:1;1021 bool dmenu_enabled_set:1;1022 bool dmenu_mode_set:1;1023 bool dmenu_exit_immediately_if_empty_set:1;1024 bool dmenu_delim_set:1;config: --nth-delimiter=CHRDaniel Eklöfbefore adoption2dd56d8
line 1025why, one step back1025 bool dmenu_nth_delim_set:1;changelog: add missing refDaniel Eklöfbefore adoption6a4c416
line 1026why, one step back1026 bool dmenu_with_nth_set:1;Add `--accept-nth` command line option to select column to outputbbb651before adoption33c9b8e
line 1027why, one step back1027 bool dmenu_accept_nth_set:1;dmenu: add support for --match-nthDaniel Eklöfbefore adoptionc006428
line 1028why, one step back1028 bool dmenu_match_nth_set:1;dmenu: add --only-matchDaniel Eklöfbefore adoptionce5dd7f
line 1029why, one step back1029 bool dmenu_only_match_set:1;config: add --mesg, --mesg-mode and --message-color command line optionsSlayerOfTheBadbefore adoption9fb7e6c
line 1030why, one step back1030 bool mesg_mode_set:1;changelog: add missing refDaniel Eklöfbefore adoption6a4c416
line 1031why, one step back1031 bool layer_set:1;Add `keyboard-focus=exclusive|on-demand` command line and config optionbbb651before adoption9a0a38d
line 1032why, one step back1032 bool keyboard_focus_set:1;changelog: add missing refDaniel Eklöfbefore adoption6a4c416
lines 1033–1042why, one step back1033 bool no_exit_on_keyboard_focus_loss_set:1;1034 bool render_workers_set:1;1035 bool match_workers_set:1;1036 bool prompt_only_set:1;1037 bool use_bold_set:1;1038 bool no_sort_set:1;1039 bool delayed_filter_ms_set:1;1040 bool delayed_filter_limit_set:1;1041 bool placeholder_color_set:1;1042 bool counter_set:1;debug: add a --print-timing-info command line optionDaniel Eklöfbefore adoption1ea01b1
line 1043why, one step back1043 bool print_timing_info_set:1;config: add scaling-filter optionDaniel Eklöfbefore adoption3866f60
line 1044why, one step back1044 bool scaling_filter_set:1;feat: config/cli option to disable mouse inputGingehbefore adoption8c9e76d
line 1045why, one step back1045 bool no_mouse_set:1;changelog: add missing refDaniel Eklöfbefore adoption6a4c416
lines 1046–1063why, one step back1046 } cmdline_overrides = {{0}};10471048 setlocale(LC_CTYPE, "");1049 setlocale(LC_MESSAGES, "");10501051 /* Auto-enable dmenu mode if invoked through a ‘dmenu’ symlink */1052 if (argv[0] != NULL) {1053 char *copy = xstrdup(argv[0]);1054 const char *name = basename(copy);1055 if (name != NULL && strcmp(name, "dmenu") == 0) {1056 cmdline_overrides.conf.dmenu.enabled = true;1057 cmdline_overrides.dmenu_enabled_set = true;1058 }10591060 free(copy);1061 }10621063 while (true) {wayland: allow setting namespace in config and from the command linefrostybefore adoption5255c0a
line 1064why, one step back1064 int c = getopt_long(argc, argv, ":n:o:f:D:IF:ia:l:w:x:y:p:P:b:t:m:s:S:M:B:r:C:T:dRvh", longopts, NULL);changelog: add missing refDaniel Eklöfbefore adoption6a4c416
lines 1065–1076why, one step back1065 if (c == -1)1066 break;10671068 switch (c) {1069 case OPT_CONFIG:1070 config_path = optarg;1071 break;10721073 case OPT_CHECK_CONFIG:1074 check_config = true;1075 break;1076wayland: allow setting namespace in config and from the command linefrostybefore adoption5255c0a
lines 1077–1080why, one step back1077 case 'n':1078 cmdline_overrides.conf.namespace = optarg;1079 break;1080changelog: add missing refDaniel Eklöfbefore adoption6a4c416
lines 1081–1115why, one step back1081 case OPT_CACHE:1082 cmdline_overrides.conf.cache_path = optarg;1083 break;10841085 case 'o':1086 cmdline_overrides.conf.output = optarg;1087 break;10881089 case 'f':1090 cmdline_overrides.conf.font = optarg;1091 break;10921093 case OPT_USE_BOLD:1094 cmdline_overrides.conf.use_bold = true;1095 cmdline_overrides.use_bold_set = true;1096 break;10971098 case 'D':1099 if (strcmp(optarg, "auto") == 0)1100 cmdline_overrides.conf.dpi_aware = DPI_AWARE_AUTO;1101 else if (strcmp(optarg, "no") == 0)1102 cmdline_overrides.conf.dpi_aware = DPI_AWARE_NO;1103 else if (strcmp(optarg, "yes") == 0)1104 cmdline_overrides.conf.dpi_aware = DPI_AWARE_YES;1105 else {1106 fprintf(1107 stderr,1108 "%s: invalid value for dpi-aware: "1109 "must be one of 'auto', 'no', or 'yes'\n",1110 optarg);1111 return EXIT_FAILURE;1112 }1113 cmdline_overrides.dpi_aware_set = true;1114 break;1115Implement gamma-correct blendingDaniel Eklöfbefore adoption2d19826
lines 1116–1120why, one step back1116 case OPT_GAMMA_CORRECT:1117 cmdline_overrides.conf.gamma_correct = true;1118 cmdline_overrides.gamma_correct_set = true;1119 break;1120changelog: add missing refDaniel Eklöfbefore adoption6a4c416
lines 1121–1283why, one step back1121 case 'i':1122 /* Ignore (this flag means case insensitive search in1123 * other fuzzel-like utilities) */1124 break;11251126 case OPT_ICON_THEME:1127 cmdline_overrides.conf.icon_theme = optarg;1128 break;11291130 case 'I':1131 cmdline_overrides.conf.icons_enabled = false;1132 cmdline_overrides.icons_disabled_set = true;1133 break;11341135 case OPT_HIDE_WHEN_PROMPT_EMPTY:1136 cmdline_overrides.conf.hide_when_prompt_empty = true;1137 cmdline_overrides.hide_when_prompt_empty_set = true;1138 break;11391140 case 'F': {1141 static const struct {1142 const char *name;1143 enum match_fields value;1144 } map[] = {1145 {"filename", MATCH_FILENAME},1146 {"name", MATCH_NAME},1147 {"generic", MATCH_GENERIC},1148 {"exec", MATCH_EXEC},1149 {"categories", MATCH_CATEGORIES},1150 {"keywords", MATCH_KEYWORDS},1151 {"comment", MATCH_COMMENT},1152 };11531154 cmdline_overrides.conf.match_fields = 0;1155 for (const char *f = strtok(optarg, ", ");1156 f != NULL;1157 f = strtok(NULL, ", "))1158 {1159 enum match_fields field = 0;11601161 for (size_t i = 0; i < ALEN(map); i++) {1162 if (strcmp(f, map[i].name) == 0) {1163 field = map[i].value;1164 break;1165 }1166 }11671168 if (field > 0)1169 cmdline_overrides.conf.match_fields |= field;1170 else {1171 char valid_names[128] = {0};1172 size_t idx = 0;1173 for (size_t i = 0; i < ALEN(map); i++) {1174 idx += xsnprintf(1175 &valid_names[idx], sizeof(valid_names) - idx,1176 "'%s', ", map[i].name);1177 }11781179 valid_names[idx - 2] = '\0';11801181 fprintf(1182 stderr,1183 "%s: invalid field name: must be one of %s\n",1184 f, valid_names);1185 return EXIT_FAILURE;1186 }1187 }1188 cmdline_overrides.match_fields_set = true;1189 break;1190 }11911192 case OPT_PASSWORD: {1193 char32_t password_char = U'\0';1194 if (optarg != NULL) {1195 char32_t *wide_optarg = ambstoc32(optarg);1196 if (wide_optarg == NULL){1197 fprintf(stderr, "%s: invalid password character\n", optarg);1198 return EXIT_FAILURE;1199 }12001201 if (c32len(wide_optarg) > 1) {1202 fprintf(1203 stderr,1204 "%s: password character must be a single character\n",1205 optarg);1206 free(wide_optarg);1207 return EXIT_FAILURE;1208 }12091210 password_char = wide_optarg[0];1211 free(wide_optarg);1212 cmdline_overrides.conf.password_mode.character_set = true;1213 }12141215 cmdline_overrides.conf.password_mode.enabled = true;1216 cmdline_overrides.conf.password_mode.character = password_char;1217 break;1218 }12191220 case 'T':1221 cmdline_overrides.conf.terminal = optarg;1222 break;12231224 case 'a': {1225 enum anchors anchor;1226 bool valid_anchor = false;12271228 for (size_t i = 0; anchors_map[i].name != NULL; i++) {1229 if (strcmp(optarg, anchors_map[i].name) == 0) {1230 anchor = anchors_map[i].value;1231 valid_anchor = true;1232 break;1233 }1234 }12351236 if (!valid_anchor) {1237 fprintf(stderr, "%s: invalid anchor\n", optarg);1238 return EXIT_FAILURE;1239 }12401241 cmdline_overrides.conf.anchor = anchor;1242 cmdline_overrides.anchor_set = true;1243 break;1244 }12451246 case OPT_X_MARGIN:1247 if (sscanf(optarg, "%u", &cmdline_overrides.conf.margin.x) != 1) {1248 fprintf(stderr, "%s: invalid horizontal margin\n", optarg);1249 return EXIT_FAILURE;1250 }1251 cmdline_overrides.x_margin_set = true;1252 break;12531254 case OPT_Y_MARGIN:1255 if (sscanf(optarg, "%u", &cmdline_overrides.conf.margin.y) != 1) {1256 fprintf(stderr, "%s: invalid vertical margin\n", optarg);1257 return EXIT_FAILURE;1258 }1259 cmdline_overrides.y_margin_set = true;1260 break;12611262 case OPT_SELECT:1263 select = optarg;1264 break;12651266 case OPT_SELECT_INDEX:1267 if (sscanf(optarg, "%zu", &select_idx) != 1) {1268 fprintf(1269 stderr,1270 "%s: invalid selected index (must be an integer)\n",1271 optarg);1272 return EXIT_FAILURE;1273 }1274 break;12751276 case 'l':1277 if (sscanf(optarg, "%u", &cmdline_overrides.conf.lines) != 1) {1278 fprintf(stderr, "%s: invalid line count\n", optarg);1279 return EXIT_FAILURE;1280 }1281 cmdline_overrides.lines_set = true;1282 break;1283Add new --minimal-flag optionMark Stosbergbefore adoption6200008
lines 1284–1288why, one step back1284 case OPT_MINIMAL_LINES:1285 cmdline_overrides.conf.minimal_lines = true;1286 cmdline_overrides.minimal_lines_set = true;1287 break;1288✨ New Feature: Hide Input Line (#597)Mark Stosbergbefore adoption1ea0283
lines 1289–1293why, one step back1289 case OPT_HIDE_PROMPT:1290 cmdline_overrides.conf.hide_prompt = true;1291 cmdline_overrides.hide_prompt_set = true;1292 break;1293changelog: add missing refDaniel Eklöfbefore adoption6a4c416
lines 1294–1415why, one step back1294 case 'w':1295 if (sscanf(optarg, "%u", &cmdline_overrides.conf.chars) != 1) {1296 fprintf(stderr, "%s: invalid width\n", optarg);1297 return EXIT_FAILURE;1298 }1299 cmdline_overrides.chars_set = true;1300 break;13011302 case OPT_TABS:1303 if (sscanf(optarg, "%u", &cmdline_overrides.conf.tabs) != 1) {1304 fprintf(stderr, "%s: invalid tab count\n", optarg);1305 return EXIT_FAILURE;1306 }1307 cmdline_overrides.tabs_set = true;1308 break;13091310 case 'x':1311 if (sscanf(optarg, "%u", &cmdline_overrides.conf.pad.x) != 1) {1312 fprintf(stderr, "%s: invalid padding\n", optarg);1313 return EXIT_FAILURE;1314 }1315 cmdline_overrides.pad_x_set = true;1316 break;13171318 case 'y':1319 if (sscanf(optarg, "%u", &cmdline_overrides.conf.pad.y) != 1) {1320 fprintf(stderr, "%s: invalid padding\n", optarg);1321 return EXIT_FAILURE;1322 }1323 cmdline_overrides.pad_y_set = true;1324 break;13251326 case 'P':1327 if (sscanf(optarg, "%u", &cmdline_overrides.conf.pad.inner) != 1) {1328 fprintf(stderr, "%s: invalid padding\n", optarg);1329 return EXIT_FAILURE;1330 }1331 cmdline_overrides.pad_inner_set = true;1332 break;13331334 case 'p':1335 free(cmdline_overrides.conf.prompt);1336 cmdline_overrides.conf.prompt = ambstoc32(optarg);13371338 if (cmdline_overrides.conf.prompt == NULL) {1339 fprintf(stderr, "%s: invalid prompt\n", optarg);1340 return EXIT_FAILURE;1341 }13421343 break;13441345 case OPT_PROMPT_ONLY:1346 free(cmdline_overrides.conf.prompt);1347 cmdline_overrides.conf.prompt = ambstoc32(optarg);13481349 if (cmdline_overrides.conf.prompt == NULL) {1350 fprintf(stderr, "%s: invalid prompt\n", optarg);1351 return EXIT_FAILURE;1352 }13531354 cmdline_overrides.prompt_only_set = true;1355 cmdline_overrides.conf.prompt_only = true;1356 break;13571358 case OPT_PLACEHOLDER:1359 free(cmdline_overrides.conf.placeholder);1360 cmdline_overrides.conf.placeholder = ambstoc32(optarg);13611362 if (cmdline_overrides.conf.placeholder == NULL) {1363 fprintf(stderr, "%s: invalid placeholder\n", optarg);1364 return EXIT_FAILURE;1365 }13661367 break;13681369 case OPT_SEARCH_TEXT:1370 free(cmdline_overrides.conf.search_text);1371 cmdline_overrides.conf.search_text = ambstoc32(optarg);13721373 if (cmdline_overrides.conf.search_text == NULL) {1374 fprintf(stderr, "%s: invalid search text\n", optarg);1375 return EXIT_FAILURE;1376 }13771378 break;13791380 case 'b': {1381 const char *clr_start = optarg;1382 if (clr_start[0] == '#')1383 clr_start++;13841385 errno = 0;1386 char *end = NULL;1387 uint32_t background = strtoul(clr_start, &end, 16);1388 if (errno != 0 || end == NULL || *end != '\0' || (end - clr_start) != 8) {1389 fprintf(stderr, "background-color: %s: invalid color\n",1390 optarg);1391 return EXIT_FAILURE;1392 }1393 cmdline_overrides.conf.colors.background =1394 conf_hex_to_rgba(background);1395 cmdline_overrides.background_color_set = true;1396 break;1397 }13981399 case 't': {1400 const char *clr_start = optarg;1401 if (clr_start[0] == '#')1402 clr_start++;14031404 errno = 0;1405 char *end = NULL;1406 uint32_t text_color = strtoul(clr_start, &end, 16);1407 if (errno != 0 || end == NULL || *end != '\0' || (end - clr_start) != 8) {1408 fprintf(stderr, "text-color: %s: invalid color\n", optarg);1409 return EXIT_FAILURE;1410 }1411 cmdline_overrides.conf.colors.text = conf_hex_to_rgba(text_color);1412 cmdline_overrides.text_color_set = true;1413 break;1414 }1415config: add --mesg, --mesg-mode and --message-color command line optionsSlayerOfTheBadbefore adoption9fb7e6c
lines 1416–1432why, one step back1416 case OPT_MESSAGE_COLOR: {1417 const char *clr_start = optarg;1418 if (clr_start[0] == '#')1419 clr_start++;14201421 errno = 0;1422 char *end = NULL;1423 uint32_t message_color = strtoul(clr_start, &end, 16);1424 if (errno != 0 || end == NULL || *end != '\0' || (end - clr_start) != 8) {1425 fprintf(stderr, "message-color: %s: invalid color\n", optarg);1426 return EXIT_FAILURE;1427 }1428 cmdline_overrides.conf.colors.message = conf_hex_to_rgba(message_color);1429 cmdline_overrides.message_color_set = true;1430 break;1431 }1432changelog: add missing refDaniel Eklöfbefore adoption6a4c416
lines 1433–1538why, one step back1433 case OPT_PROMPT_COLOR: {1434 const char *clr_start = optarg;1435 if (clr_start[0] == '#')1436 clr_start++;14371438 errno = 0;1439 char *end = NULL;1440 uint32_t prompt_color = strtoul(clr_start, &end, 16);1441 if (errno != 0 || end == NULL || *end != '\0' || (end - clr_start) != 8) {1442 fprintf(stderr, "prompt-color: %s: invalid color\n", optarg);1443 return EXIT_FAILURE;1444 }1445 cmdline_overrides.conf.colors.prompt = conf_hex_to_rgba(prompt_color);1446 cmdline_overrides.prompt_color_set = true;1447 break;1448 }14491450 case OPT_PLACEHOLDER_COLOR: {1451 const char *clr_start = optarg;1452 if (clr_start[0] == '#')1453 clr_start++;14541455 errno = 0;1456 char *end = NULL;1457 uint32_t placeholder_color = strtoul(clr_start, &end, 16);1458 if (errno != 0 || end == NULL || *end != '\0' || (end - clr_start) != 8) {1459 fprintf(stderr, "placeholder-color: %s: invalid color\n", optarg);1460 return EXIT_FAILURE;1461 }1462 cmdline_overrides.conf.colors.placeholder = conf_hex_to_rgba(placeholder_color);1463 cmdline_overrides.placeholder_color_set = true;1464 break;1465 }14661467 case OPT_INPUT_COLOR: {1468 const char *clr_start = optarg;1469 if (clr_start[0] == '#')1470 clr_start++;14711472 errno = 0;1473 char *end = NULL;1474 uint32_t input_color = strtoul(clr_start, &end, 16);1475 if (errno != 0 || end == NULL || *end != '\0' || (end - clr_start) != 8) {1476 fprintf(stderr, "prompt-color: %s: invalid color\n", optarg);1477 return EXIT_FAILURE;1478 }1479 cmdline_overrides.conf.colors.input = conf_hex_to_rgba(input_color);1480 cmdline_overrides.input_color_set = true;1481 break;1482 }14831484 case 'm': {1485 const char *clr_start = optarg;1486 if (clr_start[0] == '#')1487 clr_start++;14881489 errno = 0;1490 char *end = NULL;1491 uint32_t match_color = strtoul(clr_start, &end, 16);1492 if (errno != 0 || end == NULL || *end != '\0' || (end - clr_start) != 8) {1493 fprintf(stderr, "match-color: %s: invalid color\n", optarg);1494 return EXIT_FAILURE;1495 }1496 cmdline_overrides.conf.colors.match =1497 conf_hex_to_rgba(match_color);1498 cmdline_overrides.match_color_set = true;1499 break;1500 }15011502 case 's': {1503 const char *clr_start = optarg;1504 if (clr_start[0] == '#')1505 clr_start++;15061507 errno = 0;1508 char *end = NULL;1509 uint32_t selection_color = strtoul(clr_start, &end, 16);1510 if (errno != 0 || end == NULL || *end != '\0' || (end - clr_start) != 8) {1511 fprintf(stderr, "selection-color: %s: invalid color\n", optarg);1512 return EXIT_FAILURE;1513 }1514 cmdline_overrides.conf.colors.selection =1515 conf_hex_to_rgba(selection_color);1516 cmdline_overrides.selection_color_set = true;1517 break;1518 }15191520 case 'S': {1521 const char *clr_start = optarg;1522 if (clr_start[0] == '#')1523 clr_start++;15241525 errno = 0;1526 char *end = NULL;1527 uint32_t selection_text_color = strtoul(clr_start, &end, 16);1528 if (errno != 0 || end == NULL || *end != '\0' || (end - clr_start) != 8) {1529 fprintf(stderr, "selection-text-color: %s: invalid color\n",1530 optarg);1531 return EXIT_FAILURE;1532 }1533 cmdline_overrides.conf.colors.selection_text =1534 conf_hex_to_rgba(selection_text_color);1535 cmdline_overrides.selection_text_color_set = true;1536 break;1537 }1538feat: border radius for selected entrieswisplbefore adoption9836d81
lines 1539–1548why, one step back1539 case OPT_SELECTION_RADIUS: {1540 if (sscanf(optarg, "%u", &cmdline_overrides.conf.selection_border.radius) != 1) {1541 fprintf(stderr, "%s: invalid selection border radius (must be an integer)\n",1542 optarg);1543 return EXIT_FAILURE;1544 }1545 cmdline_overrides.selection_border_radius_set = true;1546 break;1547 }1548changelog: add missing refDaniel Eklöfbefore adoption6a4c416
lines 1549–1726why, one step back1549 case 'M': {1550 const char *clr_start = optarg;1551 if (clr_start[0] == '#')1552 clr_start++;15531554 errno = 0;1555 char *end = NULL;1556 uint32_t selection_match_color = strtoul(clr_start, &end, 16);1557 if (errno != 0 || end == NULL || *end != '\0' || (end - clr_start) != 8) {1558 fprintf(stderr, "selection-match-color: %s: invalid color\n",1559 optarg);1560 return EXIT_FAILURE;1561 }1562 cmdline_overrides.conf.colors.selection_match =1563 conf_hex_to_rgba(selection_match_color);1564 cmdline_overrides.selection_match_color_set = true;1565 break;1566 }15671568 case OPT_COUNTER_COLOR: {1569 const char *clr_start = optarg;1570 if (clr_start[0] == '#')1571 clr_start++;15721573 errno = 0;1574 char *end = NULL;1575 uint32_t count_color = strtoul(clr_start, &end, 16);1576 if (errno != 0 || end == NULL || *end != '\0' || (end - clr_start) != 8) {1577 fprintf(stderr, "counter-color: %s: invalid color\n",1578 optarg);1579 return EXIT_FAILURE;1580 }1581 cmdline_overrides.conf.colors.counter = conf_hex_to_rgba(count_color);1582 cmdline_overrides.counter_color_set = true;1583 break;1584 }158515861587 case 'B':1588 if (sscanf(optarg, "%u", &cmdline_overrides.conf.border.size) != 1) {1589 fprintf(1590 stderr,1591 "%s: invalid border width (must be an integer)\n", optarg);1592 return EXIT_FAILURE;1593 }1594 cmdline_overrides.border_size_set = true;1595 break;15961597 case 'r':1598 if (sscanf(optarg, "%u", &cmdline_overrides.conf.border.radius) != 1) {1599 fprintf(stderr, "%s: invalid border radius (must be an integer)\n",1600 optarg);1601 return EXIT_FAILURE;1602 }1603 cmdline_overrides.border_radius_set = true;1604 break;16051606 case 'C': {1607 const char *clr_start = optarg;1608 if (clr_start[0] == '#')1609 clr_start++;16101611 errno = 0;1612 char *end = NULL;1613 uint32_t border_color = strtoul(clr_start, &end, 16);1614 if (errno != 0 || end == NULL || *end != '\0' || (end - clr_start) != 8) {1615 fprintf(stderr, "border-color: %s: invalid color\n", optarg);1616 return EXIT_FAILURE;1617 }1618 cmdline_overrides.conf.colors.border =1619 conf_hex_to_rgba(border_color);1620 cmdline_overrides.border_color_set = true;1621 break;1622 }16231624 case OPT_SHOW_ACTIONS:1625 cmdline_overrides.actions_enabled_set = true;1626 cmdline_overrides.conf.actions_enabled = true;1627 break;16281629 case OPT_MATCH_MODE:1630 if (strcmp(optarg, "exact") == 0)1631 cmdline_overrides.conf.match_mode = MATCH_MODE_EXACT;1632 else if (strcmp(optarg, "fzf") == 0)1633 cmdline_overrides.conf.match_mode = MATCH_MODE_FZF;1634 else if (strcmp(optarg, "fuzzy") == 0)1635 cmdline_overrides.conf.match_mode = MATCH_MODE_FUZZY;1636 else {1637 fprintf(stderr, "%s: invalid match-mode. Must be 'exact', 'fuzzy' or 'fzf'\n", optarg);1638 return EXIT_FAILURE;1639 }16401641 cmdline_overrides.match_mode_set = true;1642 break;16431644 case OPT_FILTER_DESKTOP:1645 cmdline_overrides.filter_desktop_set = true;1646 if (optarg != NULL && strcasecmp(optarg, "no") == 0)1647 cmdline_overrides.conf.filter_desktop = false;1648 else if (optarg != NULL) {1649 fprintf(stderr, "%s: invalid filter-desktop option\n", optarg);1650 return EXIT_FAILURE;1651 }1652 else1653 cmdline_overrides.conf.filter_desktop = true;1654 break;16551656 case OPT_FUZZY_MIN_LENGTH:1657 if (sscanf(optarg, "%zu", &cmdline_overrides.conf.fuzzy.min_length) != 1) {1658 fprintf(1659 stderr,1660 "%s: invalid fuzzy min length (must be an integer)\n",1661 optarg);1662 return EXIT_FAILURE;1663 }1664 cmdline_overrides.fuzzy_min_length_set = true;1665 break;16661667 case OPT_FUZZY_MAX_LENGTH_DISCREPANCY:1668 if (sscanf(optarg, "%zu", &cmdline_overrides.conf.fuzzy.max_length_discrepancy) != 1) {1669 fprintf(1670 stderr,1671 "%s: invalid fuzzy max length discrepancy "1672 "(must be an integer)\n", optarg);1673 return EXIT_FAILURE;1674 }1675 cmdline_overrides.fuzzy_max_length_discrepancy_set = true;1676 break;16771678 case OPT_FUZZY_MAX_DISTANCE:1679 if (sscanf(optarg, "%zu", &cmdline_overrides.conf.fuzzy.max_distance) != 1) {1680 fprintf(1681 stderr,1682 "%s: invalid fuzzy max distance (must be an integer)\n",1683 optarg);1684 return EXIT_FAILURE;1685 }1686 cmdline_overrides.fuzzy_max_distance_set = true;1687 break;16881689 case OPT_LIST_EXECS_IN_PATH:1690 cmdline_overrides.conf.list_executables_in_path = true;1691 break;16921693 case 'H': { /* line-height */1694 if (!pt_or_px_from_string(optarg, &cmdline_overrides.conf.line_height))1695 return EXIT_FAILURE;1696 cmdline_overrides.line_height_set = true;1697 break;1698 }16991700 case OPT_LETTER_SPACING: {1701 if (!pt_or_px_from_string(optarg, &cmdline_overrides.conf.letter_spacing))1702 return EXIT_FAILURE;1703 cmdline_overrides.letter_spacing_set = true;1704 break;1705 }17061707 case OPT_LAUNCH_PREFIX: {1708 cmdline_overrides.conf.launch_prefix = optarg;1709 break;1710 }17111712 case OPT_LAYER:1713 if (strcasecmp(optarg, "top") == 0)1714 cmdline_overrides.conf.layer = ZWLR_LAYER_SHELL_V1_LAYER_TOP;1715 else if (strcasecmp(optarg, "overlay") == 0)1716 cmdline_overrides.conf.layer = ZWLR_LAYER_SHELL_V1_LAYER_OVERLAY;1717 else {1718 fprintf(1719 stderr,1720 "%s: invalid layer. Must be one of 'top', 'overlay'\n",1721 optarg);1722 return EXIT_FAILURE;1723 }1724 cmdline_overrides.layer_set = true;1725 break;1726Add `keyboard-focus=exclusive|on-demand` command line and config optionbbb651before adoption9a0a38d
lines 1727–1741why, one step back1727 case OPT_KEYBOARD_FOCUS:1728 if (strcasecmp(optarg, "exclusive") == 0)1729 cmdline_overrides.conf.keyboard_focus = ZWLR_LAYER_SURFACE_V1_KEYBOARD_INTERACTIVITY_EXCLUSIVE;1730 else if (strcasecmp(optarg, "on-demand") == 0)1731 cmdline_overrides.conf.keyboard_focus = ZWLR_LAYER_SURFACE_V1_KEYBOARD_INTERACTIVITY_ON_DEMAND;1732 else {1733 fprintf(1734 stderr,1735 "%s: invalid keyboard-focus. Must be one of 'exclusive', 'on-demand'\n",1736 optarg);1737 return EXIT_FAILURE;1738 }1739 cmdline_overrides.keyboard_focus_set = true;1740 break;1741changelog: add missing refDaniel Eklöfbefore adoption6a4c416
lines 1742–1768why, one step back1742 case OPT_NO_EXIT_ON_KB_LOSS:1743 cmdline_overrides.conf.exit_on_kb_focus_loss = false;1744 cmdline_overrides.no_exit_on_keyboard_focus_loss_set = true;1745 break;17461747 case 'd':1748 cmdline_overrides.conf.dmenu.enabled = true;1749 cmdline_overrides.dmenu_enabled_set = true;1750 break;17511752 case OPT_DMENU_NULL:1753 cmdline_overrides.conf.dmenu.enabled = true;1754 cmdline_overrides.conf.dmenu.delim = '\0';1755 cmdline_overrides.dmenu_enabled_set = true;1756 cmdline_overrides.dmenu_delim_set = true;1757 break;17581759 case 'R':1760 cmdline_overrides.conf.dmenu.exit_immediately_if_empty = true;1761 cmdline_overrides.dmenu_exit_immediately_if_empty_set = true;1762 break;17631764 case OPT_DMENU_INDEX:1765 cmdline_overrides.conf.dmenu.mode = DMENU_MODE_INDEX;1766 cmdline_overrides.dmenu_mode_set = true;1767 break;1768config: --nth-delimiter=CHRDaniel Eklöfbefore adoption2dd56d8
lines 1769–1781why, one step back1769 case OPT_DMENU_NTH_DELIM:1770 if (strlen(optarg) != 1) {1771 fprintf(1772 stderr,1773 "%s: invalid nth-delimiter. Must be a single ASCII character",1774 optarg);1775 return EXIT_FAILURE;1776 }17771778 cmdline_overrides.conf.dmenu.nth_delim = optarg[0];1779 cmdline_overrides.dmenu_nth_delim_set = true;1780 break;1781Rework --accept-nth and --with-nth to accept a format stringDaniel Eklöfbefore adoption4929e73
line 1782why, one step back1782 case OPT_DMENU_WITH_NTH: {main: regression: --{with,accept}-nth=0 should be "ignored" (#671)Daniel Eklöfbefore adoption2a61d78
lines 1783–1785why, one step back1783 free(cmdline_overrides.conf.dmenu.with_nth_format);1784 cmdline_overrides.conf.dmenu.with_nth_format = NULL;1785Rework --accept-nth and --with-nth to accept a format stringDaniel Eklöfbefore adoption4929e73
line 1786why, one step back1786 unsigned int with_nth_idx;main: regression: --{with,accept}-nth=0 should be "ignored" (#671)Daniel Eklöfbefore adoption2a61d78
lines 1787–1794why, one step back1787 if (sscanf(optarg, "%u", &with_nth_idx) == 1) {1788 if (with_nth_idx == 0) {1789 /* Do nothing more - i.e. leave it unset */1790 } else {1791 cmdline_overrides.conf.dmenu.with_nth_format =1792 xasprintf("{%u}", with_nth_idx);1793 }1794 } else if (optarg[0] != '\0')Rework --accept-nth and --with-nth to accept a format stringDaniel Eklöfbefore adoption4929e73
line 1795why, one step back1795 cmdline_overrides.conf.dmenu.with_nth_format = xstrdup(optarg);changelog: add missing refDaniel Eklöfbefore adoption6a4c416
lines 1796–1797why, one step back1796 cmdline_overrides.dmenu_with_nth_set = true;1797 break;Rework --accept-nth and --with-nth to accept a format stringDaniel Eklöfbefore adoption4929e73
line 1798why, one step back1798 }changelog: add missing refDaniel Eklöfbefore adoption6a4c416
line 1799why, one step back1799Rework --accept-nth and --with-nth to accept a format stringDaniel Eklöfbefore adoption4929e73
line 1800why, one step back1800 case OPT_DMENU_ACCEPT_NTH: {main: regression: --{with,accept}-nth=0 should be "ignored" (#671)Daniel Eklöfbefore adoption2a61d78
lines 1801–1803why, one step back1801 free(cmdline_overrides.conf.dmenu.accept_nth_format);1802 cmdline_overrides.conf.dmenu.accept_nth_format = NULL;1803Rework --accept-nth and --with-nth to accept a format stringDaniel Eklöfbefore adoption4929e73
line 1804why, one step back1804 unsigned int accept_nth_idx;main: regression: --{with,accept}-nth=0 should be "ignored" (#671)Daniel Eklöfbefore adoption2a61d78
lines 1805–1812why, one step back1805 if (sscanf(optarg, "%u", &accept_nth_idx) == 1) {1806 if (accept_nth_idx == 0) {1807 /* Do nothing more - i.e. leave it unset */1808 } else {1809 cmdline_overrides.conf.dmenu.accept_nth_format =1810 xasprintf("{%u}", accept_nth_idx);1811 }1812 } else if (optarg[0] != '\0')Rework --accept-nth and --with-nth to accept a format stringDaniel Eklöfbefore adoption4929e73
line 1813why, one step back1813 cmdline_overrides.conf.dmenu.accept_nth_format = xstrdup(optarg);main: regression: --{with,accept}-nth=0 should be "ignored" (#671)Daniel Eklöfbefore adoption2a61d78
line 1814why, one step back1814Rework --accept-nth and --with-nth to accept a format stringDaniel Eklöfbefore adoption4929e73
lines 1815–1817why, one step back1815 cmdline_overrides.dmenu_accept_nth_set = true;1816 break;1817 }Add `--accept-nth` command line option to select column to outputbbb651before adoption33c9b8e
line 1818why, one step back1818dmenu: add support for --match-nthDaniel Eklöfbefore adoptionc006428
lines 1819–1837why, one step back1819 case OPT_DMENU_MATCH_NTH: {1820 free(cmdline_overrides.conf.dmenu.match_nth_format);1821 cmdline_overrides.conf.dmenu.match_nth_format = NULL;18221823 unsigned int match_nth_idx;1824 if (sscanf(optarg, "%u", &match_nth_idx) == 1) {1825 if (match_nth_idx == 0) {1826 /* Do nothing more - i.e. leave it unset */1827 } else {1828 cmdline_overrides.conf.dmenu.match_nth_format =1829 xasprintf("{%u}", match_nth_idx);1830 }1831 } else if (optarg[0] != '\0')1832 cmdline_overrides.conf.dmenu.match_nth_format = xstrdup(optarg);18331834 cmdline_overrides.dmenu_match_nth_set = true;1835 break;1836 }1837dmenu: add --only-matchDaniel Eklöfbefore adoptionce5dd7f
lines 1838–1842why, one step back1838 case OPT_DMENU_ONLY_MATCH:1839 cmdline_overrides.conf.dmenu.only_match = true;1840 cmdline_overrides.dmenu_only_match_set = true;1841 break;1842config: add --mesg, --mesg-mode and --message-color command line optionsSlayerOfTheBadbefore adoption9fb7e6c
lines 1843–1866why, one step back1843 case OPT_DMENU_MESSAGE:1844 free(cmdline_overrides.conf.message);1845 cmdline_overrides.conf.message = ambstoc32(optarg);18461847 if (cmdline_overrides.conf.message == NULL) {1848 fprintf(stderr, "%s: invalid dmenu message\n", optarg);1849 return EXIT_FAILURE;1850 }18511852 break;18531854 case OPT_DMENU_MESSAGE_MODE:1855 if (strcmp(optarg, "wrap") == 0)1856 cmdline_overrides.conf.message_mode = MESSAGE_MODE_WRAP;1857 else if (strcmp(optarg, "expand") == 0)1858 cmdline_overrides.conf.message_mode = MESSAGE_MODE_EXPAND;1859 else {1860 fprintf(stderr, "%s: invalid mesg-mode. Must be 'wrap' or 'expand'\n", optarg);1861 return EXIT_FAILURE;1862 }18631864 cmdline_overrides.mesg_mode_set = true;1865 break;1866changelog: add missing refDaniel Eklöfbefore adoption6a4c416
lines 1867–1948why, one step back1867 case OPT_LOG_LEVEL: {1868 int lvl = log_level_from_string(optarg);1869 if (lvl < 0) {1870 fprintf(1871 stderr,1872 "--log-level: %s: argument must be one of %s\n",1873 optarg, log_level_string_hint());1874 return EXIT_FAILURE;1875 }1876 log_level = lvl;1877 break;1878 }18791880 case OPT_LOG_COLORIZE:1881 if (optarg == NULL || strcmp(optarg, "auto") == 0)1882 log_colorize = LOG_COLORIZE_AUTO;1883 else if (strcmp(optarg, "never") == 0)1884 log_colorize = LOG_COLORIZE_NEVER;1885 else if (strcmp(optarg, "always") == 0)1886 log_colorize = LOG_COLORIZE_ALWAYS;1887 else {1888 fprintf(stderr, "--log-colorize: %s: argument must be one of 'never', 'always' or 'auto'\n", optarg);1889 return EXIT_FAILURE;1890 }1891 break;18921893 case OPT_LOG_NO_SYSLOG:1894 log_syslog = false;1895 break;18961897 case OPT_RENDER_WORKERS:1898 if (sscanf(optarg, "%hu", &cmdline_overrides.conf.render_worker_count) != 1) {1899 fprintf(1900 stderr,1901 "%s: invalid value for render-workers (must be an integer)\n",1902 optarg);1903 return EXIT_FAILURE;1904 }19051906 cmdline_overrides.render_workers_set = true;1907 break;19081909 case OPT_MATCH_WORKERS:1910 if (sscanf(optarg, "%hu", &cmdline_overrides.conf.match_worker_count) != 1) {1911 fprintf(1912 stderr,1913 "%s: invalid value for match-workers (must be an integer)\n",1914 optarg);1915 return EXIT_FAILURE;1916 }19171918 cmdline_overrides.match_workers_set = true;1919 break;19201921 case OPT_NO_SORT:1922 cmdline_overrides.conf.sort_result = false;1923 cmdline_overrides.no_sort_set = true;1924 break;19251926 case OPT_COUNTER:1927 cmdline_overrides.conf.match_counter = true;1928 cmdline_overrides.counter_set = true;1929 break;19301931 case OPT_DELAYED_FILTER_MS:1932 if (sscanf(optarg, "%u", &cmdline_overrides.conf.delayed_filter_ms) != 1) {1933 fprintf(stderr, "%s: invalid delayed-filter-ms (must be an integer)\n",1934 optarg);1935 return EXIT_FAILURE;1936 }1937 cmdline_overrides.delayed_filter_ms_set = true;1938 break;19391940 case OPT_DELAYED_FILTER_LIMIT:1941 if (sscanf(optarg, "%u", &cmdline_overrides.conf.delayed_filter_limit) != 1) {1942 fprintf(stderr, "%s: invalid delayed-filter-limit (must be an integer)\n",1943 optarg);1944 return EXIT_FAILURE;1945 }1946 cmdline_overrides.delayed_filter_limit_set = true;1947 break;1948config: add scaling-filter optionDaniel Eklöfbefore adoption3866f60
lines 1949–1974why, one step back1949 case OPT_SCALING_FILTER:1950 if (strcmp(optarg, "none") == 0)1951 cmdline_overrides.conf.png_scaling_filter = SCALING_FILTER_NONE;1952 else if (strcmp(optarg, "nearest") == 0)1953 cmdline_overrides.conf.png_scaling_filter = SCALING_FILTER_NEAREST;1954 else if (strcmp(optarg, "bilinear") == 0)1955 cmdline_overrides.conf.png_scaling_filter = SCALING_FILTER_BILINEAR;1956 else if (strcmp(optarg, "box") == 0)1957 cmdline_overrides.conf.png_scaling_filter = SCALING_FILTER_BOX;1958 else if (strcmp(optarg, "linear") == 0)1959 cmdline_overrides.conf.png_scaling_filter = SCALING_FILTER_LINEAR;1960 else if (strcmp(optarg, "cubic") == 0)1961 cmdline_overrides.conf.png_scaling_filter = SCALING_FILTER_CUBIC;1962 else if (strcmp(optarg, "lanczos2") == 0)1963 cmdline_overrides.conf.png_scaling_filter = SCALING_FILTER_LANCZOS2;1964 else if (strcmp(optarg, "lanczos3") == 0)1965 cmdline_overrides.conf.png_scaling_filter = SCALING_FILTER_LANCZOS3;1966 else if (strcmp(optarg, "lanczos3-stretched") == 0)1967 cmdline_overrides.conf.png_scaling_filter = SCALING_FILTER_LANCZOS3_STRETCHED;1968 else {1969 fprintf(stderr, "%s: invalid scaling-filter", optarg);1970 return EXIT_FAILURE;1971 }1972 cmdline_overrides.scaling_filter_set = true;1973 break;1974debug: add a --print-timing-info command line optionDaniel Eklöfbefore adoption1ea01b1
lines 1975–1979why, one step back1975 case OPT_PRINT_TIMINGS:1976 cmdline_overrides.conf.print_timing_info = true;1977 cmdline_overrides.print_timing_info_set = true;1978 break;1979✨ Add --auto-select opt. When one entry is left, automatically select it.Mark Stosbergbefore adoption5751a65
lines 1980–1983why, one step back1980 case OPT_AUTO_SELECT:1981 cmdline_overrides.conf.auto_select = true;1982 break;1983feat: config/cli option to disable mouse inputGingehbefore adoption8c9e76d
lines 1984–1988why, one step back1984 case OPT_NO_MOUSE:1985 cmdline_overrides.conf.enable_mouse = false;1986 cmdline_overrides.no_mouse_set = true;1987 break;1988main: add --override=[section.]key=value command line optionDaniel Eklöfbefore adoption5df0df2
lines 1989–1992why, one step back1989 case OPT_GENERIC_OVERRIDE:1990 tll_push_back(generic_overrides, strdup(optarg));1991 break;1992changelog: add missing refDaniel Eklöfbefore adoption6a4c416
lines 1993–2010why, one step back1993 case 'v':1994 printf("fuzzel %s\n", version_and_features());1995 return EXIT_SUCCESS;19961997 case 'h':1998 print_usage(argv[0]);1999 return EXIT_SUCCESS;2000The first 2,000 of 2,452 lines.