t-8ch / pinentry-bemenu

Pinentry based on bemenu
GNU General Public License v3.0
52 stars 3 forks source link

Pass opts to menu #2

Closed wh1tevs closed 3 years ago

wh1tevs commented 3 years ago

Hello, it's me again) How can i pass args to bemenu? I tried to use ~/.config/environment.d/.conf, but this has no effect. Also tried Environment="BEMENU_OPTS=\"-H 30...\"" direct in systemd unit, but this doesn't works to.

And i have no line breaks, it is okay without opts or no? image

t-8ch commented 3 years ago

Hi, welcome back!

This was not possible so far. I just pushed a commit that adds CLI options that mirror the ones from the native bemenu tools. (Not part of a proper release yet)

I don't know if you can make bemenu display multiline prompts. The current state is fine for me. If you can make the native bemenu show multiline prompts then please let me know and I'll add the same to pinentry-bemenu.

t-8ch commented 3 years ago

BEMENU_OPTS is also not supported (yet)

wh1tevs commented 3 years ago

Okay, thanks. How pass options after update, in gpg-agent.conf?

t-8ch commented 3 years ago

For the moment you would have to create a wrapper script to pass the options.

t-8ch commented 3 years ago

BEMENU_OPTS should now also work.

wh1tevs commented 3 years ago

~It's dont work if called by gpg, but works if called directly by /usr/local/bin/pinentry-bemenu. And if -p dont specified prompt is empty (it's meant be?).~

``` Apr 23 05:47:54 zenbook gpg-agent[2925]: Usage: pinentry-bemenu [-bn?] [--debug] [-b|--bottom] [-n|--no-overlap] Apr 23 05:47:54 zenbook gpg-agent[2925]: [-m|--monitor=INT] [-H|--line-height=INT] [--fn=STRING] Apr 23 05:47:54 zenbook gpg-agent[2925]: [--tb=#RRGGBB] [--tf=#RRGGBB] [--fb=#RRGGBB] [--ff=#RRGGBB] Apr 23 05:47:54 zenbook gpg-agent[2925]: [--nb=#RRGGBB] [--nf=#RRGGBB] [--hb=#RRGGBB] [--hf=#RRGGBB] Apr 23 05:47:54 zenbook gpg-agent[2925]: [--sb=#RRGGBB] [--sf=#RRGGBB] [--scb=#RRGGBB] [--scf=#RRGGBB] Apr 23 05:47:54 zenbook gpg-agent[2925]: [-?|--help] [--usage] Apr 23 05:47:54 zenbook gpg-agent[1307]: can't connect to the PIN entry module '/usr/local/bin/pinentry-bemenu': End of file Apr 23 05:47:54 zenbook gpg-agent[1307]: failed to unprotect the secret key: No pinentry Apr 23 05:47:54 zenbook gpg-agent[1307]: failed to read the secret key Apr 23 05:47:54 zenbook gpg-agent[1307]: command 'PKDECRYPT' failed: No pinentry ```

UPD: sorry miss this

For the moment you would have to create a wrapper script to pass the options.

Thanks.

t-8ch commented 3 years ago

gpg-agent actively filters the environment passed to pinentry, so the script is necessary.

Cloudef commented 3 years ago

Maybe I should move the option parsing into libbemenu so it can be reused, you wouldn't have to keep up with the options in bemenu and bemenu-run then either?

t-8ch commented 3 years ago

@Cloudef Sure, that would be great!

Cloudef commented 2 years ago

@t-8ch Pushed some wip code: https://github.com/Cloudef/bemenu/blob/wip-argument-parsing-in-library/lib/options.c https://github.com/Cloudef/bemenu/blob/wip-argument-parsing-in-library/lib/bemenu.h#L1051-L1086 Does the interface look all right? I won't be using getopt in the library, as it isn't dmenu compatible. Not in the public header right now, but bm_menu_apply_option will be public too, in case you want to control the argument parsing fully.

t-8ch commented 2 years ago

@Cloudef The interface looks fine. At the moment I have one option that is not taken from bemenu, namely --debug. I'd like to keep it but am not sure if it would be better for bemenu to expose its argument parsing library or to provide some callback mechanism for unknown arguments.

Cloudef commented 2 years ago

You can have your own parsing in top of the bemenu's, as the parser will not be fatal for unknown arguments. Also since the bemenu's options are described, you can even skip bemenu's parsing completely if you want. I can make the parser callback for unknown arguments 🤔 Might be good feature to avoid writing your own parser.

Bemenu get_available_options will let you generate --help or manpage.

t-8ch commented 2 years ago

You can have your own parsing in top of the bemenu's, as the parser will not be fatal for unknown arguments.

I'm not sure how this would mix with custom options taking or not taking parameters.