Skip to content
Myr

main.c

This file

Path

main.c

2,279 lines · 83.3 KiB · C

Last changed by

feat: border radius for selected entrieswisplbefore adoption9836d81

History of this file

Take it

1#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>18#include <sys/time.h>19#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"4445#define max(x, y) ((x) > (y) ? (x) : (y))46#define min(x, y) ((x)  < (y) ? (x) : (y))4748struct context {49    struct config *conf;50    const char *cache_path;51    struct wayland *wayl;52    struct render *render;53    struct matches *matches;54    struct application_list *apps;5556    icon_theme_list_t *themes;57    int icon_size;58    mtx_t *icon_lock;5960    const char *select_initial;61    const size_t select_initial_idx;6263    int event_fd;64    int dmenu_abort_fd;6566    struct {67        struct {68            struct timeval start;69            struct timeval stop;70            struct timeval diff;71        } apps;72        struct {73            struct timeval start;74            struct timeval stop;75            struct timeval diff;76        } icons_theme;77        struct {78            struct timeval start;79            struct timeval stop;80            struct timeval diff;81        } icons;82    } timing;83};8485struct cache_entry {86    char *id;87    char32_t *title;88    size_t count;89};9091static void92read_cache(const char *path, struct application_list *apps, bool dmenu)93{94    if (path == NULL && dmenu) {95        /* Don't thrash "normal" cache in dmenu mode */96        return;97    }9899    struct stat st;100    FILE *f = NULL;101102    if (path == NULL) {103        path = xdg_cache_dir();104        if (path == NULL) {105            LOG_WARN("failed to get cache directory: not saving popularity cache");106            return;107        }108109        int cache_dir_fd = open(path, O_DIRECTORY | O_CLOEXEC);110        if (cache_dir_fd == -1) {111            LOG_ERRNO("%s: failed to open", path);112            return;113        }114115        int fd = -1;116        if (fstatat(cache_dir_fd, "fuzzel", &st, 0) < 0 ||117            (fd = openat(cache_dir_fd, "fuzzel", O_RDONLY | O_CLOEXEC)) < 0 ||118            (f = fdopen(fd, "r")) == NULL)119        {120            close(cache_dir_fd);121            if (fd >= 0)122                close(fd);123124            if (errno != ENOENT)125                LOG_ERRNO("%s/fuzzel: failed to open", path);126            return;127        }128        close(cache_dir_fd);129    } else {130        if (stat(path, &st) < 0 || (f = fopen(path, "re")) == NULL)131        {132            if (errno != ENOENT)133                LOG_ERRNO("%s: failed to open", path);134            return;135        }136    }137138    tll(struct cache_entry) cache_entries = tll_init();139140    size_t line_sz = 0;141    char *line = NULL;142143    while (true) {144        errno = 0;145        ssize_t bytes = getline(&line, &line_sz, f);146147        if (bytes < 0) {148            if (errno != 0) {149                LOG_ERRNO("failed to read cache");150                fclose(f);151                free(line);152                return;153            }154155            /* Done */156            break;157        }158159        if (line[bytes - 1] == '\n')160            line[bytes - 1] = '\0';161162        /* Parse each line ("<title>|<count>") */163        char *ptr = NULL;164        const char *id = strtok_r(line, "|", &ptr);165        const char *count_str = strtok_r(NULL, "|", &ptr);166167        if (id == NULL || count_str == NULL) {168            LOG_ERR("invalid cache entry (cache corrupt?): %s", line);169            continue;170        }171172        int count;173        sscanf(count_str, "%u", &count);174175        struct cache_entry entry = {176            .id = dmenu ? NULL : xstrdup(id),177            .title = dmenu ? ambstoc32(id) : NULL,178            .count = count,179        };180        tll_push_back(cache_entries, entry);181    }182183    free(line);184    fclose(f);185186    /* Loop all applications, and search for a matching cache entry */187    for (size_t i = 0; i < apps->count; i++) {188        struct application *app = apps->v[i];189190        if ((!dmenu && app->id == NULL) || (dmenu && app->title == NULL)) {191            continue;192        }193194        tll_foreach(cache_entries, it) {195            const struct cache_entry *e = &it->item;196            if ((!dmenu && e->id == NULL) || (dmenu && e->title == NULL))197                continue;198199            if ((!dmenu && strcmp(app->id, e->id) == 0) ||200                (dmenu && c32cmp(app->title, e->title) == 0))201            {202                app->count = e->count;203204                free(e->id);205                free(e->title);206                tll_remove(cache_entries, it);207                break;208            }209        }210    }211212    /* Free all un-matched cache entries */213    tll_foreach(cache_entries, it) {214        free(it->item.id);215        tll_remove(cache_entries, it);216    }217}218219static void220write_cache(const char *path, const struct application_list *apps, bool dmenu)221{222    if (path == NULL && dmenu) {223        /* Don't thrash "normal" cache in dmenu mode */224        return;225    }226227    int fd = -1;228229    if (path == NULL) {230        path = xdg_cache_dir();231        if (path == NULL) {232            LOG_WARN("failed to get cache directory: not saving popularity cache");233            return;234        }235236        int cache_dir_fd = open(path, O_DIRECTORY | O_CLOEXEC);237        if (cache_dir_fd == -1) {238            LOG_ERRNO("%s: failed to open", path);239            return;240        }241242        fd = openat(cache_dir_fd, "fuzzel", O_WRONLY | O_CREAT | O_TRUNC | O_CLOEXEC, 0644);243        close(cache_dir_fd);244    } else {245        fd = open(path, O_WRONLY | O_CREAT | O_TRUNC | O_CLOEXEC, 0644);246    }247248    if (fd == -1) {249        LOG_ERRNO("%s/fuzzel: failed to open", path);250        return;251    }252253    for (size_t i = 0; i < apps->count; i++) {254        if (apps->v[i]->count == 0)255            continue;256257        if (!apps->v[i]->visible)258            continue;259260        if (!dmenu && apps->v[i]->id == NULL)261            continue;262263        if (dmenu && apps->v[i]->title == NULL)264            continue;265266        if (!dmenu) {267            const char *id = apps->v[i]->id;268            const size_t id_len = strlen(id);269270            if (write(fd, id, id_len) != id_len) {271                LOG_ERRNO("failed to write cache");272                break;273            }274        } else {275            const char32_t *title = apps->v[i]->title;276            char *u8_title = ac32tombs(title);277278            if (u8_title != NULL) {279                const size_t title_len = strlen(u8_title);280                if (write(fd, u8_title, title_len) != title_len) {281                    LOG_ERRNO("failed to write cache");282                    break;283                }284285                free(u8_title);286            }287        }288289        char count_as_str[11];290        const size_t count_len = xsnprintf(291            count_as_str, sizeof(count_as_str), "%u", apps->v[i]->count);292293        if (write(fd, "|", 1) != 1 ||294            write(fd, count_as_str, count_len) != count_len ||295            write(fd, "\n", 1) != 1)296        {297            LOG_ERRNO("failed to write cache");298            break;299        }300    }301302    close(fd);303}304305static const char *306version_and_features(void)307{308    static char buf[256];309    xsnprintf(buf, sizeof(buf), "version: %s %ccairo %cpng %csvg%s %cassertions",310             FUZZEL_VERSION,311#if defined(FUZZEL_ENABLE_CAIRO)312             '+',313#else314             '-',315#endif316#if defined(FUZZEL_ENABLE_PNG_LIBPNG)317             '+',318#else319             '-',320#endif321#if defined(FUZZEL_ENABLE_SVG_NANOSVG)322             '+', "(nanosvg)",323#elif defined(FUZZEL_ENABLE_SVG_LIBRSVG)324             '+', "(librsvg)",325#else326             '-', "",327#endif328#if !defined(NDEBUG)329             '+'330#else331             '-'332#endif333        );334    return buf;335}336337static void338print_usage(const char *prog_name)339{340    printf("Usage: %s [OPTION]...\n", prog_name);341    printf("\n");342    printf("Options:\n");343    printf("     --config=PATH               load configuration from PATH\n"344           "                                 (XDG_CONFIG_HOME/fuzzel/fuzzel.ini)\n"345           "     --check-config              verify configuration, exit with 0 if ok,\n"346           "                                 otherwise exit with 1\n"347           "     --cache=PATH                load most recently launched applications from\n"348           "                                 PATH (XDG_CACHE_HOME/fuzzel)\n"349           "  -n,--namespace=NAMESPACE       layer shell surface namespace\n"350           "  -o,--output=OUTPUT             output (monitor) to display on (none)\n"351           "  -f,--font=FONT                 font name and style, in FontConfig format\n"352           "                                 (monospace)\n"353           "     --use-bold                  allow fuzzel to use bold fonts\n"354           "  -D,--dpi-aware=no|yes|auto     enable or disable DPI aware rendering (auto)\n"355           "     --icon-theme=NAME           icon theme name (\"default\")\n"356           "  -I,--no-icons                  do not render any icons\n"357           "     --hide-before-typing    hide application list until something is typed\n"358           "  -F,--fields=FIELDS             comma separated list of XDG Desktop entry\n"359           "                                 fields to match\n"360           "  -p,--prompt=PROMPT             string to use as input prompt (\"> \")\n"361           "     --prompt-only=PROMPT        same as --prompt, but in dmenu mode it does not\n"362           "                                 wait for STDIN, and implies --lines=0\n"363           "     --placeholder=TEXT          placeholder text in input box\n"364           "     --search=TEXT               initial search/filter string\n"365           "     --password=[CHARACTER]      render all input as CHARACTER ('*' by default)\n"366           "  -T,--terminal                  terminal command to use when launching\n"367           "                                 'terminal' programs, e.g. \"xterm -e\".\n"368           "                                 Not used in dmenu mode (not set)\n"369           "  -a,--anchor                    window anchor (center)\n"370           "     --x-margin=MARGIN           horizontal margin, in pixels (0)\n"371           "     --y-margin=MARGIN           vertical margin, in pixels (0)\n"372           "     --select=STRING             select first entry that matches the given\n"373           "                                 string\n"374           "     --auto-select               automatically select when only one match\n"375           "                                 remains\n"376           "     --select-index=INDEX        select the entry with index, not compatible with --select\n"377           "  -l,--lines                     number of matches to show\n"378           "     --minimal-lines             adjust the number of lines to the\n"379           "                                 minimum of --lines and the number\n"380           "                                 of input lines (dmenu mode only)\n"381           "     --hide-prompt               hide the prompt line, making the window\n"382           "                                 smaller (input still accepted)\n"383           "  -w,--width                     window width, in characters (margins and\n"384           "                                 borders not included)\n"385           "     --tabs=INT                  number of spaces a tab is expanded to (8)\n"386           "  -x,--horizontal-pad=PAD        horizontal padding, in pixels (40)\n"387           "  -y,--vertical-pad=PAD          vertical padding, in pixels (8)\n"388           "  -P,--inner-pad=PAD             vertical padding between prompt and match list,\n"389           "                                 in pixels (0)\n"390           "  -b,--background-color=HEX      background color (fdf6e3ff)\n"391           "  -t,--text-color=HEX            text color of matched entries (657b83ff)\n"392           "     --prompt-color=HEX          text color of the prompt (586e75ff)\n"393           "     --placeholder-color=HEX     text color of the placeholder text (93a1a1)\n"394           "     --input-color=HEX           text color of the input string (657b83ff)\n"395           "  -m,--match-color=HEX           color of matched substring (cb4b16ff)\n"396           "  -s,--selection-color=HEX       background color of selected item (eee8d5ff)\n"397           "  -S,--selection-text-color=HEX  text color of selected item (586e75ff)\n"398           "  -M,--selection-match-color=HEX color of matched substring in selection\n"399           "                                 (cb4b16ff)\n"400           "     --selection-radius          border radius of the selected entry (0)\n"401           "     --counter-color             color of the match count (93a1a1)\n"402           "  -B,--border-width=INT          width of border, in pixels (1)\n"403           "  -r,--border-radius=INT         amount of corner \"roundness\" (10)\n"404           "  -C,--border-color=HEX          border color (002b36ff)\n"405           "     --show-actions              include desktop actions in the list\n"406           "     --match-mode=exact|fzf|fuzzy how to match what you type against the entries\n"407           "     --filter-desktop            filter desktop entries based on XDG_CURRENT\n"408           "     --fuzzy-min-length=VALUE    search strings shorter than this will not be\n"409           "                                 fuzzy matched (3)\n"410           "     --fuzzy-max-length-discrepancy=VALUE  maximum allowed length discrepancy\n"411           "                                           between a fuzzy match and the search\n"412           "                                           criteria. Larger values mean more\n"413           "                                           fuzzy matches (2)\n"414           "     --fuzzy-max-distance=VALUE  maximum levenshtein distance between a fuzzy\n"415           "                                 match and the search criteria. Larger values\n"416           "                                 mean more fuzzy matches\n"417           "     --line-height=HEIGHT        override line height from font metrics\n"418           "     --letter-spacing=AMOUNT     additional letter spacing\n"419           "     --layer=top|overlay         which layer to render the fuzzel window on\n"420           "                                 (top)\n"421           "     --keyboard-focus=exclusive|on-demand  keyboard focus mode (exclusive)\n"422           "     --no-exit-on-keyboard-focus-loss  do not exit when losing keyboard focus\n"423           "     --launch-prefix=COMMAND     prefix to add before argv of executed program\n"424           "     --list-executables-in-path  include executables from PATH in the list\n"425           "     --render-workers=N          number of threads to use for rendering\n"426           "     --match-workers=N           number of threads to use for matching\n"427           "     --no-sort                   do not sort the result\n"428           "     --counter                   display the match count\n"429           "     --delayed-filter-ms=TIME_MS time in ms before refiltering after a keystroke\n"430           "                                 (300)\n"431           "     --delayed-filter-limit=N    used delayed refiltering when the number of\n"432           "                                 matches exceeds this number (10000)\n"433           "     --scaling-filter=FILTER     filter to use when down scaling PNGs\n"434           "  -d,--dmenu                     dmenu compatibility mode\n"435           "     --dmenu0                    like --dmenu, but input is NUL separated\n"436           "                                 instead of newline separated\n"437           "     --index                     print selected entry's index instead of of the \n"438           "                                 entry's text (dmenu mode only)\n"439           "     --with-nth=N                display the N:th column (tab separated) of each\n"440           "                                 input line (dmenu only)\n"441           "     --accept-nth=N              output the N:th column (tab separated) of each\n"442           "                                 input line (dmenu only)\n"443           "  -R,--no-run-if-empty           exit immediately without showing UI if stdin\n"444           "                                 is empty (dmenu mode only)\n"445           "     --log-level={info|warning|error|none}\n"446           "                                 log level (warning)\n"447           "     --log-colorize=[never|always|auto]\n"448           "                                 enable/disable colorization of log output on\n"449           "                                 stderr\n"450           "     --log-no-syslog             disable syslog logging\n"451           "     --print-timing-info         print timing information, to help debug\n"452           "                                 performance issues\n"453           "  -v,--version                   show the version number and quit\n");454    printf("\n");455    printf("All colors are RGBA - i.e. 8-digit hex values, without prefix.\n");456}457458static void459font_reloaded(struct wayland *wayl, struct fcft_font *font, void *data)460{461    struct context *ctx = data;462    const struct config *conf = ctx->conf;463464    applications_flush_text_run_cache(ctx->apps);465    render_flush_text_run_cache(ctx->render);466467    mtx_lock(ctx->icon_lock);468    {469        ctx->icon_size = render_icon_size(ctx->render);470471        if (conf->icons_enabled) {472            icon_lookup_application_icons(473                *ctx->themes, ctx->icon_size, ctx->apps);474475            if (conf->dmenu.enabled) {476                dmenu_try_icon_list(ctx->apps, *ctx->themes, ctx->icon_size);477            }478        }479    }480    mtx_unlock(ctx->icon_lock);481}482483static bool484pt_or_px_from_string(const char  *s, struct pt_or_px *res)485{486    const size_t len = strlen(s);487    if (len >= 2 && s[len - 2] == 'p' && s[len - 1] == 'x') {488        errno = 0;489        char *end = NULL;490491        long value = strtol(s, &end, 10);492        if (!(errno == 0 && end == s + len - 2)) {493            fprintf(stderr, "%s: not a valid pixel value\n", s);494            return false;495        }496497        res->pt = 0;498        res->px = value;499    } else {500        errno = 0;501        char *end = NULL;502503        float value = strtof(s, &end);504        if (!(errno == 0 && *end == '\0')) {505            fprintf(stderr, "%s: not a valid point value\n", s);506            return false;507        }508        res->pt = value;509        res->px = 0;510    }511512    return true;513}514515static char *516lock_file_name(void)517{518    const char *xdg_runtime_dir = getenv("XDG_RUNTIME_DIR");519    if (xdg_runtime_dir == NULL)520        xdg_runtime_dir = "/tmp";521522    const char *wayland_display = getenv("WAYLAND_DISPLAY");523    if (wayland_display == NULL)524        return NULL;525526    char *path = xasprintf("%s/fuzzel-%s.lock", xdg_runtime_dir, wayland_display);527    LOG_DBG("lock file: %s", path);528    return path;529}530531static bool532acquire_file_lock(const char *path, int *fd)533{534    *fd = open(path, O_WRONLY | O_CREAT | O_CLOEXEC, 0644);535    if (*fd < 0) {536        /* Warn, but allow running anyway */537        LOG_WARN("%s: failed to create lock file: %s", path, strerror(errno));538        return true;539    }540541    if (flock(*fd, LOCK_EX | LOCK_NB) < 0) {542        if (errno == EWOULDBLOCK) {543            /* The file is locked and the LOCK_NB flag was selected */544            LOG_ERR("%s: failed to acquire lock: fuzzel already running?", path);545            return false;546        }547    }548549    return true;550}551552/* THREAD */553static int554populate_apps(void *_ctx)555{556    struct context *ctx = _ctx;557    const char *cache_path = ctx->cache_path;558    struct application_list *apps = ctx->apps;559    const struct config *conf = ctx->conf;560    const char *icon_theme = conf->icon_theme;561    const char *terminal = conf->terminal;562    bool actions_enabled = conf->actions_enabled;563    bool dmenu_enabled = conf->dmenu.enabled;564    bool icons_enabled = conf->icons_enabled;565    char dmenu_delim = conf->dmenu.delim;566    bool filter_desktop = conf->filter_desktop;567    bool list_exec_in_path = conf->list_executables_in_path;568    char_list_t desktops = tll_init();569    char *saveptr = NULL;570571    if (filter_desktop) {572        char *xdg_current_desktop = getenv("XDG_CURRENT_DESKTOP");573        if (xdg_current_desktop && strlen(xdg_current_desktop) != 0) {574            xdg_current_desktop = xstrdup(xdg_current_desktop);575            for (char *desktop = strtok_r(xdg_current_desktop, ":", &saveptr);576                 desktop != NULL;577                 desktop = strtok_r(NULL, ":", &saveptr))578                {579                    tll_push_back(desktops, xstrdup(desktop));580                }581            free(xdg_current_desktop);582        }583    }584585    if (dmenu_enabled) {586        if (!conf->prompt_only) {587            dmenu_load_entries(apps, dmenu_delim, conf->dmenu.render_column,588                               ctx->event_fd, ctx->dmenu_abort_fd);589            read_cache(cache_path, apps, true);590        }591    } else {592        gettimeofday(&ctx->timing.apps.start, NULL);593        xdg_find_programs(terminal, actions_enabled, filter_desktop, &desktops, apps);594        if (list_exec_in_path)595            path_find_programs(apps);596        read_cache(cache_path, apps, false);597        gettimeofday(&ctx->timing.apps.stop, NULL);598        timersub(&ctx->timing.apps.stop, &ctx->timing.apps.start, &ctx->timing.apps.diff);599    }600    tll_free_and_free(desktops, free);601602    int r = send_event(ctx->event_fd, EVENT_APPS_ALL_LOADED);603    if (r != 0)604        return r;605606    if (icons_enabled) {607        gettimeofday(&ctx->timing.icons_theme.start, NULL);608        icon_theme_list_t icon_themes = icon_load_theme(icon_theme, !dmenu_enabled);609        if (tll_length(icon_themes) > 0)610            LOG_INFO("theme: %s", tll_front(icon_themes).name);611        else612            LOG_WARN("%s: icon theme not found", icon_theme);613        gettimeofday(&ctx->timing.icons_theme.stop, NULL);614        timersub(&ctx->timing.icons_theme.stop, &ctx->timing.icons_theme.start, &ctx->timing.icons_theme.diff);615616        gettimeofday(&ctx->timing.icons.start, NULL);617        mtx_lock(ctx->icon_lock);618        {619            *ctx->themes = icon_themes;620            if (ctx->icon_size > 0) {621                icon_lookup_application_icons(622                    *ctx->themes, ctx->icon_size, apps);623624                if (dmenu_enabled) {625                    dmenu_try_icon_list(apps, *ctx->themes, ctx->icon_size);626                }627            }628        }629        mtx_unlock(ctx->icon_lock);630        gettimeofday(&ctx->timing.icons.stop, NULL);631        timersub(&ctx->timing.icons.stop, &ctx->timing.icons.start, &ctx->timing.icons.diff);632633        r = send_event(ctx->event_fd, EVENT_ICONS_LOADED);634        if (r != 0)635            return r;636    }637638    return 0;639}640641static bool642process_event(struct context *ctx, enum event_type event)643{644    const struct config *conf = ctx->conf;645    struct wayland *wayl = ctx->wayl;646    struct application_list *apps = ctx->apps;647    struct matches *matches = ctx->matches;648    const char *select = ctx->select_initial;649    const size_t select_idx = ctx->select_initial_idx;650651    switch (event) {652    case EVENT_APPS_SOME_LOADED:653    case EVENT_APPS_ALL_LOADED: {654        if (event == EVENT_APPS_ALL_LOADED && conf->print_timing_info) {655            LOG_WARN("apps loaded in %llus %lluµs",656                     (unsigned long long)ctx->timing.apps.diff.tv_sec,657                     (unsigned long long)ctx->timing.apps.diff.tv_usec);658        }659        /* Update matches list, then refresh the GUI */660        matches_set_applications(matches, apps);661662        if (event == EVENT_APPS_ALL_LOADED) {663            if (conf->dmenu.exit_immediately_if_empty && apps->count == 0)664                return false;665666            matches_all_applications_loaded(matches);667668            if (conf->dmenu.enabled && conf->minimal_lines) {669                const size_t effective_lines = min(apps->count, conf->lines);670                matches_max_matches_per_page_set(matches, effective_lines);671                ctx->conf->lines = effective_lines;672                wayl_resized(wayl);673            }674675            wayl_ready_to_display(wayl);676        }677678        const size_t match_count = matches_get_count(matches);679        const size_t matches_per_page = matches_max_matches_per_page(matches);680681        if (conf->match_counter ||682            event == EVENT_APPS_ALL_LOADED ||683            match_count < matches_per_page)684        {685            /*686             * Only update matches if687             *   a) we're displaying a match counter688             *   b) all applications have been loaded689             *   c) a partial load will cause more matches to be displayed690             */691            matches_update_no_delay(matches);692            if (select_idx != 0) {693                if (!matches_selected_set(matches, select_idx)) {694                    LOG_ERR("couldn't select entry at index %zu", select_idx);695                    return false;696                }697            }698            else699                matches_selected_select(matches, select);700        }701702        /*703         * Allow displaying the menu if:704         *   --no-run-if-empty is NOT enabled, OR we have at least one entry705         * AND706         *   --minimal-lines is NOT enabled, OR we have at least --lines number of entries707         *708         * In short, display the window as soon as we are sure we709         * won't exit automatically (due to --no-run-if-empty), and we710         * know its final size.711         */712        if ((!conf->dmenu.exit_immediately_if_empty || apps->count > 0) &&713            (!(conf->dmenu.enabled && conf->minimal_lines) ||714             apps->count >= conf->lines))715        {716            wayl_ready_to_display(wayl);717        }718        break;719    }720721    case EVENT_ICONS_LOADED:722        /* Just need to refresh the GUI */723        if (conf->print_timing_info) {724            LOG_WARN("icon themes loaded in %llus %lluµs",725                     (unsigned long long)ctx->timing.icons_theme.diff.tv_sec,726                     (unsigned long long)ctx->timing.icons_theme.diff.tv_usec);727            LOG_WARN("icon paths resolved in %llus %lluµs",728                     (unsigned long long)ctx->timing.icons.diff.tv_sec,729                     (unsigned long long)ctx->timing.icons.diff.tv_usec);730        }731        matches_icons_loaded(matches);732        break;733734    default:735        LOG_ERR("unknown event: %llx", (long long)event);736        return false;737    }738739    wayl_refresh(wayl);740    return true;741}742743/*744 * Called when the application list has been populated745 */746static bool747fdm_apps_populated(struct fdm *fdm, int fd, int events, void *data)748{749    struct context *ctx = data;750    uint64_t last_event = EVENT_INVALID;751    uint64_t event = EVENT_INVALID;752753    while (true) {754        ssize_t bytes = read(fd, &event, sizeof(event));755        if (bytes == 0) {756            if (event != EVENT_INVALID) {757                if (!process_event(ctx, event))758                    return false;759            }760            break;761        }762763        if (bytes != (ssize_t)sizeof(event)) {764            if (bytes < 0) {765                if (errno == EAGAIN) {766                    if (event != EVENT_INVALID) {767                        if (!process_event(ctx, event))768                            return false;769                    }770                    break;771                }772                LOG_ERRNO("failed to read event FD");773            } else774                LOG_ERR("partial read from event FD");775            return false;776        }777778        /* Coalesce multiple, identical events */779        if (last_event != EVENT_INVALID) {780            if (event != last_event) {781                if (!process_event(ctx, last_event))782                    return false;783            }784        }785786        last_event = event;787    }788789    return true;790}791792int793main(int argc, char *const *argv)794{795    #define OPT_LETTER_SPACING               256796    #define OPT_LAUNCH_PREFIX                257797    #define OPT_SHOW_ACTIONS                 258798    #define OPT_MATCH_MODE                   259799    #define OPT_FUZZY_MIN_LENGTH             260800    #define OPT_FUZZY_MAX_LENGTH_DISCREPANCY 261801    #define OPT_FUZZY_MAX_DISTANCE           262802    #define OPT_DMENU_INDEX                  263803    #define OPT_LOG_LEVEL                    264804    #define OPT_LOG_COLORIZE                 265805    #define OPT_LOG_NO_SYSLOG                266806    #define OPT_PASSWORD                     267807    #define OPT_CONFIG                       268808    #define OPT_LAYER                        269809    #define OPT_ICON_THEME                   270810    #define OPT_KEYBOARD_FOCUS               271811    #define OPT_NO_EXIT_ON_KB_LOSS           272812    #define OPT_TABS                         273813    #define OPT_DMENU_NULL                   274814    #define OPT_FILTER_DESKTOP               275815    #define OPT_CHECK_CONFIG                 276816    #define OPT_SELECT                       277817    #define OPT_SELECT_INDEX                 278818    #define OPT_LIST_EXECS_IN_PATH           279819    #define OPT_X_MARGIN                     280820    #define OPT_Y_MARGIN                     281821    #define OPT_CACHE                        282822    #define OPT_RENDER_WORKERS               283823    #define OPT_PROMPT_COLOR                 284824    #define OPT_INPUT_COLOR                  285825    #define OPT_PROMPT_ONLY                  286826    #define OPT_COUNTER_COLOR                287827    #define OPT_USE_BOLD                     288828    #define OPT_MATCH_WORKERS                289829    #define OPT_NO_SORT                      290830    #define OPT_DELAYED_FILTER_MS            291831    #define OPT_DELAYED_FILTER_LIMIT         292832    #define OPT_PLACEHOLDER                  293833    #define OPT_PLACEHOLDER_COLOR            294834    #define OPT_SEARCH_TEXT                  295835    #define OPT_COUNTER                      296836    #define OPT_HIDE_WHEN_PROMPT_EMPTY       297837    #define OPT_DMENU_WITH_NTH               298838    #define OPT_DMENU_ACCEPT_NTH             299839    #define OPT_GAMMA_CORRECT                300840    #define OPT_PRINT_TIMINGS                301841    #define OPT_SCALING_FILTER               302842    #define OPT_MINIMAL_LINES                303843    #define OPT_HIDE_PROMPT                  304844    #define OPT_AUTO_SELECT                  305845    #define OPT_SELECTION_RADIUS             306846847    static const struct option longopts[] = {848        {"config",               required_argument, 0, OPT_CONFIG},849        {"check-config",         no_argument,       0, OPT_CHECK_CONFIG},850        {"namespace",            required_argument, 0, 'n'},851        {"cache",                required_argument, 0, OPT_CACHE},852        {"output"  ,             required_argument, 0, 'o'},853        {"font",                 required_argument, 0, 'f'},854        {"use-bold",             no_argument,       0, OPT_USE_BOLD},855        {"dpi-aware",            required_argument, 0, 'D'},856        {"gamma-correct",        no_argument,       0, OPT_GAMMA_CORRECT},857        {"icon-theme",           required_argument, 0, OPT_ICON_THEME},858        {"no-icons",             no_argument,       0, 'I'},859        {"hide-before-typing", no_argument,     0, OPT_HIDE_WHEN_PROMPT_EMPTY},860        {"fields",               required_argument, 0, 'F'},861        {"password",             optional_argument, 0, OPT_PASSWORD},862        {"anchor",               required_argument, 0, 'a'},863        {"x-margin",             required_argument, 0, OPT_X_MARGIN},864        {"y-margin",             required_argument, 0, OPT_Y_MARGIN},865        {"select",               required_argument, 0, OPT_SELECT},866        {"select-index",         required_argument, 0, OPT_SELECT_INDEX},867        {"lines",                required_argument, 0, 'l'},868        {"minimal-lines",        no_argument,       0, OPT_MINIMAL_LINES},869        {"hide-prompt",          no_argument,       0, OPT_HIDE_PROMPT},870        {"width",                required_argument, 0, 'w'},871        {"tabs",                 required_argument, 0, OPT_TABS},872        {"horizontal-pad",       required_argument, 0, 'x'},873        {"vertical-pad",         required_argument, 0, 'y'},874        {"inner-pad",            required_argument, 0, 'P'},875        {"background-color",     required_argument, 0, 'b'},876        {"text-color",           required_argument, 0, 't'},877        {"prompt-color",         required_argument, 0, OPT_PROMPT_COLOR},878        {"placeholder-color",    required_argument, 0, OPT_PLACEHOLDER_COLOR},879        {"input-color",          required_argument, 0, OPT_INPUT_COLOR},880        {"match-color",          required_argument, 0, 'm'},881        {"selection-color",      required_argument, 0, 's'},882        {"selection-text-color", required_argument, 0, 'S'},883        {"selection-match-color",required_argument, 0, 'M'},884        {"selection-radius",     required_argument, 0, OPT_SELECTION_RADIUS},885        {"counter-color",        required_argument, 0, OPT_COUNTER_COLOR},886        {"border-width",         required_argument, 0, 'B'},887        {"border-radius",        required_argument, 0, 'r'},888        {"border-color",         required_argument, 0, 'C'},889        {"prompt",               required_argument, 0, 'p'},890        {"prompt-only",          required_argument, 0, OPT_PROMPT_ONLY},891        {"placeholder",          required_argument, 0, OPT_PLACEHOLDER},892        {"search",               required_argument, 0, OPT_SEARCH_TEXT},893        {"terminal",             required_argument, 0, 'T'},894        {"show-actions",         no_argument,       0, OPT_SHOW_ACTIONS},895        {"match-mode",           required_argument, 0, OPT_MATCH_MODE},896        {"filter-desktop",       optional_argument, 0, OPT_FILTER_DESKTOP},897        {"fuzzy-min-length",     required_argument, 0, OPT_FUZZY_MIN_LENGTH},898        {"fuzzy-max-length-discrepancy", required_argument, 0, OPT_FUZZY_MAX_LENGTH_DISCREPANCY},899        {"fuzzy-max-distance",   required_argument, 0, OPT_FUZZY_MAX_DISTANCE},900        {"line-height",          required_argument, 0, 'H'},901        {"letter-spacing",       required_argument, 0, OPT_LETTER_SPACING},902        {"launch-prefix",        required_argument, 0, OPT_LAUNCH_PREFIX},903        {"layer",                required_argument, 0, OPT_LAYER},904        {"keyboard-focus",       required_argument, 0, OPT_KEYBOARD_FOCUS},905        {"no-exit-on-keyboard-focus-loss",   no_argument, 0, OPT_NO_EXIT_ON_KB_LOSS},906        {"list-executables-in-path",         no_argument, 0, OPT_LIST_EXECS_IN_PATH},907        {"render-workers",       required_argument, 0, OPT_RENDER_WORKERS},908        {"match-workers",        required_argument, 0, OPT_MATCH_WORKERS},909        {"no-sort",              no_argument,       0, OPT_NO_SORT},910        {"counter",              no_argument,       0, OPT_COUNTER},911        {"delayed-filter-ms",    required_argument, 0, OPT_DELAYED_FILTER_MS},912        {"delayed-filter-limit", required_argument, 0, OPT_DELAYED_FILTER_LIMIT},913        {"scaling-filter",       required_argument, 0, OPT_SCALING_FILTER},914        {"auto-select",          no_argument,       0, OPT_AUTO_SELECT},915916        /* dmenu mode */917        {"dmenu",                no_argument,       0, 'd'},918        {"dmenu0",               no_argument,       0, OPT_DMENU_NULL},919        {"no-run-if-empty",      no_argument,       0, 'R'},920        {"index",                no_argument,       0, OPT_DMENU_INDEX},921        {"with-nth",             required_argument, 0, OPT_DMENU_WITH_NTH},922        {"accept-nth",           required_argument, 0, OPT_DMENU_ACCEPT_NTH},923924        /* Misc */925        {"log-level",            required_argument, 0, OPT_LOG_LEVEL},926        {"log-colorize",         optional_argument, 0, OPT_LOG_COLORIZE},927        {"log-no-syslog",        no_argument,       0, OPT_LOG_NO_SYSLOG},928        {"version",              no_argument,       0, 'v'},929        {"print-timing-info",    no_argument,       0, OPT_PRINT_TIMINGS},930        {"help",                 no_argument,       0, 'h'},931        {NULL,                   no_argument,       0, 0},932    };933934    bool check_config = false;935    const char *config_path = NULL;936    enum log_class log_level = LOG_CLASS_WARNING;937    enum log_colorize log_colorize = LOG_COLORIZE_AUTO;938    bool log_syslog = true;939    const char *select = NULL;940    size_t select_idx = 0;941942    struct {943        struct config conf;944945        bool dpi_aware_set:1;946        bool gamma_correct_set:1;947        bool match_fields_set:1;948        bool icons_disabled_set:1;949        bool hide_when_prompt_empty_set:1;950        bool anchor_set:1;951        bool x_margin_set : 1;952        bool y_margin_set : 1;953        bool lines_set:1;954        bool minimal_lines_set:1;955        bool hide_prompt_set:1;956        bool chars_set:1;957        bool tabs_set:1;958        bool pad_x_set:1;959        bool pad_y_set:1;960        bool pad_inner_set:1;961        bool background_color_set:1;962        bool text_color_set:1;963        bool prompt_color_set:1;964        bool input_color_set:1;965        bool match_color_set:1;966        bool selection_color_set:1;967        bool selection_text_color_set:1;968        bool selection_match_color_set:1;969        bool selection_border_radius_set:1;970        bool counter_color_set:1;971        bool border_color_set:1;972        bool border_size_set:1;973        bool border_radius_set:1;974        bool actions_enabled_set:1;975        bool filter_desktop_set:1;976        bool match_mode_set:1;977        bool fuzzy_min_length_set:1;978        bool fuzzy_max_length_discrepancy_set:1;979        bool fuzzy_max_distance_set:1;980        bool line_height_set:1;981        bool letter_spacing_set:1;982        bool dmenu_enabled_set:1;983        bool dmenu_mode_set:1;984        bool dmenu_exit_immediately_if_empty_set:1;985        bool dmenu_delim_set:1;986        bool dmenu_with_nth_set:1;987        bool dmenu_accept_nth_set:1;988        bool layer_set:1;989        bool keyboard_focus_set:1;990        bool no_exit_on_keyboard_focus_loss_set:1;991        bool render_workers_set:1;992        bool match_workers_set:1;993        bool prompt_only_set:1;994        bool use_bold_set:1;995        bool no_sort_set:1;996        bool delayed_filter_ms_set:1;997        bool delayed_filter_limit_set:1;998        bool placeholder_color_set:1;999        bool counter_set:1;1000        bool print_timing_info_set:1;1001        bool scaling_filter_set:1;1002    } cmdline_overrides = {{0}};10031004    setlocale(LC_CTYPE, "");1005    setlocale(LC_MESSAGES, "");10061007    /* Auto-enable dmenu mode if invoked through a ‘dmenu’ symlink */1008    if (argv[0] != NULL) {1009        char *copy = xstrdup(argv[0]);1010        const char *name = basename(copy);1011        if (name != NULL && strcmp(name, "dmenu") == 0) {1012            cmdline_overrides.conf.dmenu.enabled = true;1013            cmdline_overrides.dmenu_enabled_set = true;1014        }10151016        free(copy);1017    }10181019    while (true) {1020        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);1021        if (c == -1)1022            break;10231024        switch (c) {1025        case OPT_CONFIG:1026            config_path = optarg;1027            break;10281029        case OPT_CHECK_CONFIG:1030            check_config = true;1031            break;10321033        case 'n':1034            cmdline_overrides.conf.namespace = optarg;1035            break;10361037        case OPT_CACHE:1038            cmdline_overrides.conf.cache_path = optarg;1039            break;10401041        case 'o':1042            cmdline_overrides.conf.output = optarg;1043            break;10441045        case 'f':1046            cmdline_overrides.conf.font = optarg;1047            break;10481049        case OPT_USE_BOLD:1050            cmdline_overrides.conf.use_bold = true;1051            cmdline_overrides.use_bold_set = true;1052            break;10531054        case 'D':1055            if (strcmp(optarg, "auto") == 0)1056                cmdline_overrides.conf.dpi_aware = DPI_AWARE_AUTO;1057            else if (strcmp(optarg, "no") == 0)1058                cmdline_overrides.conf.dpi_aware = DPI_AWARE_NO;1059            else if (strcmp(optarg, "yes") == 0)1060                cmdline_overrides.conf.dpi_aware = DPI_AWARE_YES;1061            else {1062                fprintf(1063                    stderr,1064                    "%s: invalid value for dpi-aware: "1065                    "must be one of 'auto', 'no', or 'yes'\n",1066                    optarg);1067                return EXIT_FAILURE;1068            }1069            cmdline_overrides.dpi_aware_set = true;1070            break;10711072        case OPT_GAMMA_CORRECT:1073            cmdline_overrides.conf.gamma_correct = true;1074            cmdline_overrides.gamma_correct_set = true;1075            break;10761077        case 'i':1078            /* Ignore (this flag means case insensitive search in1079             * other fuzzel-like utilities) */1080            break;10811082        case OPT_ICON_THEME:1083            cmdline_overrides.conf.icon_theme = optarg;1084            break;10851086        case 'I':1087            cmdline_overrides.conf.icons_enabled = false;1088            cmdline_overrides.icons_disabled_set = true;1089            break;10901091        case OPT_HIDE_WHEN_PROMPT_EMPTY:1092            cmdline_overrides.conf.hide_when_prompt_empty = true;1093            cmdline_overrides.hide_when_prompt_empty_set = true;1094            break;10951096        case 'F': {1097            static const struct {1098                const char *name;1099                enum match_fields value;1100            } map[] = {1101                {"filename", MATCH_FILENAME},1102                {"name", MATCH_NAME},1103                {"generic", MATCH_GENERIC},1104                {"exec", MATCH_EXEC},1105                {"categories", MATCH_CATEGORIES},1106                {"keywords", MATCH_KEYWORDS},1107                {"comment", MATCH_COMMENT},1108            };11091110            cmdline_overrides.conf.match_fields = 0;1111            for (const char *f = strtok(optarg, ", ");1112                 f != NULL;1113                 f = strtok(NULL, ", "))1114            {1115                enum match_fields field = 0;11161117                for (size_t i = 0; i < ALEN(map); i++) {1118                    if (strcmp(f, map[i].name) == 0) {1119                        field = map[i].value;1120                        break;1121                    }1122                }11231124                if (field > 0)1125                    cmdline_overrides.conf.match_fields |= field;1126                else {1127                    char valid_names[128] = {0};1128                    size_t idx = 0;1129                    for (size_t i = 0; i < ALEN(map); i++) {1130                        idx += xsnprintf(1131                            &valid_names[idx], sizeof(valid_names) - idx,1132                            "'%s', ", map[i].name);1133                    }11341135                    valid_names[idx - 2] = '\0';11361137                    fprintf(1138                        stderr,1139                        "%s: invalid field name: must be one of %s\n",1140                        f, valid_names);1141                    return EXIT_FAILURE;1142                }1143            }1144            cmdline_overrides.match_fields_set = true;1145            break;1146        }11471148        case OPT_PASSWORD: {1149            char32_t password_char = U'\0';1150            if (optarg != NULL) {1151                char32_t *wide_optarg = ambstoc32(optarg);1152                if (wide_optarg == NULL){1153                    fprintf(stderr, "%s: invalid password character\n", optarg);1154                    return EXIT_FAILURE;1155                }11561157                if (c32len(wide_optarg) > 1) {1158                    fprintf(1159                        stderr,1160                        "%s: password character must be a single character\n",1161                        optarg);1162                    free(wide_optarg);1163                    return EXIT_FAILURE;1164                }11651166                password_char = wide_optarg[0];1167                free(wide_optarg);1168                cmdline_overrides.conf.password_mode.character_set = true;1169            }11701171            cmdline_overrides.conf.password_mode.enabled = true;1172            cmdline_overrides.conf.password_mode.character = password_char;1173            break;1174        }11751176        case 'T':1177            cmdline_overrides.conf.terminal = optarg;1178            break;11791180        case 'a': {1181            enum anchors anchor;1182            bool valid_anchor = false;11831184            for (size_t i = 0; anchors_map[i].name != NULL; i++) {1185                if (strcmp(optarg, anchors_map[i].name) == 0) {1186                    anchor = anchors_map[i].value;1187                    valid_anchor = true;1188                    break;1189                }1190            }11911192            if (!valid_anchor) {1193                fprintf(stderr, "%s: invalid anchor\n", optarg);1194                return EXIT_FAILURE;1195            }11961197            cmdline_overrides.conf.anchor = anchor;1198            cmdline_overrides.anchor_set = true;1199            break;1200        }12011202        case OPT_X_MARGIN:1203          if (sscanf(optarg, "%u", &cmdline_overrides.conf.margin.x) != 1) {1204            fprintf(stderr, "%s: invalid horizontal margin\n", optarg);1205            return EXIT_FAILURE;1206          }1207          cmdline_overrides.x_margin_set = true;1208          break;12091210        case OPT_Y_MARGIN:1211          if (sscanf(optarg, "%u", &cmdline_overrides.conf.margin.y) != 1) {1212            fprintf(stderr, "%s: invalid vertical margin\n", optarg);1213            return EXIT_FAILURE;1214          }1215          cmdline_overrides.y_margin_set = true;1216          break;12171218        case OPT_SELECT:1219            select = optarg;1220            break;12211222        case OPT_SELECT_INDEX:1223            if (sscanf(optarg, "%zu", &select_idx) != 1) {1224                fprintf(1225                    stderr,1226                    "%s: invalid selected index (must be an integer)\n",1227                    optarg);1228                return EXIT_FAILURE;1229            }1230            break;12311232        case 'l':1233            if (sscanf(optarg, "%u", &cmdline_overrides.conf.lines) != 1) {1234                fprintf(stderr, "%s: invalid line count\n", optarg);1235                return EXIT_FAILURE;1236            }1237            cmdline_overrides.lines_set = true;1238            break;12391240        case OPT_MINIMAL_LINES:1241            cmdline_overrides.conf.minimal_lines = true;1242            cmdline_overrides.minimal_lines_set = true;1243            break;12441245        case OPT_HIDE_PROMPT:1246            cmdline_overrides.conf.hide_prompt = true;1247            cmdline_overrides.hide_prompt_set = true;1248            break;12491250        case 'w':1251            if (sscanf(optarg, "%u", &cmdline_overrides.conf.chars) != 1) {1252                fprintf(stderr, "%s: invalid width\n", optarg);1253                return EXIT_FAILURE;1254            }1255            cmdline_overrides.chars_set = true;1256            break;12571258        case OPT_TABS:1259            if (sscanf(optarg, "%u", &cmdline_overrides.conf.tabs) != 1) {1260                fprintf(stderr, "%s: invalid tab count\n", optarg);1261                return EXIT_FAILURE;1262            }1263            cmdline_overrides.tabs_set = true;1264            break;12651266        case 'x':1267            if (sscanf(optarg, "%u", &cmdline_overrides.conf.pad.x) != 1) {1268                fprintf(stderr, "%s: invalid padding\n", optarg);1269                return EXIT_FAILURE;1270            }1271            cmdline_overrides.pad_x_set = true;1272            break;12731274        case 'y':1275            if (sscanf(optarg, "%u", &cmdline_overrides.conf.pad.y) != 1) {1276                fprintf(stderr, "%s: invalid padding\n", optarg);1277                return EXIT_FAILURE;1278            }1279            cmdline_overrides.pad_y_set = true;1280            break;12811282        case 'P':1283            if (sscanf(optarg, "%u", &cmdline_overrides.conf.pad.inner) != 1) {1284                fprintf(stderr, "%s: invalid padding\n", optarg);1285                return EXIT_FAILURE;1286            }1287            cmdline_overrides.pad_inner_set = true;1288            break;12891290        case 'p':1291            free(cmdline_overrides.conf.prompt);1292            cmdline_overrides.conf.prompt = ambstoc32(optarg);12931294            if (cmdline_overrides.conf.prompt == NULL) {1295                fprintf(stderr, "%s: invalid prompt\n", optarg);1296                return EXIT_FAILURE;1297            }12981299            break;13001301        case OPT_PROMPT_ONLY:1302            free(cmdline_overrides.conf.prompt);1303            cmdline_overrides.conf.prompt = ambstoc32(optarg);13041305            if (cmdline_overrides.conf.prompt == NULL) {1306                fprintf(stderr, "%s: invalid prompt\n", optarg);1307                return EXIT_FAILURE;1308            }13091310            cmdline_overrides.prompt_only_set = true;1311            cmdline_overrides.conf.prompt_only = true;1312            break;13131314        case OPT_PLACEHOLDER:1315            free(cmdline_overrides.conf.placeholder);1316            cmdline_overrides.conf.placeholder = ambstoc32(optarg);13171318            if (cmdline_overrides.conf.placeholder == NULL) {1319                fprintf(stderr, "%s: invalid placeholder\n", optarg);1320                return EXIT_FAILURE;1321            }13221323            break;13241325        case OPT_SEARCH_TEXT:1326            free(cmdline_overrides.conf.search_text);1327            cmdline_overrides.conf.search_text = ambstoc32(optarg);13281329            if (cmdline_overrides.conf.search_text == NULL) {1330                fprintf(stderr, "%s: invalid search text\n", optarg);1331                return EXIT_FAILURE;1332            }13331334            break;13351336        case 'b': {1337            const char *clr_start = optarg;1338            if (clr_start[0] == '#')1339                clr_start++;13401341            errno = 0;1342            char *end = NULL;1343            uint32_t background = strtoul(clr_start, &end, 16);1344            if (errno != 0 || end == NULL || *end != '\0' || (end - clr_start) != 8) {1345                fprintf(stderr, "background-color: %s: invalid color\n",1346                        optarg);1347                return EXIT_FAILURE;1348            }1349            cmdline_overrides.conf.colors.background =1350                conf_hex_to_rgba(background);1351            cmdline_overrides.background_color_set = true;1352            break;1353        }13541355        case 't': {1356            const char *clr_start = optarg;1357            if (clr_start[0] == '#')1358                clr_start++;13591360            errno = 0;1361            char *end = NULL;1362            uint32_t text_color = strtoul(clr_start, &end, 16);1363            if (errno != 0 || end == NULL || *end != '\0' || (end - clr_start) != 8) {1364                fprintf(stderr, "text-color: %s: invalid color\n", optarg);1365                return EXIT_FAILURE;1366            }1367            cmdline_overrides.conf.colors.text = conf_hex_to_rgba(text_color);1368            cmdline_overrides.text_color_set = true;1369            break;1370        }13711372        case OPT_PROMPT_COLOR: {1373            const char *clr_start = optarg;1374            if (clr_start[0] == '#')1375                clr_start++;13761377            errno = 0;1378            char *end = NULL;1379            uint32_t prompt_color = strtoul(clr_start, &end, 16);1380            if (errno != 0 || end == NULL || *end != '\0' || (end - clr_start) != 8) {1381                fprintf(stderr, "prompt-color: %s: invalid color\n", optarg);1382                return EXIT_FAILURE;1383            }1384            cmdline_overrides.conf.colors.prompt = conf_hex_to_rgba(prompt_color);1385            cmdline_overrides.prompt_color_set = true;1386            break;1387        }13881389        case OPT_PLACEHOLDER_COLOR: {1390            const char *clr_start = optarg;1391            if (clr_start[0] == '#')1392                clr_start++;13931394            errno = 0;1395            char *end = NULL;1396            uint32_t placeholder_color = strtoul(clr_start, &end, 16);1397            if (errno != 0 || end == NULL || *end != '\0' || (end - clr_start) != 8) {1398                fprintf(stderr, "placeholder-color: %s: invalid color\n", optarg);1399                return EXIT_FAILURE;1400            }1401            cmdline_overrides.conf.colors.placeholder = conf_hex_to_rgba(placeholder_color);1402            cmdline_overrides.placeholder_color_set = true;1403            break;1404        }14051406        case OPT_INPUT_COLOR: {1407            const char *clr_start = optarg;1408            if (clr_start[0] == '#')1409                clr_start++;14101411            errno = 0;1412            char *end = NULL;1413            uint32_t input_color = strtoul(clr_start, &end, 16);1414            if (errno != 0 || end == NULL || *end != '\0' || (end - clr_start) != 8) {1415                fprintf(stderr, "prompt-color: %s: invalid color\n", optarg);1416                return EXIT_FAILURE;1417            }1418            cmdline_overrides.conf.colors.input = conf_hex_to_rgba(input_color);1419            cmdline_overrides.input_color_set = true;1420            break;1421        }14221423        case 'm': {1424            const char *clr_start = optarg;1425            if (clr_start[0] == '#')1426                clr_start++;14271428            errno = 0;1429            char *end = NULL;1430            uint32_t match_color = strtoul(clr_start, &end, 16);1431            if (errno != 0 || end == NULL || *end != '\0' || (end - clr_start) != 8) {1432                fprintf(stderr, "match-color: %s: invalid color\n", optarg);1433                return EXIT_FAILURE;1434            }1435            cmdline_overrides.conf.colors.match =1436                conf_hex_to_rgba(match_color);1437            cmdline_overrides.match_color_set = true;1438            break;1439        }14401441        case 's': {1442            const char *clr_start = optarg;1443            if (clr_start[0] == '#')1444                clr_start++;14451446            errno = 0;1447            char *end = NULL;1448            uint32_t selection_color = strtoul(clr_start, &end, 16);1449            if (errno != 0 || end == NULL || *end != '\0' || (end - clr_start) != 8) {1450                fprintf(stderr, "selection-color: %s: invalid color\n", optarg);1451                return EXIT_FAILURE;1452            }1453            cmdline_overrides.conf.colors.selection =1454                conf_hex_to_rgba(selection_color);1455            cmdline_overrides.selection_color_set = true;1456            break;1457        }14581459        case 'S': {1460            const char *clr_start = optarg;1461            if (clr_start[0] == '#')1462                clr_start++;14631464            errno = 0;1465            char *end = NULL;1466            uint32_t selection_text_color = strtoul(clr_start, &end, 16);1467            if (errno != 0 || end == NULL || *end != '\0' || (end - clr_start) != 8) {1468                fprintf(stderr, "selection-text-color: %s: invalid color\n",1469                        optarg);1470                return EXIT_FAILURE;1471            }1472            cmdline_overrides.conf.colors.selection_text =1473                conf_hex_to_rgba(selection_text_color);1474            cmdline_overrides.selection_text_color_set = true;1475            break;1476        }14771478        case OPT_SELECTION_RADIUS: {1479            if (sscanf(optarg, "%u", &cmdline_overrides.conf.selection_border.radius) != 1) {1480                fprintf(stderr, "%s: invalid selection border radius (must be an integer)\n",1481                        optarg);1482                return EXIT_FAILURE;1483            }1484            cmdline_overrides.selection_border_radius_set = true;1485            break;1486        }14871488        case 'M': {1489            const char *clr_start = optarg;1490            if (clr_start[0] == '#')1491                clr_start++;14921493            errno = 0;1494            char *end = NULL;1495            uint32_t selection_match_color = strtoul(clr_start, &end, 16);1496            if (errno != 0 || end == NULL || *end != '\0' || (end - clr_start) != 8) {1497                fprintf(stderr, "selection-match-color: %s: invalid color\n",1498                        optarg);1499                return EXIT_FAILURE;1500            }1501            cmdline_overrides.conf.colors.selection_match =1502                conf_hex_to_rgba(selection_match_color);1503            cmdline_overrides.selection_match_color_set = true;1504            break;1505        }15061507        case OPT_COUNTER_COLOR: {1508            const char *clr_start = optarg;1509            if (clr_start[0] == '#')1510                clr_start++;15111512            errno = 0;1513            char *end = NULL;1514            uint32_t count_color = strtoul(clr_start, &end, 16);1515            if (errno != 0 || end == NULL || *end != '\0' || (end - clr_start) != 8) {1516                fprintf(stderr, "counter-color: %s: invalid color\n",1517                        optarg);1518                return EXIT_FAILURE;1519            }1520            cmdline_overrides.conf.colors.counter = conf_hex_to_rgba(count_color);1521            cmdline_overrides.counter_color_set = true;1522            break;1523        }152415251526        case 'B':1527            if (sscanf(optarg, "%u", &cmdline_overrides.conf.border.size) != 1) {1528                fprintf(1529                    stderr,1530                    "%s: invalid border width (must be an integer)\n", optarg);1531                return EXIT_FAILURE;1532            }1533            cmdline_overrides.border_size_set = true;1534            break;15351536        case 'r':1537            if (sscanf(optarg, "%u", &cmdline_overrides.conf.border.radius) != 1) {1538                fprintf(stderr, "%s: invalid border radius (must be an integer)\n",1539                        optarg);1540                return EXIT_FAILURE;1541            }1542            cmdline_overrides.border_radius_set = true;1543            break;15441545        case 'C': {1546            const char *clr_start = optarg;1547            if (clr_start[0] == '#')1548                clr_start++;15491550            errno = 0;1551            char *end = NULL;1552            uint32_t border_color = strtoul(clr_start, &end, 16);1553            if (errno != 0 || end == NULL || *end != '\0' || (end - clr_start) != 8) {1554                fprintf(stderr, "border-color: %s: invalid color\n", optarg);1555                return EXIT_FAILURE;1556            }1557            cmdline_overrides.conf.colors.border =1558                conf_hex_to_rgba(border_color);1559            cmdline_overrides.border_color_set = true;1560            break;1561        }15621563        case OPT_SHOW_ACTIONS:1564            cmdline_overrides.actions_enabled_set = true;1565            cmdline_overrides.conf.actions_enabled = true;1566            break;15671568        case OPT_MATCH_MODE:1569            if (strcmp(optarg, "exact") == 0)1570                cmdline_overrides.conf.match_mode = MATCH_MODE_EXACT;1571            else if (strcmp(optarg, "fzf") == 0)1572                cmdline_overrides.conf.match_mode = MATCH_MODE_FZF;1573            else if (strcmp(optarg, "fuzzy") == 0)1574                cmdline_overrides.conf.match_mode = MATCH_MODE_FUZZY;1575            else {1576                fprintf(stderr, "%s: invalid match-mode. Must be 'exact', 'fuzzy' or 'fzf'\n", optarg);1577                return EXIT_FAILURE;1578            }15791580            cmdline_overrides.match_mode_set = true;1581            break;15821583        case OPT_FILTER_DESKTOP:1584            cmdline_overrides.filter_desktop_set = true;1585            if (optarg != NULL && strcasecmp(optarg, "no") == 0)1586                cmdline_overrides.conf.filter_desktop = false;1587            else if (optarg != NULL) {1588                fprintf(stderr, "%s: invalid filter-desktop option\n", optarg);1589                return EXIT_FAILURE;1590            }1591            else1592                cmdline_overrides.conf.filter_desktop = true;1593            break;15941595        case OPT_FUZZY_MIN_LENGTH:1596            if (sscanf(optarg, "%zu", &cmdline_overrides.conf.fuzzy.min_length) != 1) {1597                fprintf(1598                    stderr,1599                    "%s: invalid fuzzy min length (must be an integer)\n",1600                    optarg);1601                return EXIT_FAILURE;1602            }1603            cmdline_overrides.fuzzy_min_length_set = true;1604            break;16051606        case OPT_FUZZY_MAX_LENGTH_DISCREPANCY:1607            if (sscanf(optarg, "%zu", &cmdline_overrides.conf.fuzzy.max_length_discrepancy) != 1) {1608                fprintf(1609                    stderr,1610                    "%s: invalid fuzzy max length discrepancy "1611                    "(must be an integer)\n", optarg);1612                return EXIT_FAILURE;1613            }1614            cmdline_overrides.fuzzy_max_length_discrepancy_set = true;1615            break;16161617        case OPT_FUZZY_MAX_DISTANCE:1618            if (sscanf(optarg, "%zu", &cmdline_overrides.conf.fuzzy.max_distance) != 1) {1619                fprintf(1620                    stderr,1621                    "%s: invalid fuzzy max distance (must be an integer)\n",1622                    optarg);1623                return EXIT_FAILURE;1624            }1625            cmdline_overrides.fuzzy_max_distance_set = true;1626            break;16271628        case OPT_LIST_EXECS_IN_PATH:1629            cmdline_overrides.conf.list_executables_in_path = true;1630            break;16311632        case 'H': { /* line-height */1633            if (!pt_or_px_from_string(optarg, &cmdline_overrides.conf.line_height))1634                return EXIT_FAILURE;1635            cmdline_overrides.line_height_set = true;1636            break;1637        }16381639        case OPT_LETTER_SPACING: {1640            if (!pt_or_px_from_string(optarg, &cmdline_overrides.conf.letter_spacing))1641                return EXIT_FAILURE;1642            cmdline_overrides.letter_spacing_set = true;1643            break;1644        }16451646        case OPT_LAUNCH_PREFIX: {1647            cmdline_overrides.conf.launch_prefix = optarg;1648            break;1649        }16501651        case OPT_LAYER:1652            if (strcasecmp(optarg, "top") == 0)1653                cmdline_overrides.conf.layer = ZWLR_LAYER_SHELL_V1_LAYER_TOP;1654            else if (strcasecmp(optarg, "overlay") == 0)1655                cmdline_overrides.conf.layer = ZWLR_LAYER_SHELL_V1_LAYER_OVERLAY;1656            else {1657                fprintf(1658                    stderr,1659                    "%s: invalid layer. Must be one of 'top', 'overlay'\n",1660                    optarg);1661                return EXIT_FAILURE;1662            }1663            cmdline_overrides.layer_set = true;1664            break;16651666        case OPT_KEYBOARD_FOCUS:1667            if (strcasecmp(optarg, "exclusive") == 0)1668                cmdline_overrides.conf.keyboard_focus = ZWLR_LAYER_SURFACE_V1_KEYBOARD_INTERACTIVITY_EXCLUSIVE;1669            else if (strcasecmp(optarg, "on-demand") == 0)1670                cmdline_overrides.conf.keyboard_focus = ZWLR_LAYER_SURFACE_V1_KEYBOARD_INTERACTIVITY_ON_DEMAND;1671            else {1672                fprintf(1673                    stderr,1674                    "%s: invalid keyboard-focus. Must be one of 'exclusive', 'on-demand'\n",1675                    optarg);1676                return EXIT_FAILURE;1677            }1678            cmdline_overrides.keyboard_focus_set = true;1679            break;16801681        case OPT_NO_EXIT_ON_KB_LOSS:1682            cmdline_overrides.conf.exit_on_kb_focus_loss = false;1683            cmdline_overrides.no_exit_on_keyboard_focus_loss_set = true;1684            break;16851686        case 'd':1687            cmdline_overrides.conf.dmenu.enabled = true;1688            cmdline_overrides.dmenu_enabled_set = true;1689            break;16901691        case OPT_DMENU_NULL:1692            cmdline_overrides.conf.dmenu.enabled = true;1693            cmdline_overrides.conf.dmenu.delim = '\0';1694            cmdline_overrides.dmenu_enabled_set = true;1695            cmdline_overrides.dmenu_delim_set = true;1696            break;16971698        case 'R':1699            cmdline_overrides.conf.dmenu.exit_immediately_if_empty = true;1700            cmdline_overrides.dmenu_exit_immediately_if_empty_set = true;1701            break;17021703        case OPT_DMENU_INDEX:1704            cmdline_overrides.conf.dmenu.mode = DMENU_MODE_INDEX;1705            cmdline_overrides.dmenu_mode_set = true;1706            break;17071708        case OPT_DMENU_WITH_NTH:1709            if (sscanf(optarg, "%u", &cmdline_overrides.conf.dmenu.render_column) != 1) {1710                fprintf(1711                    stderr,1712                    "%s: invalid with-nth value (must be an integer)\n",1713                    optarg);1714                return EXIT_FAILURE;1715            }1716            cmdline_overrides.dmenu_with_nth_set = true;1717            break;17181719        case OPT_DMENU_ACCEPT_NTH:1720                    if (sscanf(optarg, "%u", &cmdline_overrides.conf.dmenu.output_column) != 1) {1721                        fprintf(1722                            stderr,1723                            "%s: invalid accept-nth value (must be an integer)\n",1724                            optarg);1725                        return EXIT_FAILURE;1726                    }1727                    cmdline_overrides.dmenu_accept_nth_set = true;1728                    break;17291730        case OPT_LOG_LEVEL: {1731            int lvl = log_level_from_string(optarg);1732            if (lvl < 0) {1733                fprintf(1734                    stderr,1735                    "--log-level: %s: argument must be one of %s\n",1736                    optarg, log_level_string_hint());1737                return EXIT_FAILURE;1738            }1739            log_level = lvl;1740            break;1741        }17421743        case OPT_LOG_COLORIZE:1744            if (optarg == NULL || strcmp(optarg, "auto") == 0)1745                log_colorize = LOG_COLORIZE_AUTO;1746            else if (strcmp(optarg, "never") == 0)1747                log_colorize = LOG_COLORIZE_NEVER;1748            else if (strcmp(optarg, "always") == 0)1749                log_colorize = LOG_COLORIZE_ALWAYS;1750            else {1751                fprintf(stderr, "--log-colorize: %s: argument must be one of 'never', 'always' or 'auto'\n", optarg);1752                return EXIT_FAILURE;1753            }1754            break;17551756        case OPT_LOG_NO_SYSLOG:1757            log_syslog = false;1758            break;17591760        case OPT_RENDER_WORKERS:1761            if (sscanf(optarg, "%hu", &cmdline_overrides.conf.render_worker_count) != 1) {1762                fprintf(1763                    stderr,1764                    "%s: invalid value for render-workers (must be an integer)\n",1765                    optarg);1766                return EXIT_FAILURE;1767            }17681769            cmdline_overrides.render_workers_set = true;1770            break;17711772        case OPT_MATCH_WORKERS:1773            if (sscanf(optarg, "%hu", &cmdline_overrides.conf.match_worker_count) != 1) {1774                fprintf(1775                    stderr,1776                    "%s: invalid value for match-workers (must be an integer)\n",1777                    optarg);1778                return EXIT_FAILURE;1779            }17801781            cmdline_overrides.match_workers_set = true;1782            break;17831784        case OPT_NO_SORT:1785            cmdline_overrides.conf.sort_result = false;1786            cmdline_overrides.no_sort_set = true;1787            break;17881789        case OPT_COUNTER:1790            cmdline_overrides.conf.match_counter = true;1791            cmdline_overrides.counter_set = true;1792            break;17931794        case OPT_DELAYED_FILTER_MS:1795            if (sscanf(optarg, "%u", &cmdline_overrides.conf.delayed_filter_ms) != 1) {1796                fprintf(stderr, "%s: invalid delayed-filter-ms (must be an integer)\n",1797                        optarg);1798                return EXIT_FAILURE;1799            }1800            cmdline_overrides.delayed_filter_ms_set = true;1801            break;18021803        case OPT_DELAYED_FILTER_LIMIT:1804            if (sscanf(optarg, "%u", &cmdline_overrides.conf.delayed_filter_limit) != 1) {1805                fprintf(stderr, "%s: invalid delayed-filter-limit (must be an integer)\n",1806                        optarg);1807                return EXIT_FAILURE;1808            }1809            cmdline_overrides.delayed_filter_limit_set = true;1810            break;18111812        case OPT_SCALING_FILTER:1813            if (strcmp(optarg, "none") == 0)1814                cmdline_overrides.conf.png_scaling_filter = SCALING_FILTER_NONE;1815            else if (strcmp(optarg, "nearest") == 0)1816                cmdline_overrides.conf.png_scaling_filter = SCALING_FILTER_NEAREST;1817            else if (strcmp(optarg, "bilinear") == 0)1818                cmdline_overrides.conf.png_scaling_filter = SCALING_FILTER_BILINEAR;1819            else if (strcmp(optarg, "box") == 0)1820                cmdline_overrides.conf.png_scaling_filter = SCALING_FILTER_BOX;1821            else if (strcmp(optarg, "linear") == 0)1822                cmdline_overrides.conf.png_scaling_filter = SCALING_FILTER_LINEAR;1823            else if (strcmp(optarg, "cubic") == 0)1824                cmdline_overrides.conf.png_scaling_filter = SCALING_FILTER_CUBIC;1825            else if (strcmp(optarg, "lanczos2") == 0)1826                cmdline_overrides.conf.png_scaling_filter = SCALING_FILTER_LANCZOS2;1827            else if (strcmp(optarg, "lanczos3") == 0)1828                cmdline_overrides.conf.png_scaling_filter = SCALING_FILTER_LANCZOS3;1829            else if (strcmp(optarg, "lanczos3-stretched") == 0)1830                cmdline_overrides.conf.png_scaling_filter = SCALING_FILTER_LANCZOS3_STRETCHED;1831            else {1832                fprintf(stderr, "%s: invalid scaling-filter", optarg);1833                return EXIT_FAILURE;1834            }1835            cmdline_overrides.scaling_filter_set = true;1836            break;18371838        case OPT_PRINT_TIMINGS:1839            cmdline_overrides.conf.print_timing_info = true;1840            cmdline_overrides.print_timing_info_set = true;1841            break;18421843        case OPT_AUTO_SELECT:1844            cmdline_overrides.conf.auto_select = true;1845            break;18461847        case 'v':1848            printf("fuzzel %s\n", version_and_features());1849            return EXIT_SUCCESS;18501851        case 'h':1852            print_usage(argv[0]);1853            return EXIT_SUCCESS;18541855        case ':':1856            fprintf(stderr, "error: %s: missing required argument\n", argv[optind-1]);1857            return EXIT_FAILURE;18581859        case '?':1860            fprintf(stderr, "error: %s: invalid option\n", argv[optind-1]);1861            return EXIT_FAILURE;1862        }1863    }18641865    log_init(log_colorize, log_syslog, LOG_FACILITY_USER, log_level);1866    LOG_INFO("%s", version_and_features());18671868    int ret = EXIT_FAILURE;18691870    if (select != NULL && select_idx) {1871        LOG_ERRNO("--select and --select-index cannot be used at the same time");1872        return ret;1873    }18741875    if (cmdline_overrides.prompt_only_set && cmdline_overrides.conf.hide_prompt) {1876        LOG_ERRNO("--prompt-only and --hide-prompt cannot be used at the same time");1877        config_free(&cmdline_overrides.conf);1878        return ret;1879    }18801881    struct config conf = {0};1882    bool conf_successful = config_load(&conf, config_path, NULL, check_config);1883    if (!conf_successful) {1884        config_free(&conf);1885        config_free(&cmdline_overrides.conf);1886        return ret;1887    }18881889    if (check_config) {1890        config_free(&conf);1891        config_free(&cmdline_overrides.conf);1892        return EXIT_SUCCESS;1893    }18941895    /* Apply command line overrides */1896    if (cmdline_overrides.conf.output != NULL) {1897        free(conf.output);1898        conf.output = xstrdup(cmdline_overrides.conf.output);1899    }1900    if (cmdline_overrides.conf.namespace != NULL) {1901        free(conf.namespace);1902        conf.namespace = xstrdup(cmdline_overrides.conf.namespace);1903    }1904    if (cmdline_overrides.conf.prompt != NULL) {1905        free(conf.prompt);1906        conf.prompt = cmdline_overrides.conf.prompt;1907        if (cmdline_overrides.prompt_only_set)1908            conf.prompt_only = cmdline_overrides.conf.prompt_only;1909    }1910    if (cmdline_overrides.conf.placeholder != NULL) {1911        free(conf.placeholder);1912        conf.placeholder = cmdline_overrides.conf.placeholder;1913    }1914    if (cmdline_overrides.conf.search_text != NULL) {1915        free(conf.search_text);1916        conf.search_text = cmdline_overrides.conf.search_text;1917    }1918    if (cmdline_overrides.conf.password_mode.enabled) {1919        conf.password_mode.enabled = true;1920        conf.password_mode.character =1921            cmdline_overrides.conf.password_mode.character_set1922                ? cmdline_overrides.conf.password_mode.character1923                : conf.password_mode.character_set1924                    ? conf.password_mode.character1925                    : U'*';1926    }1927    if (cmdline_overrides.conf.terminal != NULL) {1928        free(conf.terminal);1929        conf.terminal = xstrdup(cmdline_overrides.conf.terminal);1930    }1931    if (cmdline_overrides.conf.launch_prefix != NULL) {1932        free(conf.launch_prefix);1933        conf.launch_prefix = xstrdup(cmdline_overrides.conf.launch_prefix);1934    }1935    if (cmdline_overrides.conf.font != NULL) {1936        free(conf.font);1937        conf.font = xstrdup(cmdline_overrides.conf.font);1938    }1939    if (cmdline_overrides.use_bold_set)1940        conf.use_bold = cmdline_overrides.conf.use_bold;1941    if (cmdline_overrides.conf.icon_theme != NULL) {1942        free(conf.icon_theme);1943        conf.icon_theme = xstrdup(cmdline_overrides.conf.icon_theme);1944    }1945    if (cmdline_overrides.dpi_aware_set)1946        conf.dpi_aware = cmdline_overrides.conf.dpi_aware;1947    if (cmdline_overrides.gamma_correct_set)1948        conf.gamma_correct = cmdline_overrides.conf.gamma_correct;1949    if (cmdline_overrides.match_fields_set)1950        conf.match_fields = cmdline_overrides.conf.match_fields;1951    if (cmdline_overrides.icons_disabled_set)1952        conf.icons_enabled = cmdline_overrides.conf.icons_enabled;1953    if (cmdline_overrides.hide_when_prompt_empty_set)1954        conf.hide_when_prompt_empty = cmdline_overrides.conf.hide_when_prompt_empty;1955    if (cmdline_overrides.hide_prompt_set)1956        conf.hide_prompt = cmdline_overrides.conf.hide_prompt;1957    if (cmdline_overrides.anchor_set)1958        conf.anchor = cmdline_overrides.conf.anchor;1959    if (cmdline_overrides.x_margin_set)1960        conf.margin.x = cmdline_overrides.conf.margin.x;1961    if (cmdline_overrides.y_margin_set)1962        conf.margin.y = cmdline_overrides.conf.margin.y;1963    if (cmdline_overrides.lines_set)1964        conf.lines = cmdline_overrides.conf.lines;1965    if (cmdline_overrides.minimal_lines_set)1966        conf.minimal_lines = cmdline_overrides.conf.minimal_lines;1967    if (cmdline_overrides.chars_set)1968        conf.chars = cmdline_overrides.conf.chars;1969    if (cmdline_overrides.tabs_set)1970        conf.tabs = cmdline_overrides.conf.tabs;1971    if (cmdline_overrides.pad_x_set)1972        conf.pad.x = cmdline_overrides.conf.pad.x;1973    if (cmdline_overrides.pad_y_set)1974        conf.pad.y = cmdline_overrides.conf.pad.y;1975    if (cmdline_overrides.pad_inner_set)1976        conf.pad.inner = cmdline_overrides.conf.pad.inner;1977    if (cmdline_overrides.background_color_set)1978        conf.colors.background = cmdline_overrides.conf.colors.background;1979    if (cmdline_overrides.text_color_set)1980        conf.colors.text = cmdline_overrides.conf.colors.text;1981    if (cmdline_overrides.prompt_color_set)1982        conf.colors.prompt = cmdline_overrides.conf.colors.prompt;1983    if (cmdline_overrides.placeholder_color_set)1984        conf.colors.placeholder = cmdline_overrides.conf.colors.placeholder;1985    if (cmdline_overrides.input_color_set)1986        conf.colors.input = cmdline_overrides.conf.colors.input;1987    if (cmdline_overrides.match_color_set)1988        conf.colors.match = cmdline_overrides.conf.colors.match;1989    if (cmdline_overrides.selection_color_set)1990        conf.colors.selection = cmdline_overrides.conf.colors.selection;1991    if (cmdline_overrides.selection_text_color_set)1992        conf.colors.selection_text = cmdline_overrides.conf.colors.selection_text;1993    if (cmdline_overrides.selection_match_color_set)1994        conf.colors.selection_match = cmdline_overrides.conf.colors.selection_match;1995    if (cmdline_overrides.selection_border_radius_set)1996        conf.selection_border.radius = cmdline_overrides.conf.selection_border.radius;1997    if (cmdline_overrides.counter_color_set)1998        conf.colors.counter = cmdline_overrides.conf.colors.counter;1999    if (cmdline_overrides.border_color_set)2000        conf.colors.border = cmdline_overrides.conf.colors.border;

The first 2,000 of 2,279 lines.