1wofi(3) Library Functions Manual wofi(3)
2
3
4
6 wofi - Mode functions and documentation
7
8
10 Wofi provides a C API which can be used for developing 3rd party modes.
11 These modes should be compiled to a shared object which should be
12 placed in $XDG_CONFIG_HOME/wofi/plugins. If $XDG_CONFIG_HOME is not
13 defined then it will default to ~/.config.
14
15 It is very important to note that this API is not stable. It's mostly
16 stable however if something comes up that requires a substantial change
17 things will be changed. This shouldn't happen too much but has happened
18 in the past and might in the future.
19
20
22 There are 2 header files required in order to use the wofi API,
23 wofi_api.h and map.h. utils.h might be useful to include if you want a
24 few helper functions but it is not required. utils.h will not be docu‐
25 mented here as it's outside the scope of the mode API.
26
27
29 The following list of functions are the functions which can be defined
30 inside of your mode which will be called to do setup, and acquire vari‐
31 ous pieces of information from the mode.
32
33
34 void init(struct mode* mode, struct map* config)
35 Defining this function is required. This function is called to
36 setup your plugin and provide it with several pointers which are
37 described below.
38
39 struct mode* mode - used to identify your mode, it is passed to
40 a large number of the API functions to identify your mode.
41
42 struct map* config - all of the config options that the user
43 defined for your mode. Information on how to access this can be
44 found in wofi-map(3).
45
46
47 void load(struct mode* mode)
48 Defining this function is optional. This function is called
49 before ALL others and provides your mode pointer as early as
50 possible.
51
52 struct mode* mode - used to identify your mode, it is passed to
53 a large number of the API functions to identify your mode.
54
55
56 const char** get_arg_names(void)
57 Defining this function is optional. This function is called to
58 get an array of config options which can be set by the user. All
59 of these options have the name of your mode prefixed on the
60 front so if your array is for example {"opt1", "opt2"} the con‐
61 fig options defined will be mode-opt1=value and mode-opt2=value
62 where mode is the name of the shared object.
63
64
65 size_t get_arg_count(void)
66 Defining this function is optional. This function is called to
67 get the number of arguments returned by get_arg_names(void).
68
69
70 void exec(const char* cmd)
71 Defining this function is required. This function is called when
72 the user selects an entry.
73
74 const char* cmd - The action registered to the selected entry.
75 If your mode allows executing searches directly then this will
76 be the search contents if no matching entries exist.
77
78
79 struct widget* get_widget(void)
80 Defining this function is optional. This function is called to
81 request the next widget to be added. See wofi_create_widget() in
82 wofi-api(3) on how to obtain a struct widget*. NULL should be
83 returned to denote no more widgets are available.
84
85
86 bool no_entry(void)
87 Defining this function is optional. This function is called to
88 find out whether or not this mode supports running searches
89 without any matching entries. The default is false, if you wish
90 to allow your mode to take searches directly you must define
91 this and return true.
92
93
94
95 wofi(3)