Closed jb55 closed 4 years ago
This is fine, but we need to gate it, and we really don't have a good way of doing that right now.
Let me fix up the current options to get replaced by getopt. Then we can back this with -p
or something. :-)
ok, also it might be better to just cat the file and then printf a newline instead of buffering the whole file into memory here. probably not that big of deal, but for large selections it might be slow/use memory.
I pushed an update, no need to do anything complicated with getopt (yet). what do you think?
ah I just realized -p is a dmenu option, so this will break existing setups
pushed a v3 that replaces the -p,--print
option with --clipmenu-print
which shouldn't overlap with $CM_LAUNCHER options
I'd rather properly support getopt as a separate piece of work, first. I'll take a look at that this week. Then we can just rebase and piggyback this PR off of it :-)
In the end we didn't use getopt, because I don't want to end up with mpdmenu-style arg mangling.
If this is gated behind something like CM_OUTPUT_CLIP
, we should be good to go :-)
done
Looks great! Let's make it accept 1 or 0 as with the other settings, though, by making the check (( CM_OUTPUT_CLIP ))
:-)
You can take a look at how CM_DEBUG
is implemented in clipmenud to see how that works and how it's set up.
neat trick, will be using that in my scripts now. pushed an update
tests are failing but I'm not sure why
(( CM_OUTPUT_CLIP ))
rather than (( "$CM_OUTPUT_CLIP" ))
-- there's no need to do that inside arithmetic expressions :-)
It fails because your command returns 1, which is the final command executed, so the script also returns 1. If you use an if
guard, this won't happen.
You can also drop the exec
-- this is the last thing we run anyway, so there's not much to be gained, especially if refactoring happens later.
thanks, updated
edit: just need to add the if guard
ok that should fix it...
please match the indentation for the rest of the file :)
lol fair. sorry for the patch review DoS attack
This allows you to use clipmenu in desktop scripts. For example you could pipe the output of your narrowed selection to another command.
Signed-off-by: William Casarin jb55@jb55.com