Skip to main content

Sleek dmenu alternative written in Python and powered by curses.

Project description

pmenu

Sleek dmenu alternative written in Python and powered by curses.

pip install pmenu-lib


Button Hover Button Hover



This package provides both a command-line tool and a Python library for creating interactive terminal menus.

Usage

Library Usage

The pmenu(list_of_options) function displays a menu and returns the selected option as a str, or None if the menu is closed without selecting an option.

from pmenu_lib import pmenu

options = ["Option 1", "Option 2", "Option 3"]
selected_option = pmenu(options)

if selected_option:
    print(f"You selected: {selected_option}")
else:
    print("No option selected")

CLI Usage

After installation, you can use pmenu from the command line:

pmenu "line1\nline2\nline3..."

Or pass multiple arguments:

pmenu "option1" "option2" "option3"

The selected option will be written to /tmp/pmenu (or equivalent temp directory on Windows).

Exit Codes

  • 0: Option selected successfully
  • 1: Menu closed without selection (ESC pressed)
  • 2: Invalid usage (no arguments provided)

Menu Bindings

  • Up arrow: Highlight the previous menu entry
  • Down arrow: Highlight the next menu entry
  • Type to search: Filter options in real-time
  • Backspace: Delete search characters
  • Enter: Select the highlighted entry
  • Esc: Close the menu without selecting

pmenu_fm: A Practical Use Case (Linux)

The pmenu_fm script included in this repository is an example of how pmenu can be integrated into a bash script to implement a simple file selector.

It uses lsd, a modern ls replacement, to get the list of files in the current directory and their associated icons. The list is then passed to pmenu, which displays a menu in the terminal window.

You can highlight a directory with the Up and Down keys, and change to the selected directory or xdg-open the selected file with the Enter key. The menu can be closed with the Esc key.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pmenu_lib-1.2.2.tar.gz (11.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pmenu_lib-1.2.2-py3-none-any.whl (12.8 kB view details)

Uploaded Python 3

File details

Details for the file pmenu_lib-1.2.2.tar.gz.

File metadata

  • Download URL: pmenu_lib-1.2.2.tar.gz
  • Upload date:
  • Size: 11.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.5

File hashes

Hashes for pmenu_lib-1.2.2.tar.gz
Algorithm Hash digest
SHA256 77faadeb864c302c18153265062819e2c97781cc7de996b8c1e53500c0d58a90
MD5 713cb2797815a581e7510917a93584b1
BLAKE2b-256 5ebbb4fc840085952613c35d3c8449a30ea0576436eeca201651d72c7d9d2ec1

See more details on using hashes here.

File details

Details for the file pmenu_lib-1.2.2-py3-none-any.whl.

File metadata

  • Download URL: pmenu_lib-1.2.2-py3-none-any.whl
  • Upload date:
  • Size: 12.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.5

File hashes

Hashes for pmenu_lib-1.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 6a0b34d3fc2881193e035f983d9c38285bcaeb131e884e0a01ba4ffc0b810ee4
MD5 1c6abbc3beaea450c26a8be6693b8a36
BLAKE2b-256 7e771b73bd2f7968678732c49d74b7a2e35bc2ea7f8c8483eddc904adab31b19

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page