Allow the user to pass extra parameters to fzf#87
Allow the user to pass extra parameters to fzf#87pdonadeo wants to merge 2 commits intoBiont:masterfrom
Conversation
I use it, for example, to pass `--algo=v2`
- Reformatted sway-launcher-desktop.sh with 4-space indentation - Fixed all shellcheck warnings and errors, including quoting variables, array usage, and command substitutions.
There was a problem hiding this comment.
Pull request overview
This PR aims to let users supply additional fzf CLI flags (e.g. --algo=v2) to the launcher via an environment variable.
Changes:
- Introduces
FZF_EXTRA_OPTIONSand attempts to pass it through to thefzfinvocation. - Refactors formatting/indentation and makes small cleanup edits in a few functions (e.g.
shouldAutostart,purge).
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| readarray -t COMMAND_STR <<<"$( | ||
| ${FZF_COMMAND} --ansi +s -x -d '\034' --nth ..3 --with-nth 3 \ | ||
| "${FZF_EXTRA_OPTIONS}" \ |
There was a problem hiding this comment.
FZF_EXTRA_OPTIONS is expanded as a single (quoted) argument. This prevents passing multiple extra flags (e.g. --algo=v2 --bind ...) and will also pass an empty string argument when the variable is unset/empty. Consider parsing the env var into an array (e.g. read -r -a ... <<<"$FZF_EXTRA_OPTIONS") and expanding it as "${...[@]}", or only appending extra options when non-empty.
| readarray -t COMMAND_STR <<<"$( | |
| ${FZF_COMMAND} --ansi +s -x -d '\034' --nth ..3 --with-nth 3 \ | |
| "${FZF_EXTRA_OPTIONS}" \ | |
| FZF_EXTRA_OPTIONS_ARR=() | |
| if [[ -n "$FZF_EXTRA_OPTIONS" ]]; then | |
| read -r -a FZF_EXTRA_OPTIONS_ARR <<<"$FZF_EXTRA_OPTIONS" | |
| fi | |
| readarray -t COMMAND_STR <<<"$( | |
| ${FZF_COMMAND} --ansi +s -x -d '\034' --nth ..3 --with-nth 3 \ | |
| "${FZF_EXTRA_OPTIONS_ARR[@]}" \ |
| local filename="${XDG_CONFIG_HOME-${HOME}/.config}/${condition#* }" | ||
| local condition | ||
| local filename | ||
| condition="$(grep "AutostartCondition" "$1" | cut -d'=' -f2)" |
There was a problem hiding this comment.
shouldAutostart extracts the condition using grep "AutostartCondition", which can match commented lines or other keys and can also return multiple lines, producing an invalid filename (newline-containing) and incorrect autostart decisions. Prefer a stricter single match like grep -m1 '^AutostartCondition=' (and consider cut -d= -f2- to keep the full RHS).
| condition="$(grep "AutostartCondition" "$1" | cut -d'=' -f2)" | |
| condition="$(grep -m1 '^AutostartCondition=' "$1" | cut -d'=' -f2-)" |
I use it, for example, to pass
--algo=v2