config.h
This file
Path
config.h
248 lines · 5.3 KiB · C
Last changed by
config: add --mesg, --mesg-mode and --message-color command line optionsSlayerOfTheBadbefore adoption9fb7e6c
History of this fileTake it
1#pragma once23#include <stdint.h>4#include <stdbool.h>5#include <char32.h>67#include <wlr-layer-shell-unstable-v1.h>89#include <tllist.h>10#include <xkbcommon/xkbcommon.h>1112#define DEFINE_LIST(type) \13 type##_list { \14 size_t count; \15 type *arr; \16 }1718struct rgba {double r; double g; double b; double a;};19struct pt_or_px {int px; float pt;};2021enum dpi_aware {22 DPI_AWARE_AUTO,23 DPI_AWARE_YES,24 DPI_AWARE_NO,25};2627enum dmenu_mode {28 DMENU_MODE_TEXT,29 DMENU_MODE_INDEX,30};3132enum match_mode {33 MATCH_MODE_EXACT,34 MATCH_MODE_FZF,35 MATCH_MODE_FUZZY,36};3738enum message_mode {39 MESSAGE_MODE_WRAP,40 MESSAGE_MODE_EXPAND,41};424344enum match_fields {45 MATCH_NAME = 0x01,46 MATCH_FILENAME = 0x02,47 MATCH_GENERIC = 0x04,48 MATCH_EXEC = 0x08,49 MATCH_COMMENT = 0x10,50 MATCH_KEYWORDS = 0x20,51 MATCH_CATEGORIES = 0x40,52 MATCH_NTH = 0x80,53};5455enum anchors {56 ANCHOR_TOP_LEFT = ZWLR_LAYER_SURFACE_V1_ANCHOR_TOP | ZWLR_LAYER_SURFACE_V1_ANCHOR_LEFT,57 ANCHOR_TOP = ZWLR_LAYER_SURFACE_V1_ANCHOR_TOP,58 ANCHOR_TOP_RIGHT = ZWLR_LAYER_SURFACE_V1_ANCHOR_TOP | ZWLR_LAYER_SURFACE_V1_ANCHOR_RIGHT,59 ANCHOR_LEFT = ZWLR_LAYER_SURFACE_V1_ANCHOR_LEFT,60 ANCHOR_CENTER = 0,61 ANCHOR_RIGHT = ZWLR_LAYER_SURFACE_V1_ANCHOR_RIGHT,62 ANCHOR_BOTTOM_LEFT = ZWLR_LAYER_SURFACE_V1_ANCHOR_BOTTOM | ZWLR_LAYER_SURFACE_V1_ANCHOR_LEFT,63 ANCHOR_BOTTOM = ZWLR_LAYER_SURFACE_V1_ANCHOR_BOTTOM,64 ANCHOR_BOTTOM_RIGHT = ZWLR_LAYER_SURFACE_V1_ANCHOR_BOTTOM | ZWLR_LAYER_SURFACE_V1_ANCHOR_RIGHT,65};6667struct anchors_map {68 const char *name;69 enum anchors value;70};7172extern const struct anchors_map anchors_map[];7374struct config_key_modifiers {75 bool shift;76 bool alt;77 bool ctrl;78 bool super;79};8081struct config_key_binding {82 int action; /* One of the various bind_action_* enums from wayland.h */83 struct config_key_modifiers modifiers;84 union {85 /* Key bindings */86 struct {87 xkb_keysym_t sym;88 } k;8990#if 091 /* Mouse bindings */92 struct {93 int button;94 int count;95 } m;96#endif97 };9899 /* For error messages in collision handling */100 const char *path;101 int lineno;102};103DEFINE_LIST(struct config_key_binding);104105enum scaling_filter {106 SCALING_FILTER_NONE,107 SCALING_FILTER_NEAREST,108 SCALING_FILTER_BILINEAR,109 SCALING_FILTER_BOX,110 SCALING_FILTER_LINEAR,111 SCALING_FILTER_CUBIC,112 SCALING_FILTER_LANCZOS2,113 SCALING_FILTER_LANCZOS3,114 SCALING_FILTER_LANCZOS3_STRETCHED,115};116117struct config {118 char *output;119 char32_t *prompt;120 char32_t *placeholder;121 char32_t *search_text;122 char32_t *message;123 enum message_mode message_mode;124 bool prompt_only;125 enum match_fields match_fields;126127 char *namespace;128129 struct {130 char32_t character;131 bool enabled;132 bool character_set;133 } password_mode;134135 char *terminal;136 char *launch_prefix;137138 char *font;139 bool use_bold;140 enum dpi_aware dpi_aware;141 bool gamma_correct;142143 uint16_t render_worker_count;144 uint16_t match_worker_count;145146 bool filter_desktop;147148 bool icons_enabled;149 char *icon_theme;150151 bool hide_when_prompt_empty;152 bool hide_prompt;153154 bool actions_enabled;155156 struct config_key_binding_list key_bindings;157158 enum match_mode match_mode;159 bool sort_result;160 bool match_counter;161162 uint32_t delayed_filter_ms;163 uint32_t delayed_filter_limit;164165 struct {166 size_t min_length;167 size_t max_length_discrepancy;168 size_t max_distance;169 } fuzzy;170171 struct {172 bool enabled;173 enum dmenu_mode mode;174 bool exit_immediately_if_empty;175 bool only_match;176 char delim;177 char nth_delim;178 char *with_nth_format;179 char *accept_nth_format;180 char *match_nth_format;181 } dmenu;182183 enum anchors anchor;184185 struct {186 unsigned x;187 unsigned y;188 } margin;189190 unsigned lines;191 bool minimal_lines;192 unsigned chars;193 unsigned tabs; /* Tab stop every number of #spaces */194195 struct {196 unsigned x;197 unsigned y;198 unsigned inner;199 } pad;200201 struct {202 struct rgba background;203 struct rgba border;204 struct rgba text;205 struct rgba message;206 struct rgba prompt;207 struct rgba input;208 struct rgba match;209 struct rgba selection;210 struct rgba selection_text;211 struct rgba selection_match;212 struct rgba counter;213 struct rgba placeholder;214 } colors;215216 struct {217 unsigned size;218 unsigned radius;219 } border, selection_border;220221 float image_size_ratio;222223 enum scaling_filter png_scaling_filter;224225 struct pt_or_px line_height;226 struct pt_or_px letter_spacing;227228 enum zwlr_layer_shell_v1_layer layer;229 enum zwlr_layer_surface_v1_keyboard_interactivity keyboard_focus;230 bool exit_on_kb_focus_loss;231232 bool list_executables_in_path;233 char *cache_path;234235 bool auto_select;236 bool print_timing_info;237238 bool enable_mouse;239};240241typedef tll(char *) config_override_t;242243bool config_load(244 struct config *conf, const char *path, const config_override_t *overrides,245 bool errors_are_fatal);246void config_free(struct config *conf);247248struct rgba conf_hex_to_rgba(uint32_t color);