I use dmenu to run programs, but I did not like that dmenu_run included every single program included those without GUIs. I maintained a list of programs manually, then I wrote a script to generate the list based on whether or not a binary linked to GUI libraries. Recently, I wrote a C program that uses nftw(3) to find [desktop entry files][1], parses them and adds them to a list saved at ~/.del by default. The source is here: https://github.com/ericpruitt/edge/blob/master/utilities/del.c . I believe it is POSIX compliant, and I was able to compile it on Linux, OpenBSD and FreeBSD.
[1]: https://specifications.freedesktop.org/desktop-entry-spec/latest/ Here's the usage information: DEL searches for Freedesktop Desktop Entries, generates a list of graphical commands and uses dmenu as a front-end so the user can select a command to execute. Exit statuses: 1 Fatal error encountered. 2 Non-fatal error encountered. > 128 The dmenu subprocess was killed by a signal. Options: -h Show this text and exit. -f PATH Use specified file as the command list. When this is unspecified, it defaults to ~/.del -r Search for desktop entries to refresh the command list. Trailing command line parameters are interpreted as folders to be searched. Folders on different devices must be explicitly enumerated because the search will not automatically cross filesystem boundaries; in terms of find(1), the search is equivalent to the following: find $ARGUMENTS -xdev -name '*.desktop' When no paths are given, "/" is searched by default. A newline-separated list of programs can be fed to del via stdin to include programs that do not have desktop entries in the generated launcher list. The programs must exist in $PATH or they will be silently ignored. When "-r" is not specified, dmenu is launched with the command list feed into standard input. Trailing command line arguments can be used to pass flags to dmenu or use a different menu altogether: Set the background color of selected text to red: $ del -- -sb "#ff0000" Use rofi in dmenu mode instead of dmenu: $ del rofi -dmenu Please let me know what you think. Thanks, Eric