How sgnix/awesome-dmenu works
1. This repository is a very small Awesome WM extension: a Lua module that provides a “dmenu-like” launcher inside Awesome, instead of relying on the external Linux dmenu program.
2. The architecture is centered on one module, lib/dmenu.lua, which is required from rc.lua. There are no other subsystems, services, or build components in the repo.
3. The main input to the module is a Lua table supplied by the caller. The table keys become the selectable menu entries, and the values define what happens when an entry is activated.
4. The module produces a UI widget, exposed in the README as mydmenu.textbox, which is meant to be embedded into Awesome’s existing panel/wibox. That makes the UI part of Awesome’s normal window-manager layout rather than a standalone application window.
5. Interaction is event-driven through Awesome’s keyboard handling. When :show() is called, the module becomes active, displays the list of items, and listens for navigation, filtering, confirmation, and cancel keys.
6. The data flow is simple:
- rc.lua constructs the item table
- dmenu.lua turns that table into a visible, filterable list
- the user types or navigates
- the selected item’s value is either executed as a command or invoked as a Lua callback
7. There are two execution modes at the boundary between UI and action:
- string values are treated as shell/process commands to spawn
- function values are executed directly in Lua, allowing integration with Awesome APIs such as client matching and awful.client.run_or_raise
8. The module is therefore both a launcher and an action dispatcher. It does not manage external state, persist history, or communicate with network or storage services.
9. The filtering behavior mimics classic dmenu: typing narrows the visible options, left/right changes selection, Enter confirms, and Escape exits. The README notes that keyboard handling is intentionally close to Linux dmenu behavior.
10. The integration boundary is important: this code is designed to be embedded into Awesome’s rc.lua rather than run independently. It depends on Awesome runtime concepts like widgets, key bindings, client rules, and process spawning.
11. In diagram terms, the repo has one core component with three interfaces:
- configuration input from rc.lua
- presentation through a textbox/widget in the wibox
- action output to process execution or Lua callback logic
12. The only notable limitation described in the repo is UI-related: long item lists are clipped rather than paginated, so the widget’s visible area becomes the practical boundary for navigation.
Main entry points: dmenu.lua key handling
Components 15
Awesome integration
Embedding and runtime boundaries inside Awesome WM
- rc.lua items · Caller-provided Lua table where keys become menu entries and values define actions
- textbox widget · Text display embedded into Awesome’s panel or wibox
- panel embed · Places the launcher inside Awesome’s existing UI layout
- Awesome APIs · Client matching, spawning, and other Awesome-provided integration points
- clipped list · Long lists are clipped rather than paginated
dmenu module
Main launcher and menu logic in lib/dmenu.lua
- show() · Activates the menu and makes it ready for input
lib/dmenu.lua - menu state · Tracks visible entries, current selection, and active filtering
lib/dmenu.lua - item list · Selectable options derived from the caller table
lib/dmenu.lua - filtering · Narrows visible entries as the user types
lib/dmenu.lua - key handling · Keyboard navigation, confirmation, and cancel handling
lib/dmenu.lua - confirm selection · Enter commits the current item
lib/dmenu.lua - escape · Cancels and exits the active menu
lib/dmenu.lua
Action dispatch
What happens when an item is activated
- spawn command · String values are executed as shell/process commands
- Lua callback · Function values are invoked directly in Lua
- client actions · Useful for run-or-raise style client control
Connections 15
- rc.lua items → show(): supplies items · The caller builds the table and passes it to the launcher
- show() → menu state: activates · show() initializes the active menu session
- menu state → item list: derives · The table is turned into selectable entries
- item list → filtering: narrows by input · Typing reduces the visible options
- key handling → filtering: updates query · Keyboard input drives filtering and navigation
- key handling → confirm selection: Enter · Confirmation key accepts the current selection
- key handling → escape: Escape · Cancel key closes the launcher
- filtering → textbox widget: renders · The filtered set is shown in the embedded widget
- textbox widget → panel embed: embedded in · The widget lives inside Awesome’s panel/wibox layout
- confirm selection → spawn command: string value · Text actions launch a process or shell command
- confirm selection → Lua callback: function value · Function actions are executed directly
- Lua callback → Awesome APIs: uses · Callbacks can call Awesome runtime APIs
- Awesome APIs → client actions: supports · Common use case is client matching and run-or-raise behavior
- clipped list → textbox widget: constrains · The visible area bounds long lists
- show() → key handling: listens for · Once shown, the module responds to keyboard events