Skip to content

Latest commit

 

History

History

README.md

cmenu

About

cmenu is a cross-platform dmenu clone built with Raylib in ~500 lines of code.

Features

Usage: cmenu [options]

Options:

    -b --bottom            Appears at the bottom of the screen. (default: false)
    -c --center            Centers the window. (default: false, overrides x and y)
    -m --monitor MONITOR   Try to display on monitor number supplied. Monitor
                           numbers are starting from 0. (default: 0)
    -p --prompt PROMPT     Prompt to be displayed to the left of the input field.
                           (default: None)
    -x POSITION            X position of the window. (default: 0)
    -y POSITION            Y position of the window. (default: 0)
    -w --width WIDTH       Width of the window. (default: screen width)
    --font-size FONT_SIZE  Font size of the prompt and input. (default: 16px)
    -v --vertical          Vertical menu. (default: false)
    --border-width WIDTH   Border width of the menu. (default: 0)
    --persist              Don't exit when the window loses focus. (default: false)

Behaviour:

    The menu will be read from STDIN as newline separated strings. Order is preserved.

    If the user input is a match for an option and the user has not selected an
    option, the first matching option is printed to stdout and the program 
    exits with code 0.

    If the user input is not a match for an option, the user input is printed 
    to stdout and the program exits with code 2.

    If the user input is empty, nothing is printed and the program exits with 
    code 0.

    If the user presses ESC, the program exits with code 0.

    Pressing and holding ALT whilst running will show shortcuts.

Dependencies

None

Building

1. Get Raylib

You will need Raylib library installed on your system to be able to build cmenu. You can try running

make install-deps

To install raylib.

2. Initialise git submodules

$ git submodule init

3. Build

$ make

The output binaries will be in the target/ directory.

All in one build and run:

$ make clean && make && ./build/target/cmenu <tests/basic.txt

Testing

There is support for memory leak testing described in DEBUG.md

TODO

  • Support mouse click
  • Allow custom font
  • Enable custom colours
  • Create test suite
  • Write launcher script (as per dmenu_run)
  • set up companion shell menu script (use bmenu format?)
  • Build for windows (?)
  • Add timing reporting for first render
  • Add shortcut instructions to readme
  • Configurable shortcuts (eg IJKLM instead of UP/DOWN or different shortcut key)
  • Capture keystrokes before they get to the input field (eg shortcuts)

Done

  • Add number shortcuts option
  • Fix arrow navigation and item selection highlight
  • Compress raw fonts and assets (using LZ4? Zstd?)
  • Set up valgrind check
  • Exit on lose focus by default, with option to prevent
  • enable vertical mode
  • Enable center of screen mode with vertical
  • Fix ugly font
  • Fix styling with input box

Feature inspiration

Packaging

See https://thoughtbot.com/blog/the-magic-behind-configure-make-make-install

Setting up CI: https://blog.reds.ch/?p=1956 See also https://github.com/nektos/act for local testing