kpsh-menu(1) General Commands Manual kpsh-menu(1)

kpsh-menu - menu-like kpsh's daemon client

kpsh-menu [OPTIONS]

kpsh-menu allows access to kpsh run in daemon mode (kpsh -d) via menu-like programs, like dmenu, rofi or fzf. It is optimized for programs which read their stdin asynchronously, e.g. rofi -async-pre-read=0 or dmenu with "non-blocking stdin" patch: it quickly displays menu and feeds it with entries when they become available (e.g. when database is unlocked).

kpsh-menu requires a running kpsh daemon (see: kpsh(1) --daemon) and socket paths used by daemon an kpsh-menu must match. It is the case for the default paths, but they can be configured with --socket-path options at both menu and daemon's side.

kpsh-menu doesn't provide any way to open and unlock KeePass database. It managed by kpsh server. For example:

$ kpsh -d --keyfike /path/to/keyfile --password-command "gpg2 -q --decrypt pwd.gpg" /path/to/db.kdbx &
$ kpsh-menu

-h, --help
Show help message and quit.

-m, --menu MENU_CMD

Menu command to use. Can be any command, with additional arguments. Default: rofi.

-s, --socket-path FILE

Path to the kpsh's socket.

-c, --command COMMAND

Add a command to execute on selected entry. When more than one command is specified this way, kpsh-menu will show them in menu program. COMMAND has a special formatting: see the "COMMANDS" section.

By default, kpsh-menu will autotype selected entry with a default autotype sequence.

-n, --notify NOTIFY_COMMAND

Command which kpsh-menu will run after executing of COMMAND configured with "n" flag (see the "COMMANDS" section).

--pinentry PINENTRY_COMMAND

Command to run pinentry when kpsh server prompts for user input. When both kpsh server and kpsh-menu are configured with --pinentry options, the value of kpsh server is prioritised. Default: /usr/bin/pinentry.

The format of COMMAND passed to the --command consists of 3 parts, separated with double colons:

<DISPLAY_NAME>::<COMMAND>::<FLAGS>

DISPLAY_NAME: (mandatory) human-friendly name displayed in menu.

COMMAND: (mandatory) kpsh command. It may contain a placeholder {} which will be replaced with selected entry path.

FLAGS: (optional) a set of flags used to modify behavior of kpsh-menu after selected command is executed (see flags section). See the "Flags" section.

The following flags can be used for commands:

l: (loop) when set, kpsh-menu will loop, i.e. will be re-display command selection screen. This allows performing several separate actions on a selected entry, e.g. first typing a username, and then password.

n: (notify) after command execution, kpsh-menu will run a NOTIFY_COMMAND set with --notify option.

$ kpsh-menu 
	-m "dmenu -p '>'"
	-c "Autotype::autotype '{}'" 
	-c "Username::autotype '{}' -s {USERNAME}::ln"
	-c "Password::autotype '{}' -s {PASSWORD}::ln"
	-c "Type TAB::autotype '{} -s {TAB}::l'"
	-c "Type ENTER::autotype '{} -s {ENTER}::l'"
	-c "Show::show '{}'"
	-c "Lock database::lock"
	-n "notify-send kpsh-menu 'Executed command {cmd}'"

kpsh(1), kpsh-client(1)

Michał Góral <dev@goral.net.pl>

Source code: https://git.goral.net.pl/keepass-shell.git

2024-02-13