The following functions are used to interact with wofi.
char*wofi_parse_image_escapes(constchar*text)
This function takes in text containing image escapes and pango markup and will return the plain
text with all of that stripped. The string returned is newly allocated and should be freed by the
caller when they are done with it.
constchar*text - The input text containing image escapes and pango markup.
voidwofi_write_cache(structmode*mode,constchar*cmd)
Writes an entry to the cache file.
structmode*mode - The structmode* given to your mode's init() function.
constchar*cmd - The entry to write to the cache file. If this entry already exists the number of
times it has been written will be incremented.
voidwofi_remove_cache(structmode*mode,constchar*cmd)
Removes an entry from the cache file.
structmode*mode - The structmode* given to your mode's init() function.
constchar*cmd - The entry to remove from the cache file. This does NOT decrement the number of
times written, it fully removes the entry.
structwl_list*wofi_read_cache(structmode*mode)
Reads the cache and returns a structwl_list* containing the entires. The list is made up of
structcache_line* entries. The wayland documentation should be referred to for the usage of a
wl_list.
structmode*mode - The structmode* given to your mode's init() function.
structwidget*wofi_create_widget(structmode*mode,char*text[],char*search_text,char*actions[],size_taction_count)
Creates a widget from the specified information. This widget should be returned by the mode's
get_widget() function in order to be displayed.
structmode*mode - The structmode* given to your mode's init() function.
char*text[] - The array of text to display on the entry in wofi. Each element in the array
represents the text for 1 action. The array should only be larger than 1 if you're creating a
multi-action entry. Multi-action entries need to provide 1 string for every action the entry has.
char*search_text - The text which the user can search for to find this widget.
char*actions[] - The array of actions for the entry. An action is the text given to a mode's
exec() function when the user selects an entry. Multi-action entries need to provide 1 action
string for every action the entry has.
size_taction_count - The number of actions the entry will have.
voidwofi_insert_widgets(structmode*mode)
This will requery the mode for more widgets.
structmode*mode - The structmode* given to your mode's init() function.
char*wofi_get_dso_path(structmode*mode)
Returns the path to this mode's DSO if it's an external mode, returns NULL otherwise.
structmode*mode - The structmode* given to your mode's init() function.
boolwofi_allow_images(void)
Returns true if the user enabled images, false otherwise.
boolwofi_allow_markup(void)
Returns true if the user enabled pango markup, false otherwise.
uint64_twofi_get_image_size(void)
Returns the user specified image size, 32 by default. Wofi will scale images for you, this is just
informational and is not required but can be helpful if multiple sizes are available.
boolwofi_mod_shift(void)
Returns true if the user was holding shift when selecting an entry, false otherwise.
boolwofi_mod_control(void)
Returns true if the user was holding control when selecting an entry, false otherwise.
voidwofi_term_run(constchar*cmd)
Runs the provided cmd in a terminal emulator. The following order is used for picking a terminal
emulator: The user specified terminal, kitty, alacritty, wezterm, foot, termite, gnome-terminal,
weston-terminal. If none of these can be found execution will fail.
constchar*cmd - The command to run, this is invoked by doing term--cmd.
voidwofi_exit(void)
This function is how you should call to exit wofi. It checks the status given and only sets a
custom exit code if you pass EXIT_SUCCESS. If you call the libc exit() function then the custom
exit code will always be used even if an error should be reported
wofi-api(3)