# sgnix/awesome-dmenu architecture

> Architecture diagram of the GitHub repository sgnix/awesome-dmenu, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-05-26). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/sgnix/awesome-dmenu
- Repository: https://github.com/sgnix/awesome-dmenu

## Overview

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: [`lib/dmenu.lua`](https://github.com/sgnix/awesome-dmenu/blob/master/lib/dmenu.lua) (key handling)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_integration["Awesome integration"]
  node_rc_config["rc.lua items<br/>config input"]
  node_display_widget["textbox widget<br/>ui widget"]
  node_wibox_embed["panel embed<br/>layout integration"]
  node_awesome_api["Awesome APIs<br/>wm runtime"]
  node_visible_limit{{"clipped list<br/>ui limit"}}
end

subgraph group_core["dmenu module"]
  node_show_api(("show()<br/>entrypoint<br/>[dmenu.lua]"))
  node_menu_state["menu state<br/>runtime state<br/>[dmenu.lua]"]
  node_entry_list["item list<br/>data model<br/>[dmenu.lua]"]
  node_filter_logic{{"filtering<br/>match logic<br/>[dmenu.lua]"}}
  node_nav_keys(("key handling<br/>event loop<br/>[dmenu.lua]"))
  node_confirm(("confirm selection<br/>action trigger<br/>[dmenu.lua]"))
  node_cancel(("escape<br/>action trigger<br/>[dmenu.lua]"))
end

subgraph group_actions["Action dispatch"]
  node_spawn_cmd["spawn command<br/>process action"]
  node_lua_cb["Lua callback<br/>function action"]
  node_client_flow["client actions<br/>window action"]
end

node_rc_config -->|"supplies items"| node_show_api
node_show_api -->|"activates"| node_menu_state
node_menu_state -->|"derives"| node_entry_list
node_entry_list -->|"narrows by input"| node_filter_logic
node_nav_keys -->|"updates query"| node_filter_logic
node_nav_keys -->|"Enter"| node_confirm
node_nav_keys -->|"Escape"| node_cancel
node_filter_logic -->|"renders"| node_display_widget
node_display_widget -->|"embedded in"| node_wibox_embed
node_confirm -->|"string value"| node_spawn_cmd
node_confirm -->|"function value"| node_lua_cb
node_lua_cb -->|"uses"| node_awesome_api
node_awesome_api -->|"supports"| node_client_flow
node_visible_limit -.->|"constrains"| node_display_widget
node_show_api -->|"listens for"| node_nav_keys

click node_show_api "https://github.com/sgnix/awesome-dmenu/blob/master/lib/dmenu.lua"
click node_menu_state "https://github.com/sgnix/awesome-dmenu/blob/master/lib/dmenu.lua"
click node_entry_list "https://github.com/sgnix/awesome-dmenu/blob/master/lib/dmenu.lua"
click node_filter_logic "https://github.com/sgnix/awesome-dmenu/blob/master/lib/dmenu.lua"
click node_nav_keys "https://github.com/sgnix/awesome-dmenu/blob/master/lib/dmenu.lua"
click node_confirm "https://github.com/sgnix/awesome-dmenu/blob/master/lib/dmenu.lua"
click node_cancel "https://github.com/sgnix/awesome-dmenu/blob/master/lib/dmenu.lua"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_rc_config,node_display_widget,node_wibox_embed,node_awesome_api,node_visible_limit toneBlue
class node_show_api,node_menu_state,node_entry_list,node_filter_logic,node_nav_keys,node_confirm,node_cancel toneAmber
class node_spawn_cmd,node_lua_cb,node_client_flow toneMint
```

## Components

### Awesome integration

Embedding and runtime boundaries inside Awesome WM

- **rc.lua items**: config input · Caller-provided Lua table where keys become menu entries and values define actions
- **textbox widget**: ui widget · Text display embedded into Awesome’s panel or wibox
- **panel embed**: layout integration · Places the launcher inside Awesome’s existing UI layout
- **Awesome APIs**: wm runtime · Client matching, spawning, and other Awesome-provided integration points
- **clipped list**: ui limit · Long lists are clipped rather than paginated

### dmenu module

Main launcher and menu logic in lib/dmenu.lua

- [show()](https://github.com/sgnix/awesome-dmenu/blob/master/lib/dmenu.lua): entrypoint · Activates the menu and makes it ready for input · `lib/dmenu.lua`
- [menu state](https://github.com/sgnix/awesome-dmenu/blob/master/lib/dmenu.lua): runtime state · Tracks visible entries, current selection, and active filtering · `lib/dmenu.lua`
- [item list](https://github.com/sgnix/awesome-dmenu/blob/master/lib/dmenu.lua): data model · Selectable options derived from the caller table · `lib/dmenu.lua`
- [filtering](https://github.com/sgnix/awesome-dmenu/blob/master/lib/dmenu.lua): match logic · Narrows visible entries as the user types · `lib/dmenu.lua`
- [key handling](https://github.com/sgnix/awesome-dmenu/blob/master/lib/dmenu.lua): event loop · Keyboard navigation, confirmation, and cancel handling · `lib/dmenu.lua`
- [confirm selection](https://github.com/sgnix/awesome-dmenu/blob/master/lib/dmenu.lua): action trigger · Enter commits the current item · `lib/dmenu.lua`
- [escape](https://github.com/sgnix/awesome-dmenu/blob/master/lib/dmenu.lua): action trigger · Cancels and exits the active menu · `lib/dmenu.lua`

### Action dispatch

What happens when an item is activated

- **spawn command**: process action · String values are executed as shell/process commands
- **Lua callback**: function action · Function values are invoked directly in Lua
- **client actions**: window action · Useful for run-or-raise style client control

## Connections

- 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
