Skip to content
Myr

Merge branch 'config'

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Closes #3

authored by Daniel Eklöf · committed by Daniel Eklöf · parents 7cfb97e, 2844871 · Browse files · 18 files+1898 added−512 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

18 files+1898 added−512 removed

  • other:+1898 added−512 removed

18 files+1898 added−512 removed

modified:completions/zsh/_fuzzel+1 added
1#compdef fuzzel23_arguments \4 -s \5 '--config[path to configuration file (XDG_CONFIG_HOME/fuzzel/fuzzel.ini)]:config:_files' \6 '(-v --version)'{-v,--version}'[show the version number and quit]' \7 '(-h --help)'{-h,--help}'[show help message and quit]' \8 '(-o --output)'{-o,--output}'[output (monitor) to display on (none)]:output:->outputs' \9 '(-f --font)'{-f,--font}'[font name and style in fontconfig format (monospace)]:font:->fonts' \
53 unmodified lines
added:doc/fuzzel.1.scd+267 added
1fuzzel(1)23# NAME4fuzzel - display XDG applications in a searchable Wayland window56# SYNOPSIS7*fuzzel* [_OPTIONS_]...89# DESCRIPTION1011*fuzzel* lists all available XDG applications in a searchable12Window. The search box supports Emacs-like key bindings.1314The window size, font and colors can be configured with command line15options:1617*--config*=_PATH_18 Path to configuration file, see *fuzzel.ini*(5) for details.1920*-o*,*--output*=_OUTPUT_21 Specifies the monitor to display the window on. In _Sway_, you can22 list the available outputs with *swaymsg -t get_outputs*.2324 The default is to let the compositor choose output.2526*-f*,*--font*=_FONT_[,_FALLBACK1_,_FALLBACK2_,...]27 Comma separated list of primary font, and fallback fonts, in28 FontConfig format. See *FONT FORMAT*. Default: _monospace_.2930*-D*,*--dpi-aware*=_no|yes|auto_31 When set to *yes*, fonts are sized using the monitor's DPI, making32 a font of a given point size have the same physical size,33 regardless of monitor.34 35 In this mode, the monitor's scaling factor is ignored; doubling36 the scaling factor will *not* double the font size.37 38 When set to *no*, the monitor's DPI is ignored. The font is39 instead sized using the monitor's scaling factor; doubling the40 scaling factor *does* double the font size.41 42 Finally, if set to *auto*, fonts will be sized using the monitor's43 DPI if _all_ monitors have a scaling factor of 1. If at least one44 monitor as a scaling factor larger than 1 (regardless of whether45 the fuzzel window is mapped on that monitor or not), fonts will be46 scaled using the scaling factor.47 48 Note that this option typically does not work with bitmap fonts,49 which only contains a pre-defined set of sizes, and cannot be50 dynamically scaled. Whichever size (of the available ones) that51 best matches the DPI or scaling factor, will be used.52 53 Also note that if the font size has been specified in pixels54 (*:pixelsize=*_N_, instead of *:size=*_N_), DPI scaling55 (*dpi-aware=yes*) will have no effect (the specified pixel size56 will be used as is). But, if the monitor's scaling factor is used57 to size the font (*dpi-aware=no*), the font's pixel size will be58 multiplied with the scaling factor.59 60 Default: _auto_6162*-P*,*--prompt*=_PROMPT_63 Prompt to use. Default: _> _.6465*-i*,*--icon-theme*=_NAME_66 Icon theme to use. Note that this option is case sensitive; the67 name must match the theme's folder name.68 69 Example: _Adwaita_.70 71 Default: _hicolor_.7273*-I*,*--no-icons*74 Do not render any icons.7576*-F*,*--fields*=_FIELDS_77 Comma separated list of XDG Desktop entry fields to match against:78 79 - *filename*: the .desktop file's filename80 - *name*: the application's name (title)81 - *generic*: the application's generic name82 - *exec*: the applications's executable, as specified in the desktop file. Note: may include command line options as well.83 - *keywords*: the application's keywords84 - *categories*: the application's categories85 - *comment*: the application's comment86 87 Default: _filename,name,generic_8889*--password*=[_CHARACTER_]90 Password input. Render all typed text as _CHARACTER_. If91 _CHARACTER_ is omitted, a *\** will be used.9293*-T*,*--terminal*=_TERMINAL ARGS_94 Command to launch XDG applications with the property95 *Terminal=true* (_htop_, for example). Example: _xterm -e_.96 Default: _not set_.9798*-l*,*--lines*=COUNT99 The (maximum) number of matches to display. This dictates the100 window height. Default: _15_.101102*-w*,*--width*103 Window width, in characters. Margins and borders not104 included. Default: _30_.105106*-x*,*--horizontal-pad*=_PAD_107 Horizontal padding between border and icons and text. In pixels,108 subject to output scaling. Default: _40_.109110*-y*,*--vertical-pad*=_PAD_111 Vertical padding between border and text. In pixels, subject to112 output scaling. Default: _8_.113114*-p*,*--inner-pad*=_PAD_115 Vertical padding between prompt and match list. In pixels, subject to116 output scaling. Default: _0_.117118*-b*,*--background*=_HEX_119 Background color. See *COLORS*. Default: _fdf6e3dd_.120121*-t*,*--text-color*=_HEX_122 Text color. See *COLORS*. Default: _657b83ff_.123124*-m*,*--match-color*=_HEX_125 The color of matching substring(s). As you start typing in the search126 box, the matching part in each application's name is highlighted with127 this color. See *COLORS*. Default: _cb4b16ff_.128129*-s*,*--selection-color*=_HEX_130 The color to use as background of the currently selected131 application. See *COLORS*. Default: _eee8d5dd_.132133*-S*,*--selection-text-color*=_HEX_134 The text color of the currently selected application. See135 *COLORS*. Default: _657b83ff_.136137*-B*,*--border-width*=_INT_138 The width of the surrounding border, in pixels (subject to output139 scaling). Default: _1_.140141*-r*,*--border-radius*=_INT_142 The corner curvature. Larger means more rounded corners.143 0 disables rounded corners. Default: _10_.144145*-C*,*--border-color*=_HEX_146 The color of the border. See *COLORS*. Default: _002b36ff_.147148*--show-actions*149 Include desktop actions in the list. Desktop actions are150 alternative actions some desktop entries have. Examples include151 "New Window", "New Document", etc.152153*--no-fuzzy*154 Disables fuzzy matching. When disabled, only exact (case155 insensitive) substring matches are considered.156157*--fuzzy-min-length*=_VALUE_158 Search strings shorter than this will not by fuzzy159 matched. Default: _3_.160161*--fuzzy-max-length-discrepancy*=_VALUE_162 Maximum allowed length difference between the search string, and a163 fuzzy match. Larger values result in more fuzzy matches. Default:164 _2_.165166*--fuzzy-max-distance*=_VALUE_167 Maximum allowed levenshtein distance between the search string,168 and a fuzzy match. Larger values result in more fuzzy169 matches. Default: _1_.170171*--line-height*=_HEIGHT_172 Override line height from font metrics. In points by default, but173 can be specified as pixels by appending 'px'174 (i.e. *--line-height=16px*). Default: _not set_.175176*--letter-spacing*=_AMOUNT_177 Additional space between letters. In points by default, but can be178 specified as pixels by appending 'px'179 (i.e. *letter-spacing=5px*). Negative values are180 supported. Default: _0_.181182*--launch-prefix*=_COMMAND_183 Command to launch XDG applications with. Example: _swaymsg exec --_.184 Default: _not set_.185186*-d*,*--dmenu*187 dmenu compatibility mode. In this mode, the list entries are read188 from stdin (newline separated). The selected entry is printed to189 stdout. If the input string does not match any of the entries, the190 input string is printed as is on stdout.191 192 Alternatively, you can symlink the fuzzel binary to193 *dmenu*. Fuzzel will then start in dmenu mode, without the194 *--dmenu* argument.195196*--index*197 Print selected entry's index instead of its text. **dmenu** mode198 only.199200*-R*,*--no-run-if-empty*201 Exit immediately, without showing the UI, if stdin is202 empty. **dmenu** mode only.203204*--log-level*={*info*,*warning*,*error*,*none*}205 Log level, used both for log output on stderr as well as206 syslog. Default: _info_.207208*--log-colorize*=[{*never*,*always*,*auto*}]209 Enables or disables colorization of log output on stderr.210211*--log-no-syslog*212 Disables syslog logging. Logging is only done on stderr.213214*-v*,*--version*215 Show the version number and quit216217# CONFIGURATION218219fuzzel will search for a configuration file in the following locations,220in this order:221222 - *XDG_CONFIG_HOME/fuzzel/fuzzel.ini* (defaulting to223 *~/.config/fuzzel/fuzzel.ini* if unset)224 - *XDG_CONFIG_DIRS/fuzzel/fuzzel.ini* (defaulting to225 */etc/xdg/fuzzel/fuzzel.ini* if unset)226227An example configuration file containing all options with their default value228commented out will usually be installed to */etc/xdg/fuzzel/fuzzel.ini*.229230For more information, see *fuzzel.ini*(5).231232# FONT FORMAT233234The font is specified in FontConfig syntax. That is, a colon-separated235list of font name and font options.236237_Examples_:238- Dina:weight=bold:slant=italic239- Arial:size=12240241242# COLORS243244All colors must be specified as a RGBA quadruple, in hex format,245without a leading '0x'.246247_EXAMPLES_:248- white: *ffffffff* (no transparency)249- black: *000000ff* (no transparency)250- black: *00000010* (semi-transparent)251- red: *ff0000ff* (no transparency)252253The default color scheme is _Solarized_.254255# FILES256257_$XDG_CACHE_HOME/fuzzel_258 Stores a list of applications and their launch count. This allows259 fuzzel to sort frequently launched applications at the top.260261_$XDG_RUNTIME_DIR/fuzzel-$WAYLAND_DISPLAY.lock_262 Lock file, used to prevent multiple fuzzel instances from running263 at the same time.264265# SEE ALSO266267*fuzzel.ini*(5)
added:doc/fuzzel.ini.5.scd+208 added
1fuzzel.ini(5)23# NAME4fuzzel.ini - configuration file for *fuzzel*(1)567# DESCRIPTION89*fuzzel* uses the standard _unix configuration format_, with section10based key/value pairs. The default section is usually unnamed,11i.e. not prefixed with a _[section]_. However it can also be12explicitly named _[main]_, say if it needs to be reopened after any of13the other sections.1415fuzzel will search for a configuration file in the following locations,16in this order:1718 - *XDG_CONFIG_HOME/fuzzel/fuzzel.ini* (defaulting to19 *~/.config/fuzzel/fuzzel.ini* if unset)20 - *XDG_CONFIG_DIRS/fuzzel/fuzzel.ini* (defaulting to21 */etc/xdg/fuzzel/fuzzel.ini* if unset)2223An example configuration file containing all options with their default value24commented out will usually be installed to */etc/xdg/fuzzel/fuzzel.ini*.2526# SECTION: main2728*output*29 Output (monitor) to display on. If unset, the compositor will30 choose the monitor. Default: _not set_.3132*font*33 Comma separated list of fonts to use, in fontconfig format. That34 is, a font name followed by a list of colon-separated35 options. Most noteworthy is *:size=n*, which is used to set the36 font size. Note that the font size is also affected by the37 *dpi-aware* option.38 39 Examples:40 - Dina:weight=bold:slant=italic41 - Courier New:size=1242 - Fantasque Sans Mono:fontfeatures=ss0143 44 Default: _monospace_.4546*dpi-aware*47 *auto*, *yes*, or *no*.48 49 When set to *yes*, fonts are sized using the monitor's DPI, making50 a font of a given size have the same physical size, regardless of51 monitor.52 53 In this mode, the monitor's scaling factor is ignored; doubling54 the scaling factor will *not* double the font size.55 56 When set to *no*, the monitor's DPI is ignored. The font is57 instead sized using the monitor's scaling factor; doubling the58 scaling factor *does* double the font size.59 60 Finally, if set to *auto*, fonts will be sized using the monitor's61 DPI if _all_ monitors have a scaling factor of 1. If at least one62 monitor as a scaling factor larger than 1 (regardless of whether63 the fuzzel window is mapped on that monitor or not), fonts will be64 scaled using the scaling factor.65 66 Note that this option typically does not work with bitmap fonts,67 which only contains a pre-defined set of sizes, and cannot be68 dynamically scaled. Whichever size (of the available ones) that69 best matches the DPI or scaling factor, will be used.70 71 Also note that if the font size has been specified in pixels72 (*:pixelsize=*_N_, instead of *:size=*_N_), DPI scaling73 (*dpi-aware=yes*) will have no effect (the specified pixel size74 will be used as is). But, if the monitor's scaling factor is used75 to size the font (*dpi-aware=no*), the font's pixel size will be76 multiplied with the scaling factor.77 78 Default: _auto_.7980*prompt*=81 String to use as input prompt. Default: _> _.8283*icon-theme*84 Icon theme. Note that the name is case sensitive. Default:85 _hicolor_.8687*icons-enabled*88 Boolean. When enabled, application icons (from the selected89 *icon-theme*) will be rendered. Default: _yes_.9091*fields*92 Comma separated list of XDG Desktop entry fields to match93 against.94 95 Even though fuzzel only displays the application names,96 matching can (and by default is) be done against other fields as97 well. Supported fields are:98 99 - filename100 - name101 - generic102 - exec103 - categories104 - keywords105 - comment106 107 Default: _filename,name,generic_.108109*password-character*110 Default character to use with the command line option111 *--password*. Note that this can be overridden on the command112 line, by explicitly specifying the character with113 *--password=X*. Default: _\*_.114115*fuzzy*116 Boolean. Enables or disables fuzzy matching. Default: _yes_.117118*show-actions*119 Boolean. Some desktop files define "actions", in addition to the120 application itself. Examples are "new window", "preferences",121 etc. When this option is enabled, those actions will be listed by122 fuzzel. Default: _no_.123124*terminal*125 terminal command to use when launching 'terminal' programs,126 e.g. \"xterm -e\". Default: _not set_.127128*launch-prefix*129 Prefix to add before argv of executed program. Default: _not set_.130131*lines*132 Number of matches to show. Default: _15_.133134*width*135 Window width, in characters. Border and margins are not included136 in this. Default: _30_.137138*horizontal-pad*139 Horizontal padding, in pixels, between border and140 content. Default: _40_.141142*vertical-pad*143 Vertical padding, in pixels, between border and content. Default:144 _8_.145146*inner-pad*147 Vertical padding between prompt and match list, in148 pixels. Default: _0_.149150*line-height*151 Override line height from font metrics. Default: use font metrics.152153*letter-spacing*154 Additional letter spacing. Negative values are allowed. Default:155 _0_.156157158# SECTION: colors159160All color values are in RGBA.161162*background*163 Background color. Default: _fdf6e3dd_.164165*text*166 Text (foreground) color of unselected entries. Default:167 _657b83ff_.168169*match*170 Text (foreground) color of the matched substring. Default:171 _cb4b16ff_.172173*selection*174 Background color of the selected entry. Default: _eee8d5dd_.175176*selection-text*177 Text (foreground) color of the selected entry. Default:178 _657b83ff_.179180*border*181 Border color. Default: _002b36ff_.182183184# SECTION: border185186*width*187 Width of the border, in pixels. Default: _1_.188189*radius*190 Amount of corner "roundness". Default: _10_.191192193# SECTION: dmenu194195*mode*196 One of *text* or *index*. Determines what fuzzel prints on stdout197 when an entry is selected: *text* prints the entry itself, *index*198 prints the index of the selected entry. Default: _text_.199200*exit-immediately-if-empty*201 Boolean. If enabled, fuzzel will not run at all (i.e. it will not202 open a window, and will not print anything on stdout) if there's203 nothing on stdin. Default: _no_.204205206# SEE ALSO207208*fuzzel*(1)
deleted:doc/fuzzel.scd-245 removed
1fuzzel(1)23# NAME4fuzzel - display XDG applications in a searchable Wayland window56# SYNOPSIS7*fuzzel* [_OPTIONS_]...89# DESCRIPTION1011*fuzzel* lists all available XDG applications in a searchable12Window. The search box supports Emacs-like key bindings.1314The window size, font and colors can be configured with command line15options:1617*-o*,*--output*=_OUTPUT_18 Specifies the monitor to display the window on. In _Sway_, you can19 list the available outputs with *swaymsg -t get_outputs*.2021 The default is to let the compositor choose output.2223*-f*,*--font*=_FONT_[,_FALLBACK1_,_FALLBACK2_,...]24 Comma separated list of primary font, and fallback fonts, in25 FontConfig format. See *FONT FORMAT*. Default: _monospace_.2627*-D*,*--dpi-aware*=_no|yes|auto_28 When set to *yes*, fonts are sized using the monitor's DPI, making29 a font of a given point size have the same physical size,30 regardless of monitor.31 32 In this mode, the monitor's scaling factor is ignored; doubling33 the scaling factor will *not* double the font size.34 35 When set to *no*, the monitor's DPI is ignored. The font is36 instead sized using the monitor's scaling factor; doubling the37 scaling factor *does* double the font size.38 39 Finally, if set to *auto*, fonts will be sized using the monitor's40 DPI if _all_ monitors have a scaling factor of 1. If at least one41 monitor as a scaling factor larger than 1 (regardless of whether42 the fuzzel window is mapped on that monitor or not), fonts will be43 scaled using the scaling factor.44 45 Note that this option typically does not work with bitmap fonts,46 which only contains a pre-defined set of sizes, and cannot be47 dynamically scaled. Whichever size (of the available ones) that48 best matches the DPI or scaling factor, will be used.49 50 Also note that if the font size has been specified in pixels51 (*:pixelsize=*_N_, instead of *:size=*_N_), DPI scaling52 (*dpi-aware=yes*) will have no effect (the specified pixel size53 will be used as is). But, if the monitor's scaling factor is used54 to size the font (*dpi-aware=no*), the font's pixel size will be55 multiplied with the scaling factor.56 57 Default: _auto_5859*-P*,*--prompt*=_PROMPT_60 Prompt to use. Default: _> _.6162*-i*,*--icon-theme*=_NAME_63 Icon theme to use. Note that this option is case sensitive; the64 name must match the theme's folder name.65 66 Example: _Adwaita_.67 68 Default: _hicolor_.6970*-I*,*--no-icons*71 Do not render any icons.7273*-F*,*--fields*=_FIELDS_74 Comma separated list of XDG Desktop entry fields to match against:75 76 - *filename*: the .desktop file's filename77 - *name*: the application's name (title)78 - *generic*: the application's generic name79 - *exec*: the applications's executable, as specified in the desktop file. Note: may include command line options as well.80 - *keywords*: the application's keywords81 - *categories*: the application's categories82 - *comment*: the application's comment83 84 Default: _filename,name,generic_8586*--password*=[_CHARACTER_]87 Password input. Render all typed text as _CHARACTER_. If88 _CHARACTER_ is omitted, a *\** will be used.8990*-T*,*--terminal*=_TERMINAL ARGS_91 Command to launch XDG applications with the property92 *Terminal=true* (_htop_, for example). Example: _xterm -e_.93 Default: _not set_.9495*-l*,*--lines*=COUNT96 The (maximum) number of matches to display. This dictates the97 window height. Default: _15_.9899*-w*,*--width*100 Window width, in characters. Margins and borders not101 included. Default: _30_.102103*-x*,*--horizontal-pad*=_PAD_104 Horizontal padding between border and icons and text. In pixels,105 subject to output scaling. Default: _40_.106107*-y*,*--vertical-pad*=_PAD_108 Vertical padding between border and text. In pixels, subject to109 output scaling. Default: _8_.110111*-p*,*--inner-pad*=_PAD_112 Vertical padding between prompt and match list. In pixels, subject to113 output scaling. Default: _0_.114115*-b*,*--background*=_HEX_116 Background color. See *COLORS*. Default: _fdf6e3dd_.117118*-t*,*--text-color*=_HEX_119 Text color. See *COLORS*. Default: _657b83ff_.120121*-m*,*--match-color*=_HEX_122 The color of matching substring(s). As you start typing in the search123 box, the matching part in each application's name is highlighted with124 this color. See *COLORS*. Default: _cb4b16ff_.125126*-s*,*--selection-color*=_HEX_127 The color to use as background of the currently selected128 application. See *COLORS*. Default: _eee8d5dd_.129130*-S*,*--selection-text-color*=_HEX_131 The text color of the currently selected application. See132 *COLORS*. Default: _0x657b83ff_.133134*-B*,*--border-width*=_INT_135 The width of the surrounding border, in pixels (subject to output136 scaling). Default: _1_.137138*-r*,*--border-radius*=_INT_139 The corner curvature. Larger means more rounded corners.140 0 disables rounded corners. Default: _10_.141142*-C*,*--border-color*=_HEX_143 The color of the border. See *COLORS*. Default: _002b36ff_.144145*--show-actions*146 Include desktop actions in the list. Desktop actions are147 alternative actions some desktop entries have. Examples include148 "New Window", "New Document", etc.149150*--no-fuzzy*151 Disables fuzzy matching. When disabled, only exact (case152 insensitive) substring matches are considered.153154*--fuzzy-min-length*=_VALUE_155 Search strings shorter than this will not by fuzzy156 matched. Default: _3_.157158*--fuzzy-max-length-discrepancy*=_VALUE_159 Maximum allowed length difference between the search string, and a160 fuzzy match. Larger values result in more fuzzy matches. Default:161 _2_.162163*--fuzzy-max-distance*=_VALUE_164 Maximum allowed levenshtein distance between the search string,165 and a fuzzy match. Larger values result in more fuzzy166 matches. Default: _1_.167168*--line-height*=_HEIGHT_169 Override line height from font metrics. In points by default, but170 can be specified as pixels by appending 'px'171 (i.e. *--line-height=16px*). Default: _not set_.172173*--letter-spacing*=_AMOUNT_174 Additional space between letters. In points by default, but can be175 specified as pixels by appending 'px'176 (i.e. *letter-spacing=5px*). Negative values are177 supported. Default: _0_.178179*--launch-prefix*=_COMMAND_180 Command to launch XDG applications with. Example: _swaymsg exec --_.181 Default: _not set_.182183*-d*,*--dmenu*184 dmenu compatibility mode. In this mode, the list entries are read185 from stdin (newline separated). The selected entry is printed to186 stdout. If the input string does not match any of the entries, the187 input string is printed as is on stdout.188 189 Alternatively, you can symlink the fuzzel binary to190 *dmenu*. Fuzzel will then start in dmenu mode, without the191 *--dmenu* argument.192193*--index*194 Print selected entry's index instead of its text. **dmenu** mode195 only.196197*-R*,*--no-run-if-empty*198 Exit immediately, without showing the UI, if stdin is199 empty. **dmenu** mode only.200201*--log-level*={*info*,*warning*,*error*,*none*}202 Log level, used both for log output on stderr as well as203 syslog. Default: _info_.204205*--log-colorize*=[{*never*,*always*,*auto*}]206 Enables or disables colorization of log output on stderr.207208*--log-no-syslog*209 Disables syslog logging. Logging is only done on stderr.210211*-v*,*--version*212 Show the version number and quit213214# FONT FORMAT215216The font is specified in FontConfig syntax. That is, a colon-separated217list of font name and font options.218219_Examples_:220- Dina:weight=bold:slant=italic221- Arial:size=12222223224# COLORS225226All colors must be specified as a RGBA quadruple, in hex format,227without a leading '0x'.228229_EXAMPLES_:230- white: *ffffffff* (no transparency)231- black: *000000ff* (no transparency)232- black: *00000010* (semi-transparent)233- red: *ff0000ff* (no transparency)234235The default color scheme is _Solarized_.236237# FILES238239_$XDG_CACHE_HOME/fuzzel_240 Stores a list of applications and their launch count. This allows241 fuzzel to sort frequently launched applications at the top.242243_$XDG_RUNTIME_DIR/fuzzel-$WAYLAND_DISPLAY.lock_244 Lock file, used to prevent multiple fuzzel instances from running245 at the same time.
modified:doc/meson.build+7 added-5 removed
1sh = find_program('sh', native: true)2scdoc = dependency('scdoc', native: true)3scdoc_prog = find_program(scdoc.get_variable('scdoc'), native: true)45foreach man_src : ['fuzzel.scd']6 base = man_src.split('.')[-2]7 out = '@0@.1'.format(base)5foreach man_src : [{'name': 'fuzzel', 'section': 1},6 {'name': 'fuzzel.ini', 'section': 5}]7 name = man_src['name']8 section = man_src['section']9 out = '@0@.@1@'.format(name, section)1011 custom_target(12 out,13 output: out,12 input: man_src,14 input: '@0@.@1@.scd'.format(name, section),15 command: [sh, '-c', '@0@ < @INPUT@'.format(scdoc_prog.full_path())],16 capture: true,17 install: true,16 install_dir: join_paths(get_option('mandir'), 'man1'))18 install_dir: join_paths(get_option('mandir'), 'man@0@'.format(section)))19endforeach
modified:CHANGELOG.md+2 added
19 unmodified lines
20## Unreleased2122### Added2324* Support for file based configuration25 (https://codeberg.org/dnkl/fuzzel/issues/3).26* If `argv[0]` is _dmenu_, fuzzel now starts in dmenu mode27 (https://codeberg.org/dnkl/fuzzel/issues/107).28* `--password=[CHARACTER]` command line option. Intended to be used29 with “password input”; all typed text is rendered as _CHARACTER_,
330 unmodified lines
added:config.c+957 added
1#include "config.h"23#include <sys/types.h>4#include <sys/stat.h>56#include <stdio.h>7#include <assert.h>8#include <errno.h>9#include <fcntl.h>10#include <limits.h>11#include <pwd.h>12#include <stdio.h>13#include <stdlib.h>14#include <string.h>15#include <unistd.h>16#include <ctype.h>171819#define LOG_MODULE "config"20#define LOG_ENABLE_DBG 021#include "log.h"2223#define ALEN(v) (sizeof(v) / sizeof((v)[0]))2425struct context {26 struct config *conf;27 const char *section;28 const char *key;29 const char *value;3031 const char *path;32 unsigned lineno;3334 bool errors_are_fatal;35};3637#define LOG_CONTEXTUAL_ERR(...) \38 log_contextual(ctx, LOG_CLASS_ERROR, __FILE__, __LINE__, __VA_ARGS__)3940#define LOG_CONTEXTUAL_WARN(...) \41 log_contextual(ctx, LOG_CLASS_WARNING, __FILE__, __LINE__, __VA_ARGS__)4243#define LOG_CONTEXTUAL_ERRNO(...) \44 log_contextual_errno(ctx, __FILE__, __LINE__, __VA_ARGS__)454647static void __attribute__((format(printf, 5, 6)))48log_contextual(struct context *ctx, enum log_class log_class,49 const char *file, int lineno, const char *fmt, ...)50{51 char *formatted_msg = NULL;52 va_list va;53 va_start(va, fmt);54 if (vasprintf(&formatted_msg, fmt, va) < 0) {55 va_end(va);56 return;57 }5859 va_end(va);6061 bool print_dot = ctx->key != NULL;62 bool print_colon = ctx->value != NULL;6364 if (!print_dot)65 ctx->key = "";6667 if (!print_colon)68 ctx->value = "";6970 log_msg(71 log_class, LOG_MODULE, file, lineno, "%s:%d: [%s]%s%s%s%s: %s",72 ctx->path, ctx->lineno, ctx->section, print_dot ? "." : "",73 ctx->key, print_colon ? ": " : "", ctx->value, formatted_msg);74 free(formatted_msg);75}7677struct config_file {78 char *path; /* Full, absolute, path */79 int fd; /* FD of file, O_RDONLY */80};8182static const char *83get_user_home_dir(void)84{85 const struct passwd *passwd = getpwuid(getuid());86 if (passwd == NULL)87 return NULL;88 return passwd->pw_dir;89}9091static struct config_file92open_config(void)93{94 char *path = NULL;95 struct config_file ret = {.path = NULL, .fd = -1};9697 const char *xdg_config_home = getenv("XDG_CONFIG_HOME");98 const char *xdg_config_dirs = getenv("XDG_CONFIG_DIRS");99 const char *home_dir = get_user_home_dir();100 char *xdg_config_dirs_copy = NULL;101102 /* First, check XDG_CONFIG_HOME (or .config, if unset) */103 if (xdg_config_home != NULL && xdg_config_home[0] != '\0') {104 if (asprintf(&path, "%s/fuzzel/fuzzel.ini", xdg_config_home) < 0) {105 LOG_ERRNO("failed to build fuzzel.ini path");106 goto done;107 }108 } else if (home_dir != NULL) {109 if (asprintf(&path, "%s/.config/fuzzel/fuzzel.ini", home_dir) < 0) {110 LOG_ERRNO("failed to build fuzzel.ini path");111 goto done;112 }113 }114115 if (path != NULL) {116 int fd = open(path, O_RDONLY | O_CLOEXEC);117118 if (fd >= 0) {119 ret = (struct config_file) {.path = path, .fd = fd};120 path = NULL;121 goto done;122 }123 }124125 xdg_config_dirs_copy = xdg_config_dirs != NULL && xdg_config_dirs[0] != '\0'126 ? strdup(xdg_config_dirs)127 : strdup("/etc/xdg");128129 if (xdg_config_dirs_copy == NULL || xdg_config_dirs_copy[0] == '\0')130 goto done;131132 for (const char *conf_dir = strtok(xdg_config_dirs_copy, ":");133 conf_dir != NULL;134 conf_dir = strtok(NULL, ":"))135 {136 free(path);137 path = NULL;138139 if (asprintf(&path, "%s/fuzzel/fuzzel.ini", conf_dir) < 0) {140 LOG_ERRNO("failed to build fuzzel.ini path");141 goto done;142 }143144 int fd = open(path, O_RDONLY | O_CLOEXEC);145 if (fd >= 0) {146 ret = (struct config_file){.path = path, .fd = fd};147 path = NULL;148 goto done;149 }150 }151152done:153 free(xdg_config_dirs_copy);154 free(path);155 return ret;156}157158static bool159str_to_ulong(const char *s, int base, unsigned long *res)160{161 if (s == NULL)162 return false;163164 errno = 0;165 char *end = NULL;166167 *res = strtoul(s, &end, base);168 return errno == 0 && *end == '\0';169}170171static bool172str_to_uint32(const char *s, int base, uint32_t *res)173{174 unsigned long v;175 bool ret = str_to_ulong(s, base, &v);176 if (!ret)177 return false;178 if (v > UINT32_MAX)179 return false;180 *res = v;181 return true;182}183184static bool185value_to_str(struct context *ctx, char **res)186{187 free(*res);188 *res = strdup(ctx->value);189 return true;190}191192static bool193value_to_wchars(struct context *ctx, char32_t **res)194{195 char32_t *s = ambstoc32(ctx->value);196 if (s == NULL) {197 LOG_CONTEXTUAL_ERR("not a valie string value");198 return false;199 }200201 free(*res);202 *res = s;203 return true;204}205206static bool207value_to_bool(struct context *ctx, bool *res)208{209 static const char *const yes[] = {"on", "true", "yes", "1"};210 static const char *const no[] = {"off", "false", "no", "0"};211212 for (size_t i = 0; i < ALEN(yes); i++) {213 if (strcasecmp(ctx->value, yes[i]) == 0) {214 *res = true;215 return true;216 }217 }218219 for (size_t i = 0; i < ALEN(no); i++) {220 if (strcasecmp(ctx->value, no[i]) == 0) {221 *res = false;222 return true;223 }224 }225226 LOG_CONTEXTUAL_ERR("invalid boolean value");227 return false;228}229230static bool231value_to_uint32(struct context *ctx, int base, uint32_t *res)232{233 if (!str_to_uint32(ctx->value, base, res)){234 LOG_CONTEXTUAL_ERR(235 "invalid integer value, or outside range 0-%u", UINT32_MAX);236 return false;237 }238 return true;239}240241static bool242value_to_color(struct context *ctx, bool allow_alpha, struct rgba *color)243{244 if (strlen(ctx->value) != 8) {245 LOG_CONTEXTUAL_ERR("not a valid color value");246 return false;247 }248249 uint32_t v;250 if (!str_to_uint32(ctx->value, 16, &v)) {251 LOG_CONTEXTUAL_ERR("not a valid color value");252 return false;253 }254255 if (!allow_alpha && (v & 0x000000ff) != 0) {256 LOG_CONTEXTUAL_ERR("color value must not have an alpha component");257 return false;258 }259260 *color = conf_hex_to_rgba(v);261 return true;262}263264static bool265value_to_double(struct context *ctx, float *res)266{267 const char *s = ctx->value;268269 if (s == NULL)270 return false;271272 errno = 0;273 char *end = NULL;274275 *res = strtof(s, &end);276 if (!(errno == 0 && *end == '\0')) {277 LOG_CONTEXTUAL_ERR("invalid decimal value");278 return false;279 }280281 return true;282}283284static bool285value_to_pt_or_px(struct context *ctx, struct pt_or_px *res)286{287 const char *s = ctx->value;288289 size_t len = s != NULL ? strlen(s) : 0;290 if (len >= 2 && s[len - 2] == 'p' && s[len - 1] == 'x') {291 errno = 0;292 char *end = NULL;293294 long value = strtol(s, &end, 10);295 if (!(errno == 0 && end == s + len - 2)) {296 LOG_CONTEXTUAL_ERR("invalid px value (must be on the form 12px)");297 return false;298 }299 res->pt = 0;300 res->px = value;301 } else {302 float value;303 if (!value_to_double(ctx, &value))304 return false;305 res->pt = value;306 res->px = 0;307 }308309 return true;310}311312static bool313value_to_enum(struct context *ctx, const char **value_map, int *res)314{315 size_t str_len = 0;316 size_t count = 0;317318 for (; value_map[count] != NULL; count++) {319 if (strcasecmp(value_map[count], ctx->value) == 0) {320 *res = count;321 return true;322 }323 str_len += strlen(value_map[count]);324 }325326 const size_t size = str_len + count * 4 + 1;327 char valid_values[512];328 size_t idx = 0;329 assert(size < sizeof(valid_values));330331 for (size_t i = 0; i < count; i++)332 idx += snprintf(&valid_values[idx], size - idx, "'%s', ", value_map[i]);333334 if (count > 0)335 valid_values[idx - 2] = '\0';336337 LOG_CONTEXTUAL_ERR("not one of %s", valid_values);338 *res = -1;339 return false;340}341342343static bool parse_config_file(344 FILE *f, struct config *conf, const char *path, bool errors_are_fatal);345346static bool347parse_section_main(struct context *ctx)348{349 struct config *conf = ctx->conf;350 const char *key = ctx->key;351 const char *value = ctx->value;352353 if (strcmp(key, "output") == 0)354 return value_to_str(ctx, &conf->output);355356 else if (strcmp(key, "font") == 0)357 return value_to_str(ctx, &conf->font);358359 else if (strcmp(key, "dpi-aware") == 0) {360 if (strcmp(value, "auto") == 0)361 conf->dpi_aware = DPI_AWARE_AUTO;362 else {363 bool value;364 if (!value_to_bool(ctx, &value))365 return false;366 conf->dpi_aware = value ? DPI_AWARE_YES : DPI_AWARE_NO;367 }368 return true;369 }370371 else if (strcmp(key, "prompt") == 0)372 return value_to_wchars(ctx, &conf->prompt);373374 else if (strcmp(key, "icon-theme") == 0)375 return value_to_str(ctx, &conf->icon_theme);376377 else if (strcmp(key, "icons-enabled") == 0)378 return value_to_bool(ctx, &conf->icons_enabled);379380 else if (strcmp(key, "fields") == 0) {381 _Static_assert(sizeof(conf->match_fields) == sizeof(int),382 "enum is not 32-bit");383384 return value_to_enum(385 ctx,386 (const char *[]){387 "filename",388 "name",389 "generic",390 "exec",391 "categories",392 "keywords",393 "comment",394 NULL},395 (int *)&conf->match_fields);396 }397398 else if (strcmp(key, "password-character") == 0) {399 char32_t *password_chars = ambstoc32(value);400 if (password_chars == NULL || c32len(password_chars) != 1) {401 LOG_CONTEXTUAL_ERR("ivnalid password character");402 free(password_chars);403 return false;404 }405406 conf->password = password_chars[0];407 free(password_chars);408 return true;409 }410411 else if (strcmp(key, "fuzzy") == 0)412 return value_to_bool(ctx, &conf->fuzzy.enabled);413414 else if (strcmp(key, "show-actions") == 0)415 return value_to_bool(ctx, &conf->actions_enabled);416417 else if (strcmp(key, "terminal") == 0)418 return value_to_str(ctx, &conf->terminal);419420 else if (strcmp(key, "launch-prefix") == 0)421 return value_to_str(ctx, &conf->launch_prefix);422423 else if (strcmp(key, "lines") == 0)424 return value_to_uint32(ctx, 10, &conf->lines);425426 else if (strcmp(key, "width") == 0)427 return value_to_uint32(ctx, 10, &conf->chars);428429 else if (strcmp(key, "horizontal-pad") == 0)430 return value_to_uint32(ctx, 10, &conf->pad.x);431432 else if (strcmp(key, "vertical-pad") == 0)433 return value_to_uint32(ctx, 10, &conf->pad.y);434435 else if (strcmp(key, "inner-pad") == 0)436 return value_to_uint32(ctx, 10, &conf->pad.inner);437438 else if (strcmp(key, "line-height") == 0)439 return value_to_pt_or_px(ctx, &conf->line_height);440441 else if (strcmp(key, "letter-spacing") == 0)442 return value_to_pt_or_px(ctx, &conf->letter_spacing);443444 else445 LOG_CONTEXTUAL_ERR("not a valid option: %s", key);446447 return false;448}449450static bool451parse_section_colors(struct context *ctx)452{453 struct config *conf = ctx->conf;454 const char *key = ctx->key;455456 if (strcmp(key, "background") == 0)457 return value_to_color(ctx, true, &conf->colors.background);458459 else if (strcmp(key, "text") == 0)460 return value_to_color(ctx, true, &conf->colors.text);461462 else if (strcmp(key, "match") == 0)463 return value_to_color(ctx, true, &conf->colors.match);464465 else if (strcmp(key, "selection") == 0)466 return value_to_color(ctx, true, &conf->colors.selection);467468 else if (strcmp(key, "selection-text") == 0)469 return value_to_color(ctx, true, &conf->colors.selection_text);470471 else if (strcmp(key, "border") == 0)472 return value_to_color(ctx, true, &conf->colors.border);473474 else475 LOG_CONTEXTUAL_ERR("not a valid option: %s", key);476477 return false;478}479480static bool481parse_section_border(struct context *ctx)482{483 struct config *conf = ctx->conf;484 const char *key = ctx->key;485486 if (strcmp(key, "width") == 0)487 return value_to_uint32(ctx, 10, &conf->border.size);488489 else if (strcmp(key, "radius") == 0)490 return value_to_uint32(ctx, 10, &conf->border.radius);491492 else493 LOG_CONTEXTUAL_ERR("not a valid option: %s", key);494495 return false;496}497498static bool499parse_section_dmenu(struct context *ctx)500{501 struct config *conf = ctx->conf;502 const char *key = ctx->key;503504 if (strcmp(key, "mode") == 0) {505 _Static_assert(sizeof(conf->dmenu.mode) == sizeof(int),506 "enum is not 32-bit");507508 return value_to_enum(509 ctx,510 (const char *[]){"text", "index", NULL},511 (int *)&conf->dmenu.mode);512 }513514 else if (strcmp(key, "exit-immediately-if-empty") == 0)515 return value_to_bool(ctx, &conf->dmenu.exit_immediately_if_empty);516517 else518 LOG_CONTEXTUAL_ERR("not a valid option: %s", key);519520 return false;521}522523enum section {524 SECTION_MAIN,525 SECTION_COLORS,526 SECTION_BORDER,527 SECTION_DMENU,528 SECTION_COUNT,529};530531/* Function pointer, called for each key/value line */532typedef bool (*parser_fun_t)(struct context *ctx);533534static const struct {535 parser_fun_t fun;536 const char *name;537} section_info[] = {538 [SECTION_MAIN] = {&parse_section_main, "main"},539 [SECTION_COLORS] = {&parse_section_colors, "colors"},540 [SECTION_BORDER] = {&parse_section_border, "border"},541 [SECTION_DMENU] = {&parse_section_dmenu, "dmenu"},542};543544static enum section545str_to_section(const char *str)546{547 for (enum section section = SECTION_MAIN; section < SECTION_COUNT; ++section) {548 if (strcmp(str, section_info[section].name) == 0)549 return section;550 }551 return SECTION_COUNT;552}553554static bool555parse_key_value(char *kv, const char **section, const char **key, const char **value)556{557 bool section_is_needed = section != NULL;558559 /* Strip leading whitespace */560 while (isspace(kv[0]))561 ++kv;562563 if (section_is_needed)564 *section = "main";565566 if (kv[0] == '=')567 return false;568569 *key = kv;570 *value = NULL;571572 size_t kvlen = strlen(kv);573574 /* Strip trailing whitespace */575 while (isspace(kv[kvlen - 1]))576 kvlen--;577 kv[kvlen] = '\0';578579 for (size_t i = 0; i < kvlen; ++i) {580 if (kv[i] == '.' && section_is_needed) {581 section_is_needed = false;582 *section = kv;583 kv[i] = '\0';584 if (i == kvlen - 1 || kv[i + 1] == '=') {585 *key = NULL;586 return false;587 }588 *key = &kv[i + 1];589 } else if (kv[i] == '=') {590 kv[i] = '\0';591 if (i != kvlen - 1)592 *value = &kv[i + 1];593 break;594 }595 }596597 if (*value == NULL)598 return false;599600 /* Strip trailing whitespace from key (leading stripped earlier) */601 {602 assert(!isspace(*key[0]));603604 char *end = (char *)*key + strlen(*key) - 1;605 while (isspace(end[0]))606 end--;607 end[1] = '\0';608 }609610 /* Strip leading whitespace from value (trailing stripped earlier) */611 while (isspace(*value[0]))612 ++*value;613614 return true;615}616617static bool618parse_config_file(FILE *f, struct config *conf, const char *path,619 bool errors_are_fatal)620{621 enum section section = SECTION_MAIN;622623 char *_line = NULL;624 size_t count = 0;625 bool ret = true;626627#define error_or_continue() \628 { \629 if (errors_are_fatal) { \630 ret = false; \631 goto done; \632 } else \633 continue; \634 }635636 char *section_name = strdup("main");637638 struct context context = {639 .conf = conf,640 .section = section_name,641 .path = path,642 .lineno = 0,643 .errors_are_fatal = errors_are_fatal,644 };645 struct context *ctx = &context; /* For LOG_AND_*() */646647 errno = 0;648 ssize_t len;649650 while ((len = getline(&_line, &count, f)) != -1) {651 context.key = NULL;652 context.value = NULL;653 context.lineno++;654655 char *line = _line;656657 /* Strip leading whitespace */658 while (isspace(line[0])) {659 line++;660 len--;661 }662663 /* Empty line, or comment */664 if (line[0] == '\0' || line[0] == '#')665 continue;666667 /* Strip the trailing newline - may be absent on the last line */668 if (line[len - 1] == '\n')669 line[--len] = '\0';670671 /* Split up into key/value pair + trailing comment separated by blank */672 char *key_value = line;673 char *kv_trailing = &line[len - 1];674 char *comment = &line[1];675 while (comment[1] != '\0') {676 if (isblank(comment[0]) && comment[1] == '#') {677 comment[1] = '\0'; /* Terminate key/value pair */678 kv_trailing = comment++;679 break;680 }681 comment++;682 }683 comment++;684685 /* Strip trailing whitespace */686 while (isspace(kv_trailing[0]))687 kv_trailing--;688 kv_trailing[1] = '\0';689690 /* Check for new section */691 if (key_value[0] == '[') {692 key_value++;693694 if (key_value[0] == ']') {695 LOG_CONTEXTUAL_ERR("empty section name");696 section = SECTION_COUNT;697 error_or_continue();698 }699700 char *end = strchr(key_value, ']');701702 if (end == NULL) {703 context.section = key_value;704 LOG_CONTEXTUAL_ERR("syntax error: no closing ']'");705 context.section = section_name;706 section = SECTION_COUNT;707 error_or_continue();708 }709710 end[0] = '\0';711712 if (end[1] != '\0') {713 context.section = key_value;714 LOG_CONTEXTUAL_ERR("section declaration contains trailing "715 "characters");716 context.section = section_name;717 section = SECTION_COUNT;718 error_or_continue();719 }720721 section = str_to_section(key_value);722 if (section == SECTION_COUNT) {723 context.section = key_value;724 LOG_CONTEXTUAL_ERR("invalid section name: %s", key_value);725 context.section = section_name;726 error_or_continue();727 }728729 free(section_name);730 section_name = strdup(key_value);731 context.section = section_name;732733 /* Process next line */734 continue;735 }736737 if (section >= SECTION_COUNT) {738 /* Last section name was invalid; ignore all keys in it */739 continue;740 }741742 if (!parse_key_value(key_value, NULL, &context.key, &context.value)) {743 LOG_CONTEXTUAL_ERR("syntax error: key/value pair has no %s",744 context.key == NULL ? "key" : "value");745 error_or_continue();746 }747748 LOG_DBG("section=%s, key='%s', value='%s', comment='%s'",749 section_info[section].name, context.key, context.value, comment);750751 assert(section >= 0 && section < SECTION_COUNT);752753 parser_fun_t section_parser = section_info[section].fun;754 assert(section_parser != NULL);755756 if (!section_parser(ctx))757 error_or_continue();758 }759760 if (errno != 0) {761 LOG_ERRNO("failed to read from configuration");762 if (errors_are_fatal)763 ret = false;764 }765766done:767 free(section_name);768 free(_line);769 return ret;770}771772static bool773overrides_apply(struct config *conf, const config_override_t *overrides,774 bool errors_are_fatal)775{776 if (overrides == NULL)777 return true;778779 struct context context = {780 .conf = conf,781 .path = "override",782 .lineno = 0,783 .errors_are_fatal = errors_are_fatal,784 };785 struct context *ctx = &context;786787 tll_foreach(*overrides, it) {788 context.lineno++;789790 if (!parse_key_value(791 it->item, &context.section, &context.key, &context.value))792 {793 LOG_CONTEXTUAL_ERR("syntax error: key/value pair has no %s",794 context.key == NULL ? "key" : "value");795 if (errors_are_fatal)796 return false;797 continue;798 }799800 if (context.section[0] == '\0') {801 LOG_CONTEXTUAL_ERR("empty section name");802 if (errors_are_fatal)803 return false;804 continue;805 }806807 enum section section = str_to_section(context.section);808 if (section == SECTION_COUNT) {809 LOG_CONTEXTUAL_ERR("invalid section name: %s", context.section);810 if (errors_are_fatal)811 return false;812 continue;813 }814 parser_fun_t section_parser = section_info[section].fun;815 assert(section_parser != NULL);816817 if (!section_parser(ctx)) {818 if (errors_are_fatal)819 return false;820 continue;821 }822 }823824#if 0825 return826 resolve_key_binding_collisions(827 conf, section_info[SECTION_KEY_BINDINGS].name,828 binding_action_map, &conf->bindings.key, KEY_BINDING) &&829 resolve_key_binding_collisions(830 conf, section_info[SECTION_SEARCH_BINDINGS].name,831 search_binding_action_map, &conf->bindings.search, KEY_BINDING) &&832 resolve_key_binding_collisions(833 conf, section_info[SECTION_URL_BINDINGS].name,834 url_binding_action_map, &conf->bindings.url, KEY_BINDING) &&835 resolve_key_binding_collisions(836 conf, section_info[SECTION_MOUSE_BINDINGS].name,837 binding_action_map, &conf->bindings.mouse, MOUSE_BINDING);838#endif839 return true;840}841842bool843config_load(struct config *conf, const char *conf_path,844 const config_override_t *overrides, bool errors_are_fatal)845{846 bool ret = !errors_are_fatal;847 *conf = (struct config) {848 .output = NULL,849 .prompt = c32dup(U"> "),850 .password = U'\0',851 .match_fields = MATCH_FILENAME | MATCH_NAME | MATCH_GENERIC,852 .terminal = NULL,853 .launch_prefix = NULL,854 .font = strdup("monospace"),855 .dpi_aware = DPI_AWARE_AUTO,856 .icons_enabled = true,857 .icon_theme = strdup("hicolor"),858 .actions_enabled = false,859 .fuzzy = {860 .min_length = 3,861 .max_length_discrepancy = 2,862 .max_distance = 1,863 .enabled = true,864 },865 .dmenu = {866 .enabled = false,867 .mode = DMENU_MODE_TEXT,868 .exit_immediately_if_empty = false,869 },870 .lines = 15,871 .chars = 30,872 .pad = {873 .x = 40,874 .y = 8,875 .inner = 0,876 },877 .colors = {878 .background = conf_hex_to_rgba(0xfdf6e3dd),879 .border = conf_hex_to_rgba(0x002b36ff),880 .text = conf_hex_to_rgba(0x657b83ff),881 .match = conf_hex_to_rgba(0xcb4b16ff),882 .selection = conf_hex_to_rgba(0xeee8d5dd),883 .selection_text = conf_hex_to_rgba(0x657b83ff),884 },885 .border = {886 .size = 1u,887 .radius = 10u,888 },889 .line_height = {-1, 0.0},890 .letter_spacing = {0},891 };892893 struct config_file conf_file = {.path = NULL, .fd = -1};894 if (conf_path != NULL) {895 int fd = open(conf_path, O_RDONLY);896 if (fd < 0) {897 LOG_ERRNO("%s: failed to open", conf_path);898 goto out;899 }900901 conf_file.path = strdup(conf_path);902 conf_file.fd = fd;903 } else {904 conf_file = open_config();905 if (conf_file.fd < 0) {906 LOG_WARN("no configuration found, using defaults");907 goto out;908 }909 }910911 LOG_INFO("loading configuration from %s", conf_file.path);912913 FILE *f = fdopen(conf_file.fd, "r");914 if (f == NULL) {915 LOG_ERRNO("%s: failed to open", conf_file.path);916 goto out;917 }918919 if (!parse_config_file(f, conf, conf_file.path, errors_are_fatal) ||920 !overrides_apply(conf, overrides, errors_are_fatal))921 {922 ret = !errors_are_fatal;923 } else924 ret = true;925926 fclose(f);927928out:929930 free(conf_file.path);931 if (conf_file.fd >= 0)932 close(conf_file.fd);933934 return ret;935}936937void938config_free(struct config *conf)939{940 free(conf->output);941 free(conf->prompt);942 free(conf->terminal);943 free(conf->launch_prefix);944 free(conf->font);945 free(conf->icon_theme);946}947948struct rgba949conf_hex_to_rgba(uint32_t color)950{951 return (struct rgba){952 .r = (double)((color >> 24) & 0xff) / 255.0,953 .g = (double)((color >> 16) & 0xff) / 255.0,954 .b = (double)((color >> 8) & 0xff) / 255.0,955 .a = (double)((color >> 0) & 0xff) / 255.0,956 };957}
added:config.h+97 added
1#pragma once23#include <stdint.h>4#include <stdbool.h>5#include <char32.h>67#include <tllist.h>89struct rgba {double r; double g; double b; double a;};10struct pt_or_px {int px; float pt;};1112enum dpi_aware {13 DPI_AWARE_AUTO,14 DPI_AWARE_YES,15 DPI_AWARE_NO,16};1718enum dmenu_mode {19 DMENU_MODE_TEXT,20 DMENU_MODE_INDEX,21};2223enum match_fields {24 MATCH_FILENAME = 0x01,25 MATCH_NAME = 0x02,26 MATCH_GENERIC = 0x04,27 MATCH_EXEC = 0x08,28 MATCH_CATEGORIES = 0x10,29 MATCH_KEYWORDS = 0x20,30 MATCH_COMMENT = 0x40,31};3233struct config {34 char *output;35 char32_t *prompt;36 char32_t password;37 enum match_fields match_fields;3839 char *terminal;40 char *launch_prefix;4142 char *font;43 enum dpi_aware dpi_aware;4445 bool icons_enabled;46 char *icon_theme;4748 bool actions_enabled;4950 struct {51 size_t min_length;52 size_t max_length_discrepancy;53 size_t max_distance;54 bool enabled;55 } fuzzy;5657 struct {58 bool enabled;59 enum dmenu_mode mode;60 bool exit_immediately_if_empty;61 } dmenu;6263 unsigned lines;64 unsigned chars;6566 struct {67 unsigned x;68 unsigned y;69 unsigned inner;70 } pad;7172 struct {73 struct rgba background;74 struct rgba border;75 struct rgba text;76 struct rgba match;77 struct rgba selection;78 struct rgba selection_text;79 } colors;8081 struct {82 unsigned size;83 unsigned radius;84 } border;8586 struct pt_or_px line_height;87 struct pt_or_px letter_spacing;88};8990typedef tll(char *) config_override_t;9192bool config_load(93 struct config *conf, const char *path, const config_override_t *overrides,94 bool errors_are_fatal);95void config_free(struct config *conf);9697struct rgba conf_hex_to_rgba(uint32_t color);
modified:dmenu.c-4 removed
98 unmodified lines
99dmenu_execute(const struct application *app, ssize_t index,100 const struct prompt *prompt, enum dmenu_mode format)101{102 switch (format) {103 case DMENU_MODE_NONE:104 assert(false);105 return false;106103 case DMENU_MODE_TEXT: {104 char *text = ac32tombs(app != NULL ? app->title : prompt_text(prompt));105 if (text != NULL)106 printf("%s\n", text);
11 unmodified lines
modified:dmenu.h+1 added-2 removed
1 unmodified line
23#include <sys/types.h>45#include "application.h"6#include "config.h"7#include "prompt.h"88enum dmenu_mode { DMENU_MODE_NONE, DMENU_MODE_TEXT, DMENU_MODE_INDEX };99void dmenu_load_entries(struct application_list *applications, int abort_fd);10bool dmenu_execute(const struct application *app, ssize_t index,11 const struct prompt *prompt, enum dmenu_mode format);
added:fuzzel.ini+37 added
1# output=<not set>2# font=monospace3# dpi-aware=auto4# prompt=> 5# icon-theme=hicolor6# icons-enabled=yes7# fields=filename,name,generic8# password-character=*9# fuzzy=yes10# show-actions=no11# terminal=<not set>12# launch-prefix=<not set>1314# lines=1515# width=3016# horizontal-pad=4017# vertical-pad=818# inner-pad=01920# line-height=<use font metrics>21# letter-spacing=02223[colors]24# background=fdf6e3dd25# text=657b83ff26# match=cb4b16ff27# selection=eee8d5dd28# selection-text=657b83ff29# border=002b36ff3031[border]32# width=133# radius=103435[dmenu]36# mode=text # text|index37# exit-immediately-if-empty=no
modified:main.c+243 added-132 removed
23 unmodified lines
24#define LOG_MODULE "fuzzel"25#define LOG_ENABLE_DBG 026#include "log.h"27#include "application.h"28#include "config.h"29#include "char32.h"30#include "dmenu.h"31#include "fdm.h"32#include "match.h"
3 unmodified lines
36#include "wayland.h"37#include "xdg.h"3839struct context {40 const struct config *conf;41 struct wayland *wayl;42 struct render *render;43 struct matches *matches;44 struct prompt *prompt;
2 unmodified lines
47 icon_theme_list_t *themes;48 int icon_size;49 mtx_t *icon_lock;5051#if 052 /* TODO: can we use a struct config ptr instead? */53 struct {54 const char *icon_theme;55 const char *terminal;56 bool icons_enabled;57 bool actions_enabled;58 bool dmenu_mode;59 } options;5660#endif61 int event_fd;62 int dmenu_abort_fd;63};6461static struct rgba62hex_to_rgba(uint32_t color)63{64 return (struct rgba){65 .r = (double)((color >> 24) & 0xff) / 255.0,66 .g = (double)((color >> 16) & 0xff) / 255.0,67 .b = (double)((color >> 8) & 0xff) / 255.0,68 .a = (double)((color >> 0) & 0xff) / 255.0,69 };70}7165static void66read_cache(struct application_list *apps)67{68 const char *path = xdg_cache_dir();
126 unmodified lines
195{196 printf("Usage: %s [OPTION]...\n", prog_name);197 printf("\n");198 printf("Options:\n");199 printf(" --config=PATH load configuration from PATH (XDG_CONFIG_HOME/fuzzel/fuzzel.ini)\n"206 printf(" -o,--output=OUTPUT output (monitor) to display on (none)\n"200 " -o,--output=OUTPUT output (monitor) to display on (none)\n"201 " -f,--font=FONT font name and style, in FontConfig format\n"202 " (monospace)\n"203 " -D,--dpi-aware=no|yes|auto enable or disable DPI aware rendering (auto)\n"204 " -i,--icon-theme=NAME icon theme name (\"hicolor\")\n"205 " -I,--no-icons do not render any icons\n"206 " -F,--fields=FIELDS comma separated list of XDG Desktop entry\n"207 " fields to match\n"208 " -P,--prompt=PROMPT string to use as input prompt (\"> \")\n"209 " --password=[CHARACTER] render all input as CHARACTER ('*' by default)\n"210 " -T,--terminal terminal command to use when launching\n"211 " 'terminal' programs, e.g. \"xterm -e\".\n"212 " Not used in dmenu mode (not set)\n"
51 unmodified lines
264265 mtx_lock(ctx->icon_lock);266 {267 ctx->icon_size = font->height;272 if (ctx->options.icons_enabled) {268 if (ctx->conf->icons_enabled) {269 icon_lookup_application_icons(270 *ctx->themes, ctx->icon_size, ctx->apps);271 }272 }
95 unmodified lines
368populate_apps(void *_ctx)369{370 struct context *ctx = _ctx;371 struct application_list *apps = ctx->apps;376 const char *icon_theme = ctx->options.icon_theme;377 const char *terminal = ctx->options.terminal;378 bool actions_enabled = ctx->options.actions_enabled;379 bool dmenu_mode = ctx->options.dmenu_mode;380 bool icons_enabled = ctx->options.icons_enabled;372 const char *icon_theme = ctx->conf->icon_theme;373 const char *terminal = ctx->conf->terminal;374 bool actions_enabled = ctx->conf->actions_enabled;375 bool dmenu_enabled = ctx->conf->dmenu.enabled;376 bool icons_enabled = ctx->conf->icons_enabled;377382 if (dmenu_mode) {378 if (dmenu_enabled) {379 dmenu_load_entries(apps, ctx->dmenu_abort_fd);380 return send_event(ctx->event_fd, EVENT_APPS_LOADED);381 }382
88 unmodified lines
471 #define OPT_LOG_LEVEL 264472 #define OPT_LOG_COLORIZE 265473 #define OPT_LOG_NO_SYSLOG 266474 #define OPT_PASSWORD 267475 #define OPT_CONFIG 268476477 static const struct option longopts[] = {478 {"config", required_argument, 0, OPT_CONFIG},479 {"output" , required_argument, 0, 'o'},480 {"font", required_argument, 0, 'f'},481 {"dpi-aware", required_argument, 0, 'D'},482 {"icon-theme", required_argument, 0, 'i'},
37 unmodified lines
520 {"help", no_argument, 0, 'h'},521 {NULL, no_argument, 0, 0},522 };523526 enum dpi_aware dpi_aware = DPI_AWARE_AUTO;527 const char *output_name = NULL;524 const char *config_path = NULL;528 const char *font_name = "monospace";529 const char *icon_theme = "hicolor";530 const char *terminal = NULL;531 const char32_t *prompt_content = U"> ";532 char32_t *prompt_allocated = NULL;533 bool icons_enabled = true;534 bool actions_enabled = false;535 bool fuzzy = true;536 size_t fuzzy_min_length = 3;537 size_t fuzzy_max_length_discrepancy = 2;538 size_t fuzzy_max_distance = 1;539 const char *launch_prefix = NULL;540525 enum log_class log_level = LOG_CLASS_INFO;526 enum log_colorize log_colorize = LOG_COLORIZE_AUTO;527 bool log_syslog = true;528545 bool dmenu_mode = false;546 enum dmenu_mode dmenu_format = DMENU_MODE_TEXT;547 bool no_run_if_empty = false;529 struct {530 struct config conf;531549 enum match_fields match_fields =550 MATCH_FILENAME | MATCH_NAME | MATCH_GENERIC;532 bool dpi_aware_set:1;533 bool match_fields_set:1;534 bool icons_disabled_set:1;535 bool lines_set:1;536 bool chars_set:1;537 bool pad_x_set:1;538 bool pad_y_set:1;539 bool pad_inner_set:1;540 bool background_color_set:1;541 bool text_color_set:1;542 bool match_color_set:1;543 bool selection_color_set:1;544 bool selection_text_color_set:1;545 bool border_color_set:1;546 bool border_size_set:1;547 bool border_radius_set:1;548 bool actions_enabled_set:1;549 bool fuzzy_set:1;550 bool fuzzy_min_length_set:1;551 bool fuzzy_max_length_discrepancy_set:1;552 bool fuzzy_max_distance_set:1;553 bool line_height_set:1;554 bool letter_spacing_set:1;555 bool dmenu_enabled_set:1;556 bool dmenu_mode_set:1;557 bool dmenu_exit_immediately_if_empty_set:1;558 } cmdline_overrides = {{0}};559552 struct render_options render_options = {553 .lines = 15,554 .chars = 30,555 .border_size = 1u,556 .border_radius = 10u,557 .pad = {.x = 40, .y = 8, .inner = 0},558 .password = false,559 .background_color = hex_to_rgba(0xfdf6e3dd),560 .border_color = hex_to_rgba(0x002b36ff),561 .text_color = hex_to_rgba(0x657b83ff),562 .match_color = hex_to_rgba(0xcb4b16ff),563 .selection_color = hex_to_rgba(0xeee8d5dd),564 .selection_text_color = hex_to_rgba(0x657b83ff),565 .line_height = {-1, 0.0}, /* Use font metrics */566 .letter_spacing = {0},567 };568560 setlocale(LC_CTYPE, "");561562 /* Auto-enable dmenu mode if invoked through a ‘dmenu’ symlink */563 if (argv[0] != NULL) {564 char *copy = strdup(argv[0]);565 if (copy != NULL) {566 const char *name = basename(copy);576 if (name != NULL && strcmp(name, "dmenu") == 0)577 dmenu_mode = true;567 if (name != NULL && strcmp(name, "dmenu") == 0) {568 cmdline_overrides.conf.dmenu.enabled = true;569 cmdline_overrides.dmenu_enabled_set = true;570 }571572 free(copy);573 }574 }
3 unmodified lines
578 if (c == -1)579 break;580581 switch (c) {582 case OPT_CONFIG:583 config_path = optarg;584 break;585586 case 'o':590 output_name = optarg;587 cmdline_overrides.conf.output = optarg;588 break;589590 case 'f':594 font_name = optarg;591 cmdline_overrides.conf.font = optarg;592 break;593594 case 'D':595 if (strcmp(optarg, "auto") == 0)599 dpi_aware = DPI_AWARE_AUTO;596 cmdline_overrides.conf.dpi_aware = DPI_AWARE_AUTO;597 else if (strcmp(optarg, "no") == 0)601 dpi_aware = DPI_AWARE_NO;598 cmdline_overrides.conf.dpi_aware = DPI_AWARE_NO;599 else if (strcmp(optarg, "yes") == 0)603 dpi_aware = DPI_AWARE_YES;600 cmdline_overrides.conf.dpi_aware = DPI_AWARE_YES;601 else {602 fprintf(603 stderr,604 "%s: invalid value for dpi-aware: "605 "must be one of 'auto', 'no', or 'yes'\n",606 optarg);607 return EXIT_FAILURE;608 }609 cmdline_overrides.dpi_aware_set = true;610 break;611612 case 'i':615 icon_theme = optarg;613 cmdline_overrides.conf.icon_theme = optarg;614 break;615616 case 'I':619 icons_enabled = false;617 cmdline_overrides.conf.icons_enabled = false;618 cmdline_overrides.icons_disabled_set = true;619 break;620621 case 'F': {622 static const struct {
8 unmodified lines
631 {"keywords", MATCH_KEYWORDS},632 {"comment", MATCH_COMMENT},633 };634636 match_fields = 0;635 cmdline_overrides.conf.match_fields = 0;636 for (const char *f = strtok(optarg, ", ");637 f != NULL;638 f = strtok(NULL, ", "))639 {
6 unmodified lines
646 }647 }648649 if (field > 0)651 match_fields |= field;650 cmdline_overrides.conf.match_fields |= field;651 else {652 char valid_names[128] = {0};653 int idx = 0;654 for (size_t i = 0; i < sizeof(map) / sizeof(map[0]); i++) {
10 unmodified lines
665 f, valid_names);666 return EXIT_FAILURE;667 }668 }669 cmdline_overrides.match_fields_set = true;670 break;671 }672673 case OPT_PASSWORD: {
10 unmodified lines
684 }685 password_char = wide_optarg[0];686 free(wide_optarg);687 }688 render_options.password = password_char;688 cmdline_overrides.conf.password = password_char;689 break;690 }691692 case 'T':693 terminal = optarg;693 cmdline_overrides.conf.terminal = optarg;694 break;695696 case 'l':697 if (sscanf(optarg, "%u", &render_options.lines) != 1) {697 if (sscanf(optarg, "%u", &cmdline_overrides.conf.lines) != 1) {698 fprintf(stderr, "%s: invalid line count\n", optarg);699 return EXIT_FAILURE;700 }701 cmdline_overrides.lines_set = true;702 break;703704 case 'w':704 if (sscanf(optarg, "%u", &render_options.chars) != 1) {705 if (sscanf(optarg, "%u", &cmdline_overrides.conf.chars) != 1) {706 fprintf(stderr, "%s: invalid width\n", optarg);707 return EXIT_FAILURE;708 }709 cmdline_overrides.chars_set = true;710 break;711712 case 'x':711 if (sscanf(optarg, "%u", &render_options.pad.x) != 1) {713 if (sscanf(optarg, "%u", &cmdline_overrides.conf.pad.x) != 1) {714 fprintf(stderr, "%s: invalid padding\n", optarg);715 return EXIT_FAILURE;716 }717 cmdline_overrides.pad_x_set = true;718 break;719720 case 'y':718 if (sscanf(optarg, "%u", &render_options.pad.y) != 1) {721 if (sscanf(optarg, "%u", &cmdline_overrides.conf.pad.y) != 1) {722 fprintf(stderr, "%s: invalid padding\n", optarg);723 return EXIT_FAILURE;724 }725 cmdline_overrides.pad_y_set = true;726 break;727728 case 'p':725 if (sscanf(optarg, "%u", &render_options.pad.inner) != 1) {729 if (sscanf(optarg, "%u", &cmdline_overrides.conf.pad.inner) != 1) {730 fprintf(stderr, "%s: invalid padding\n", optarg);731 return EXIT_FAILURE;732 }733 cmdline_overrides.pad_inner_set = true;734 break;735736 case 'P':732 free(prompt_allocated);733 prompt_allocated = ambstoc32(optarg);737 free(cmdline_overrides.conf.prompt);738 cmdline_overrides.conf.prompt = ambstoc32(optarg);739735 if (prompt_allocated == NULL) {740 if (cmdline_overrides.conf.prompt == NULL) {741 fprintf(stderr, "%s: invalid prompt\n", optarg);742 return EXIT_FAILURE;743 }744740 prompt_content = prompt_allocated;745 break;746747 case 'b': {748 uint32_t background;749 if (sscanf(optarg, "%08x", &background) != 1) {750 fprintf(stderr, "%s: invalid color\n", optarg);751 return EXIT_FAILURE;752 }749 render_options.background_color = hex_to_rgba(background);753 cmdline_overrides.conf.colors.background =754 conf_hex_to_rgba(background);755 cmdline_overrides.background_color_set = true;756 break;757 }758759 case 't': {
1 unmodified line
761 if (sscanf(optarg, "%08x", &text_color) != 1) {762 fprintf(stderr, "%s: invalid color\n", optarg);763 return EXIT_FAILURE;764 }759 render_options.text_color = hex_to_rgba(text_color);765 cmdline_overrides.conf.colors.text = conf_hex_to_rgba(text_color);766 cmdline_overrides.text_color_set = true;767 break;768 }769770 case 'm': {
1 unmodified line
772 if (sscanf(optarg, "%x", &match_color) != 1) {773 fprintf(stderr, "%s: invalid color\n", optarg);774 return EXIT_FAILURE;775 }769 render_options.match_color = hex_to_rgba(match_color);776 cmdline_overrides.conf.colors.match =777 conf_hex_to_rgba(match_color);778 cmdline_overrides.match_color_set = true;779 break;780 }781782 case 's': {
1 unmodified line
784 if (sscanf(optarg, "%x", &selection_color) != 1) {785 fprintf(stderr, "%s: invalid color\n", optarg);786 return EXIT_FAILURE;787 }779 render_options.selection_color = hex_to_rgba(selection_color);788 cmdline_overrides.conf.colors.selection =789 conf_hex_to_rgba(selection_color);790 cmdline_overrides.selection_color_set = true;791 break;792 }793794 case 'S': {
1 unmodified line
796 if (sscanf(optarg, "%x", &selection_text_color) != 1) {797 fprintf(stderr, "%s: invalid color\n", optarg);798 return EXIT_FAILURE;799 }789 render_options.selection_text_color = hex_to_rgba(selection_text_color);800 cmdline_overrides.conf.colors.selection_text =801 conf_hex_to_rgba(selection_text_color);802 cmdline_overrides.selection_text_color_set = true;803 break;804 }805806 case 'B':794 if (sscanf(optarg, "%u", &render_options.border_size) != 1) {807 if (sscanf(optarg, "%u", &cmdline_overrides.conf.border.size) != 1) {808 fprintf(809 stderr,810 "%s: invalid border width (must be an integer)\n", optarg);811 return EXIT_FAILURE;812 }813 cmdline_overrides.border_size_set = true;814 break;815816 case 'r':803 if (sscanf(optarg, "%u", &render_options.border_radius) != 1) {817 if (sscanf(optarg, "%u", &cmdline_overrides.conf.border.radius) != 1) {818 fprintf(stderr, "%s: invalid border radius (must be an integer)\n",819 optarg);820 return EXIT_FAILURE;821 }822 cmdline_overrides.border_radius_set = true;823 break;824825 case 'C': {826 uint32_t border_color;827 if (sscanf(optarg, "%x", &border_color) != 1) {828 fprintf(stderr, "%s: invalid color\n", optarg);829 return EXIT_FAILURE;830 }816 render_options.border_color = hex_to_rgba(border_color);831 cmdline_overrides.conf.colors.border =832 conf_hex_to_rgba(border_color);833 cmdline_overrides.border_color_set = true;834 break;835 }836837 case OPT_SHOW_ACTIONS:821 actions_enabled = true;838 cmdline_overrides.conf.actions_enabled = true;839 break;840841 case OPT_NO_FUZZY:825 fuzzy = false;842 cmdline_overrides.conf.fuzzy.enabled = false;843 cmdline_overrides.fuzzy_set = true;844 break;845846 case OPT_FUZZY_MIN_LENGTH:829 if (sscanf(optarg, "%zu", &fuzzy_min_length) != 1) {847 if (sscanf(optarg, "%zu", &cmdline_overrides.conf.fuzzy.min_length) != 1) {848 fprintf(849 stderr,850 "%s: invalid fuzzy min length (must be an integer)\n",851 optarg);852 return EXIT_FAILURE;853 }854 cmdline_overrides.fuzzy_min_length_set = true;855 break;856857 case OPT_FUZZY_MAX_LENGTH_DISCREPANCY:839 if (sscanf(optarg, "%zu", &fuzzy_max_length_discrepancy) != 1) {858 if (sscanf(optarg, "%zu", &cmdline_overrides.conf.fuzzy.max_length_discrepancy) != 1) {859 fprintf(860 stderr,861 "%s: invalid fuzzy max length discrepancy "862 "(must be an integer)\n", optarg);863 return EXIT_FAILURE;864 }865 cmdline_overrides.fuzzy_max_length_discrepancy_set = true;866 break;867868 case OPT_FUZZY_MAX_DISTANCE:849 if (sscanf(optarg, "%zu", &fuzzy_max_distance) != 1) {869 if (sscanf(optarg, "%zu", &cmdline_overrides.conf.fuzzy.max_distance) != 1) {870 fprintf(871 stderr,872 "%s: invalid fuzzy max distance (must be an integer)\n",873 optarg);874 return EXIT_FAILURE;875 }876 cmdline_overrides.fuzzy_max_distance_set = true;877 break;878879 case 'H': { /* line-height */859 if (!pt_or_px_from_string(optarg, &render_options.line_height))880 if (!pt_or_px_from_string(optarg, &cmdline_overrides.conf.line_height))881 return EXIT_FAILURE;882 cmdline_overrides.line_height_set = true;883 break;884 }885886 case OPT_LETTER_SPACING: {865 if (!pt_or_px_from_string(optarg, &render_options.letter_spacing))887 if (!pt_or_px_from_string(optarg, &cmdline_overrides.conf.letter_spacing))888 return EXIT_FAILURE;889 cmdline_overrides.letter_spacing_set = true;890 break;891 }892893 case OPT_LAUNCH_PREFIX: {871 launch_prefix = optarg;894 cmdline_overrides.conf.launch_prefix = optarg;895 break;896 }897898 case 'd':876 dmenu_mode = true;899 cmdline_overrides.conf.dmenu.enabled = true;900 cmdline_overrides.dmenu_enabled_set = true;901 break;902903 case 'R':880 no_run_if_empty = true;904 cmdline_overrides.conf.dmenu.exit_immediately_if_empty = true;905 cmdline_overrides.dmenu_exit_immediately_if_empty_set = true;906 break;907908 case OPT_DMENU_INDEX:884 dmenu_format = DMENU_MODE_INDEX;909 cmdline_overrides.conf.dmenu.mode = DMENU_MODE_INDEX;910 cmdline_overrides.dmenu_mode_set = true;911 break;912913 case OPT_LOG_LEVEL: {914 int lvl = log_level_from_string(optarg);
42 unmodified lines
957 return EXIT_FAILURE;958 }959 }960961 log_init(log_colorize, log_syslog, LOG_FACILITY_USER, log_level);962963 int ret = EXIT_FAILURE;964965 struct config conf = {0};966 bool conf_successful = config_load(&conf, config_path, NULL, true);967 if (!conf_successful) {968 config_free(&conf);969 return ret;970 }971972 /* Apply command line overrides */973 if (cmdline_overrides.conf.output != NULL) {974 free(conf.output);975 conf.output = strdup(cmdline_overrides.conf.output);976 }977 if (cmdline_overrides.conf.prompt != NULL) {978 free(conf.prompt);979 conf.prompt = cmdline_overrides.conf.prompt;980 }981 if (cmdline_overrides.conf.password != U'\0')982 conf.password = cmdline_overrides.conf.password;983 if (cmdline_overrides.conf.terminal != NULL) {984 free(conf.terminal);985 conf.terminal = strdup(cmdline_overrides.conf.terminal);986 }987 if (cmdline_overrides.conf.launch_prefix != NULL) {988 free(conf.launch_prefix);989 conf.launch_prefix = strdup(cmdline_overrides.conf.launch_prefix);990 }991 if (cmdline_overrides.conf.font != NULL) {992 free(conf.font);993 conf.font = strdup(cmdline_overrides.conf.font);994 }995 if (cmdline_overrides.conf.icon_theme != NULL) {996 free(conf.icon_theme);997 conf.icon_theme = strdup(cmdline_overrides.conf.icon_theme);998 }999 if (cmdline_overrides.dpi_aware_set)1000 conf.dpi_aware = cmdline_overrides.conf.dpi_aware;1001 if (cmdline_overrides.match_fields_set)1002 conf.match_fields = cmdline_overrides.conf.match_fields;1003 if (cmdline_overrides.icons_disabled_set)1004 conf.icons_enabled = cmdline_overrides.conf.icons_enabled;1005 if (cmdline_overrides.lines_set)1006 conf.lines = cmdline_overrides.conf.lines;1007 if (cmdline_overrides.chars_set)1008 conf.chars = cmdline_overrides.conf.chars;1009 if (cmdline_overrides.pad_x_set)1010 conf.pad.x = cmdline_overrides.conf.pad.x;1011 if (cmdline_overrides.pad_y_set)1012 conf.pad.y = cmdline_overrides.conf.pad.y;1013 if (cmdline_overrides.pad_inner_set)1014 conf.pad.inner = cmdline_overrides.conf.pad.inner;1015 if (cmdline_overrides.background_color_set)1016 conf.colors.background = cmdline_overrides.conf.colors.background;1017 if (cmdline_overrides.text_color_set)1018 conf.colors.text = cmdline_overrides.conf.colors.text;1019 if (cmdline_overrides.match_color_set)1020 conf.colors.match = cmdline_overrides.conf.colors.match;1021 if (cmdline_overrides.selection_color_set)1022 conf.colors.selection = cmdline_overrides.conf.colors.selection;1023 if (cmdline_overrides.selection_text_color_set)1024 conf.colors.selection_text = cmdline_overrides.conf.colors.selection_text;1025 if (cmdline_overrides.border_color_set)1026 conf.colors.border = cmdline_overrides.conf.colors.border;1027 if (cmdline_overrides.border_size_set)1028 conf.border.size = cmdline_overrides.conf.border.size;1029 if (cmdline_overrides.border_radius_set)1030 conf.border.radius = cmdline_overrides.conf.border.radius;1031 if (cmdline_overrides.actions_enabled_set)1032 conf.actions_enabled = cmdline_overrides.conf.actions_enabled;1033 if (cmdline_overrides.fuzzy_set)1034 conf.fuzzy.enabled = cmdline_overrides.conf.fuzzy.enabled;1035 if (cmdline_overrides.fuzzy_min_length_set)1036 conf.fuzzy.min_length = cmdline_overrides.conf.fuzzy.min_length;1037 if (cmdline_overrides.fuzzy_max_length_discrepancy_set)1038 conf.fuzzy.max_length_discrepancy = cmdline_overrides.conf.fuzzy.max_length_discrepancy;1039 if (cmdline_overrides.fuzzy_max_distance_set)1040 conf.fuzzy.max_distance = cmdline_overrides.conf.fuzzy.max_distance;1041 if (cmdline_overrides.line_height_set)1042 conf.line_height = cmdline_overrides.conf.line_height;1043 if (cmdline_overrides.letter_spacing_set)1044 conf.letter_spacing = cmdline_overrides.conf.letter_spacing;1045 if (cmdline_overrides.dmenu_enabled_set)1046 conf.dmenu.enabled = cmdline_overrides.conf.dmenu.enabled;1047 if (cmdline_overrides.dmenu_mode_set)1048 conf.dmenu.mode = cmdline_overrides.conf.dmenu.mode;1049 if (cmdline_overrides.dmenu_exit_immediately_if_empty_set)1050 conf.dmenu.exit_immediately_if_empty = cmdline_overrides.conf.dmenu.exit_immediately_if_empty;10511052 _Static_assert((int)LOG_CLASS_ERROR == (int)FCFT_LOG_CLASS_ERROR,1053 "fcft log level enum offset");1054 _Static_assert((int)LOG_COLORIZE_ALWAYS == (int)FCFT_LOG_COLORIZE_ALWAYS,1055 "fcft colorize enum mismatch");941942 log_init(log_colorize, log_syslog, LOG_FACILITY_USER, log_level);1056 fcft_init((enum fcft_log_colorize)log_colorize, log_syslog, (enum fcft_log_class)log_level);10571058#if !defined(FUZZEL_ENABLE_SVG_LIBRSVG)1059 /* Skip fcft cleanup if we’re using the librsvg backend
36 unmodified lines
10961097 if ((fdm = fdm_init()) == NULL)1098 goto out;1099987 if ((render = render_init(&render_options, &icon_lock)) == NULL)1100 if ((render = render_init(&conf, &icon_lock)) == NULL)1101 goto out;1102990 if ((prompt = prompt_init(prompt_content)) == NULL)1103 if ((prompt = prompt_init(conf.prompt)) == NULL)1104 goto out;11051106 if ((matches = matches_init(994 match_fields, fuzzy, fuzzy_min_length,995 fuzzy_max_length_discrepancy, fuzzy_max_distance)) == NULL)1107 conf.match_fields, conf.fuzzy.enabled, conf.fuzzy.min_length,1108 conf.fuzzy.max_length_discrepancy,1109 conf.fuzzy.max_distance)) == NULL)1110 goto out;997 matches_max_matches_per_page_set(matches, render_options.lines);1111 matches_max_matches_per_page_set(matches, conf.lines);11121113 if ((apps = applications_init()) == NULL)1114 goto out;11151116 if (conf.dmenu.enabled) {1002 if (dmenu_mode && no_run_if_empty) {1003 /*1004 * If no_run_if_empty is set, we *must* load the entries1005 * *before displaying the window.1006 */1007 dmenu_load_entries(apps, -1);1008 if (apps->count == 0)1009 goto out;1117 if (conf.dmenu.exit_immediately_if_empty) {1118 /*1119 * If no_run_if_empty is set, we *must* load the entries1120 * *before displaying the window.1121 */1122 dmenu_load_entries(apps, -1);1123 if (apps->count == 0)1124 goto out;11251011 matches_set_applications(matches, apps);1012 matches_update(matches, prompt);1013 } else if (dmenu_mode) {1014 dmenu_abort_fd = eventfd(0, EFD_CLOEXEC | EFD_NONBLOCK);1015 if (dmenu_abort_fd < 0) {1016 LOG_ERRNO("failed to create event FD for dmenu mode");1017 goto out;1126 matches_set_applications(matches, apps);1127 matches_update(matches, prompt);1128 }11291130 else {1131 dmenu_abort_fd = eventfd(0, EFD_CLOEXEC | EFD_NONBLOCK);1132 if (dmenu_abort_fd < 0) {1133 LOG_ERRNO("failed to create event FD for dmenu mode");1134 goto out;1135 }1136 }1137 }11381139 struct context ctx = {1140 .conf = &conf,1141 .render = render,1142 .matches = matches,1143 .prompt = prompt,1144 .apps = apps,1145 .themes = &themes,1146 .icon_lock = &icon_lock,1028 .options = {1029 .icon_theme = icon_theme,1030 .terminal = terminal,1031 .icons_enabled = icons_enabled,1032 .actions_enabled = actions_enabled,1033 .dmenu_mode = dmenu_mode,1034 },1147 .event_fd = -1,1148 .dmenu_abort_fd = dmenu_abort_fd,1149 };11501151 if ((wayl = wayl_init(1040 fdm, render, prompt, matches, &render_options,1041 dmenu_mode ? dmenu_format : DMENU_MODE_NONE,1042 launch_prefix, output_name, font_name, dpi_aware,1152 &conf, fdm, render, prompt, matches,1153 &font_reloaded, &ctx)) == NULL)1154 goto out;11551156 ctx.wayl = wayl;11571158 /* Create thread that will populate the application list */1049 if (!dmenu_mode || !no_run_if_empty) {1159 if (!conf.dmenu.enabled || !conf.dmenu.exit_immediately_if_empty) {1160 if (pipe2(event_pipe, O_CLOEXEC | O_NONBLOCK) < 0) {1161 LOG_ERRNO("failed to create event pipe");1162 goto out;1163 }
63 unmodified lines
1227 prompt_destroy(prompt);1228 fdm_destroy(fdm);1229 applications_destroy(apps);1230 icon_themes_destroy(themes);1121 free(prompt_allocated);1231 //free(prompt_allocated);1232 config_free(&conf);12331234#if defined(FUZZEL_ENABLE_CAIRO) && defined(_DEBUG)1235 cairo_debug_reset_static_data();1236#endif
11 unmodified lines
modified:match.h+1 added-10 removed
2 unmodified lines
3#include <stdbool.h>4#include <unistd.h>56#include "application.h"7#include "config.h"8#include "prompt.h"910enum matched_type {11 MATCHED_NONE,
7 unmodified lines
19 ssize_t start_title;20 size_t index;21};2222enum match_fields {23 MATCH_FILENAME = 0x01,24 MATCH_NAME = 0x02,25 MATCH_GENERIC = 0x04,26 MATCH_EXEC = 0x08,27 MATCH_CATEGORIES = 0x10,28 MATCH_KEYWORDS = 0x20,29 MATCH_COMMENT = 0x40,30};3123struct matches;24struct matches *matches_init(enum match_fields fields, bool fuzzy,25 size_t fuzzy_min_length,26 size_t fuzzy_max_length_discrepancy,
25 unmodified lines
modified:meson.build+4 added
130 unmodified lines
131132executable(133 'fuzzel',134 'application.c', 'application.h',135 'config.c', 'config.h',136 'char32.c', 'char32.h',137 'dmenu.c', 'dmenu.h',138 'fdm.c', 'fdm.h',139 'icon.c', 'icon.h',
24 unmodified lines
164 fcft],165 install: true)166167install_data(168 'fuzzel.ini',169 install_dir: join_paths(get_option('sysconfdir'), 'xdg', 'fuzzel'))170install_data(171 'LICENSE', 'README.md', 'CHANGELOG.md',172 install_dir: join_paths(get_option('datadir'), 'doc', 'fuzzel'))173174subdir('completions')
10 unmodified lines
modified:render.c+49 added-43 removed
20 unmodified lines
21#define min(x, y) ((x) < (y) ? (x) : (y))22#define max(x, y) ((x) > (y) ? (x) : (y))2324struct render {25 struct render_options options;25 const struct config *conf;26 struct fcft_font *font;27 enum fcft_subpixel subpixel;2829 int scale;30 float dpi;31 bool size_font_by_dpi;3233 pixman_color_t pix_background_color;34 pixman_color_t pix_border_color;35 pixman_color_t pix_text_color;36 pixman_color_t pix_match_color;37 pixman_color_t pix_selection_color;38 pixman_color_t pix_selection_text_color;3940 unsigned x_margin;41 unsigned y_margin;42 unsigned inner_pad;43 unsigned border_size;
34 unmodified lines
78render_background(const struct render *render, struct buffer *buf)79{80 bool use_pixman =81#if defined(FUZZEL_ENABLE_CAIRO)75 render->options.border_radius == 082 render->conf->border.radius == 083#else84 true85#endif86 ;8788 if (use_pixman) {82 unsigned bw = render->options.border_size;89 unsigned bw = render->conf->border.size;9084 pixman_color_t bg = rgba2pixman(render->options.background_color);91 pixman_color_t bg = rgba2pixman(render->conf->colors.background);92 pixman_image_fill_rectangles(93 PIXMAN_OP_SRC, buf->pix, &bg,94 1, &(pixman_rectangle16_t){95 bw, bw, buf->width - 2 * bw, buf->height - 2 * bw});9690 pixman_color_t border_color = rgba2pixman(render->options.border_color);97 pixman_color_t border_color = rgba2pixman(render->conf->colors.border);98 pixman_image_fill_rectangles(99 PIXMAN_OP_SRC, buf->pix, &border_color,100 4, (pixman_rectangle16_t[]){101 {0, 0, buf->width, bw}, /* top */
21 unmodified lines
123 const double w = max(buf->width - 2 * b, 0.);124 const double h = max(buf->height - 2 * b, 0.);125126 const double from_degree = M_PI / 180;120 const double radius = render->options.border_radius;127 const double radius = render->conf->border.radius;128129 /* Path describing an arc:ed rectangle */130 cairo_new_path(buf->cairo);131 cairo_arc(buf->cairo, b + w - radius, b + h - radius, radius,
6 unmodified lines
138 270.0 * from_degree, 360.0 * from_degree);139 cairo_close_path(buf->cairo);140141 /* Border */135 const struct rgba *bc = &render->options.border_color;142 const struct rgba *bc = &render->conf->colors.border;143 cairo_set_operator(buf->cairo, CAIRO_OPERATOR_SOURCE);144 cairo_set_line_width(buf->cairo, 2 * b);145 cairo_set_source_rgba(buf->cairo, bc->r, bc->g, bc->b, bc->a);146 cairo_stroke_preserve(buf->cairo);147148 /* Background */142 const struct rgba *bg = &render->options.background_color;149 const struct rgba *bg = &render->conf->colors.background;150 cairo_set_source_rgba(buf->cairo, bg->r, bg->g, bg->b, bg->a);151 cairo_fill(buf->cairo);152#else153 assert(false);
27 unmodified lines
181{182 struct fcft_font *font = render->font;183 assert(font != NULL);184178 const struct render_options *opts = &render->options;185 const struct config *conf = render->conf;186187 const char32_t *pprompt = prompt_prompt(prompt);188 const size_t prompt_len = c32len(pprompt);189190 const char32_t *ptext = prompt_text(prompt);191 const size_t text_len = c32len(ptext);192193 const enum fcft_subpixel subpixel =187 (render->options.background_color.a == 1. &&188 render->options.selection_color.a == 1.)194 (render->conf->colors.background.a == 1. &&195 render->conf->colors.selection.a == 1.)196 ? render->subpixel : FCFT_SUBPIXEL_NONE;197198 int x = render->border_size + render->x_margin;199 int y = render->border_size + render->y_margin + font->ascent;
2 unmodified lines
202203 for (size_t i = 0; i < prompt_len + text_len; i++) {204 char32_t wc = i < prompt_len205 ? pprompt[i]199 : (opts->password != 0200 ? opts->password206 : (conf->password != 0207 ? conf->password208 : ptext[i - prompt_len]);209210 const struct fcft_glyph *glyph = fcft_rasterize_char_utf32(211 font, wc, subpixel);
6 unmodified lines
218 long x_kern;219 fcft_kerning(font, prev, wc, &x_kern, NULL);220221 x += x_kern;215 render_glyph(buf->pix, glyph, x, y, &render->options.pix_text_color);222 render_glyph(buf->pix, glyph, x, y, &render->pix_text_color);223 x += glyph->advance.x;224 if (i >= prompt_len)218 x += pt_or_px_as_pixels(render, &render->options.letter_spacing);225 x += pt_or_px_as_pixels(render, &render->conf->letter_spacing);226227 /* Cursor */228 if (prompt_cursor(prompt) + prompt_len - 1 == i) {229 pixman_image_fill_rectangles(223 PIXMAN_OP_SRC, buf->pix, &render->options.pix_text_color,230 PIXMAN_OP_SRC, buf->pix, &render->pix_text_color,231 1, &(pixman_rectangle16_t){232 x, y - font->ascent,233 font->underline.thickness, font->ascent + font->descent});234 }
314 unmodified lines
549 const int border_size = render->border_size;550 const size_t match_count = matches_get_count(matches);551 const size_t selected = matches_get_match_index(matches);552 const enum fcft_subpixel subpixel =546 (render->options.background_color.a == 1. &&547 render->options.selection_color.a == 1.)553 (render->conf->colors.background.a == 1. &&554 render->conf->colors.selection.a == 1.)555 ? render->subpixel : FCFT_SUBPIXEL_NONE;556 const struct fcft_glyph *ellipses =557 fcft_rasterize_char_utf32(font, U'…', subpixel);558
36 unmodified lines
595 {596 render_svg(&match->application->icon, img_x, img_y, size, buf);597 }598592 pixman_color_t sc = rgba2pixman(render->options.selection_color);599 pixman_color_t sc = rgba2pixman(render->conf->colors.selection);600 pixman_image_fill_rectangles(601 PIXMAN_OP_SRC, buf->pix, &sc, 1,602 &(pixman_rectangle16_t){603 x_margin - sel_margin,
6 unmodified lines
610 double cur_x = border_size + x_margin;611 double max_x = buf->width - border_size - x_margin;612613#if 0 /* Render the icon+text bounding box */607 pixman_color_t sc = rgba2pixman(render->options.match_color);614 pixman_color_t sc = rgba2pixman(render->conf->match_color);615 pixman_image_fill_rectangles(616 PIXMAN_OP_SRC, buf->pix, &sc, 1,617 &(pixman_rectangle16_t){618 cur_x, first_row + i * row_height,
25 unmodified lines
644 font, U' ', subpixel);645646 cur_x += row_height +647 (space != NULL ? space->advance.x : font->max_advance.x) +641 pt_or_px_as_pixels(render, &render->options.letter_spacing);648 pt_or_px_as_pixels(render, &render->conf->letter_spacing);649650 /* Application title */651 render_match_text(652 buf, &cur_x, y, max_x - (ellipses != NULL ? ellipses->width : 0),653 match->application->title, match->start_title, c32len(prompt_text(prompt)),654 font, subpixel,648 pt_or_px_as_pixels(render, &render->options.letter_spacing),655 pt_or_px_as_pixels(render, &render->conf->letter_spacing),656 (i == selected650 ? render->options.pix_selection_text_color651 : render->options.pix_text_color),652 render->options.pix_match_color, &match->application->shaped);657 ? render->pix_selection_text_color658 : render->pix_text_color),659 render->pix_match_color, &match->application->shaped);660661 y += row_height;662 }663
1 unmodified line
665 mtx_unlock(render->icon_lock);666}667668struct render *662render_init(const struct render_options *options, mtx_t *icon_lock)669render_init(const struct config *conf, mtx_t *icon_lock)670{671 struct render *render = calloc(1, sizeof(*render));672 *render = (struct render){666 .options = *options,673 .conf = conf,674 .icon_lock = icon_lock,675 };676670 /* TODO: the one providing the options should calculate these */671 render->options.pix_background_color = rgba2pixman(render->options.background_color);672 render->options.pix_border_color = rgba2pixman(render->options.border_color);673 render->options.pix_text_color = rgba2pixman(render->options.text_color);674 render->options.pix_match_color = rgba2pixman(render->options.match_color);675 render->options.pix_selection_color = rgba2pixman(render->options.selection_color);676 render->options.pix_selection_text_color = rgba2pixman(render->options.selection_text_color);677 render->pix_background_color = rgba2pixman(render->conf->colors.background);678 render->pix_border_color = rgba2pixman(render->conf->colors.border);679 render->pix_text_color = rgba2pixman(render->conf->colors.text);680 render->pix_match_color = rgba2pixman(render->conf->colors.match);681 render->pix_selection_color = rgba2pixman(render->conf->colors.selection);682 render->pix_selection_text_color = rgba2pixman(render->conf->colors.selection_text);683 return render;684}685686void
21 unmodified lines
708709 const struct fcft_glyph *W = fcft_rasterize_char_utf32(710 font, U'W', render->subpixel);711706 const unsigned x_margin = render->options.pad.x * scale;707 const unsigned y_margin = render->options.pad.y * scale;708 const unsigned inner_pad = render->options.pad.inner * scale;712 const unsigned x_margin = render->conf->pad.x * scale;713 const unsigned y_margin = render->conf->pad.y * scale;714 const unsigned inner_pad = render->conf->pad.inner * scale;715710 const unsigned border_size = render->options.border_size * scale;716 const unsigned border_size = render->conf->border.size * scale;717712 const unsigned row_height = render->options.line_height.px >= 0713 ? pt_or_px_as_pixels(render, &render->options.line_height)718 const unsigned row_height = render->conf->line_height.px >= 0719 ? pt_or_px_as_pixels(render, &render->conf->line_height)720 : font->height;721722 const unsigned icon_height = max(0, row_height - font->descent);723
1 unmodified line
725 border_size + /* Top border */726 y_margin +727 row_height + /* The prompt */728 inner_pad + /* Padding between prompt and matches */723 render->options.lines * row_height + /* Matches */729 render->conf->lines * row_height + /* Matches */730 y_margin +731 border_size; /* Bottom border */732733 const unsigned width =734 border_size +735 x_margin +736 (max((W->advance.x + pt_or_px_as_pixels(731 render, &render->options.letter_spacing)),737 render, &render->conf->letter_spacing)),738 0)733 * render->options.chars) +739 * render->conf->chars) +740 x_margin +741 border_size;742743 LOG_DBG("x-margin: %d, y-margin: %d, border: %d, row-height: %d, "
28 unmodified lines
modified:render.h+3 added-37 removed
3 unmodified lines
4#include <pixman.h>56#include <fcft/fcft.h>78#include "shm.h"8#include "config.h"9#include "match.h"10#include "shm.h"11#include "tllist.h"1212struct rgba {double r; double g; double b; double a;};13struct pt_or_px {int px; float pt;};1415struct render_options {16 unsigned lines;17 unsigned chars;18 unsigned border_size;19 unsigned border_radius;20 struct {21 unsigned x;22 unsigned y;23 unsigned inner;24 } pad;25 char32_t password;2627 struct rgba background_color;28 struct rgba border_color;29 struct rgba text_color;30 struct rgba match_color;31 struct rgba selection_color;32 struct rgba selection_text_color;3334 struct pt_or_px line_height;35 struct pt_or_px letter_spacing;3637 /* Filled in by render, for now */38 pixman_color_t pix_background_color;39 pixman_color_t pix_border_color;40 pixman_color_t pix_text_color;41 pixman_color_t pix_match_color;42 pixman_color_t pix_selection_color;43 pixman_color_t pix_selection_text_color;44};4513struct render;47struct render *render_init(48 const struct render_options *options, mtx_t *icon_lock);14struct render *render_init(const struct config *conf, mtx_t *icon_lock);15void render_destroy(struct render *render);1617void render_set_subpixel(struct render *render, enum fcft_subpixel subpixel);18bool render_set_font(struct render *render, struct fcft_font *font,
12 unmodified lines
modified:wayland.c+14 added-27 removed
142 unmodified lines
143 } pointer;144};145146struct wayland {147 const struct config *conf;148 struct fdm *fdm;149 struct render *render;150 struct prompt *prompt;151 struct matches *matches;152152 const struct render_options *render_options;153153 struct font_spec *fonts;154 size_t font_count;155 struct {156 font_reloaded_t cb;
5 unmodified lines
162 int height;163 int scale;164 float dpi;165 enum fcft_subpixel subpixel;167 enum dpi_aware dpi_aware;166 bool font_is_sized_by_dpi;167168 enum { KEEP_RUNNING, EXIT_UPDATE_CACHE, EXIT} status;169 int exit_code;172 enum dmenu_mode dmenu_mode;173 const char *launch_prefix;170171 struct wl_callback *frame_cb;172 struct buffer *pending;173
5 unmodified lines
179 struct zwlr_layer_surface_v1 *layer_surface;180 struct wl_shm *shm;181 struct zxdg_output_manager_v1 *xdg_output_manager;182187 char *output_name;183 tll(struct monitor) monitors;184 const struct monitor *monitor;185186 tll(struct seat) seats;
251 unmodified lines
438 const struct match *match = matches_get_match(wayl->matches);439 struct application *app = match != NULL ? match->application : NULL;440 ssize_t index = match != NULL ? match->index : -1;441447 if (wayl->dmenu_mode != DMENU_MODE_NONE) {448 dmenu_execute(app, index, wayl->prompt, wayl->dmenu_mode);442 if (wayl->conf->dmenu.enabled) {443 dmenu_execute(app, index, wayl->prompt, wayl->conf->dmenu.mode);444 wayl->exit_code = EXIT_SUCCESS;445 } else {451 bool success = application_execute(app, wayl->prompt, wayl->launch_prefix);446 bool success = application_execute(447 app, wayl->prompt, wayl->conf->launch_prefix);448 wayl->exit_code = success ? EXIT_SUCCESS : EXIT_FAILURE;449450 if (success && match != NULL) {451 wayl->status = EXIT_UPDATE_CACHE;
419 unmodified lines
871872static bool873size_font_using_dpi(const struct wayland *wayl)874{879 switch (wayl->dpi_aware) {875 switch (wayl->conf->dpi_aware) {876 case DPI_AWARE_NO: return false;877 case DPI_AWARE_YES: return true;878879 case DPI_AWARE_AUTO:
263 unmodified lines
11431144 free(mon->name);1145 mon->name = name != NULL ? strdup(name) : NULL;11461151 if (wayl->output_name != NULL &&1147 if (wayl->conf->output != NULL &&1148 mon->name != NULL &&1153 strcmp(wayl->output_name, mon->name) == 0)1149 strcmp(wayl->conf->output, mon->name) == 0)1150 {1151 wayl->monitor = mon;1152 }1153}
485 unmodified lines
1639 }1640}16411642struct wayland *1647wayl_init(struct fdm *fdm,1648 struct render *render, struct prompt *prompt, struct matches *matches,1649 const struct render_options *render_options, enum dmenu_mode dmenu_mode,1650 const char *launch_prefix, const char *output_name,1651 const char *font_spec, enum dpi_aware dpi_aware,1652 font_reloaded_t font_reloaded_cb, void *data)1643wayl_init(const struct config *conf, struct fdm *fdm,1644 struct render *render, struct prompt *prompt,1645 struct matches *matches, font_reloaded_t font_reloaded_cb, void *data)1646{1647 struct wayland *wayl = malloc(sizeof(*wayl));1648 *wayl = (struct wayland){1649 .conf = conf,1650 .fdm = fdm,1651 .render = render,1652 .prompt = prompt,1653 .matches = matches,1654 .status = KEEP_RUNNING,1661 .exit_code = (dmenu_mode == DMENU_MODE_NONE1662 ? EXIT_SUCCESS : EXIT_FAILURE),1663 .dmenu_mode = dmenu_mode,1664 .launch_prefix = launch_prefix,1665 .output_name = output_name != NULL ? strdup(output_name) : NULL,1666 .render_options = render_options,1655 .exit_code = !conf->dmenu.enabled ? EXIT_SUCCESS : EXIT_FAILURE,1656 .font_reloaded = {1657 .cb = font_reloaded_cb,1658 .data = data,1659 },1671 .dpi_aware = dpi_aware,1660 };16611674 parse_font_spec(font_spec, &wayl->font_count, &wayl->fonts);1662 parse_font_spec(conf->font, &wayl->font_count, &wayl->fonts);16631664 wayl->display = wl_display_connect(NULL);1665 if (wayl->display == NULL) {1666 LOG_ERR("failed to connect to wayland; no compositor running?");
162 unmodified lines
1829 for (size_t i = 0; i < wayl->font_count; i++)1830 free(wayl->fonts[i].pattern);1831 free(wayl->fonts);18321845 free(wayl->output_name);1833 free(wayl);1834}18351836void
16 unmodified lines
modified:wayland.h+7 added-7 removed
1#pragma once23#include <fcft/fcft.h>45#include "config.h"6#include "dmenu.h"7#include "fdm.h"8#include "match.h"9#include "prompt.h"
3 unmodified lines
1314typedef void (*font_reloaded_t)(15 struct wayland *wayl, struct fcft_font *font, void *data);1616enum dpi_aware {DPI_AWARE_AUTO, DPI_AWARE_YES, DPI_AWARE_NO};1717struct wayland *wayl_init(19 struct fdm *fdm,20 struct render *render, struct prompt *prompt, struct matches *matches,21 const struct render_options *render_options, enum dmenu_mode dmenu_mode,22 const char *launch_prefix, const char *output_name, const char *font_spec,23 enum dpi_aware dpi_aware, font_reloaded_t font_reloaded_cb, void *data);18 const struct config *conf, struct fdm *fdm, struct render *render,19 struct prompt *prompt, struct matches *matches,20 //enum dmenu_mode dmenu_mode, const char *launch_prefix,21 //const char *output_name, const char *font_spec,22 //enum dpi_aware dpi_aware,23 font_reloaded_t font_reloaded_cb, void *data);2425void wayl_destroy(struct wayland *wayl);2627void wayl_refresh(struct wayland *wayl);
6 unmodified lines