Similar dmenu input behaviour
alejandrogallo opened this issue · 2 comments
How would I go about to reproduce the input behaviour of dmenu?
I need to have the following behaviour with smenu as with dmenu, ie.
possible_new_option=$(
cat ~/file-with-some-options |
dmenu -p "Choose an option"
)
In case you are not familiar with this in dmenu, if
the file ~/file-with-some-options
has no content, I simply
get an empty list to choose from and then the input I provide is the one
that dmenu
will write to stdout
. In the case that said file
has contents, then I can simply also choose one from the list, but also
give an input that is not in the list.
As far as I understand smenu
, this is not possible, since one can not
input a string that is not given in the option, list. I would very
much like to be wrong here, since I'd like this to be possible
in order to have scripts that use smenu
in the terminal and dmenu
on desktop contexts.
All I could do with smenu
is something like this,
possible_new_option=$(
cat ~/file-with-some-options |
smenu -m "Choose an option"
)
but of course I am not able to input a random string and
if the file ~/file-with-some-options
is empty then smenu
simply returns.
If this is indeed possible, I would suggest putting it in the man file
for some dmenu users, which they will surely find useful.
Hi,
smenu is only capable of making selections from existing strings, but you can get a similar result using something like this in your case (in bash):
Q="Choose an option: "
F=~/file-with-some-options
[[ -s $F ]] && A=$(smenu -m "$Q" $F) || read -p "$Q" A
Hi! that's what I thought! Anyways that is ok, I just wanted to ask if there was some combinations of the nice zillion flags that did the trick, thanks anyways and hope you keep on it!