Skip to content

Allow the user to pass extra parameters to fzf#87

Open
pdonadeo wants to merge 2 commits intoBiont:masterfrom
pdonadeo:master
Open

Allow the user to pass extra parameters to fzf#87
pdonadeo wants to merge 2 commits intoBiont:masterfrom
pdonadeo:master

Conversation

@pdonadeo
Copy link
Copy Markdown
Contributor

@pdonadeo pdonadeo commented Mar 6, 2025

I use it, for example, to pass --algo=v2

pdonadeo added 2 commits March 6, 2025 23:35
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.
Copilot AI review requested due to automatic review settings April 4, 2026 22:07
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_OPTIONS and attempts to pass it through to the fzf invocation.
  • 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.

Comment thread sway-launcher-desktop.sh
Comment on lines +321 to +323
readarray -t COMMAND_STR <<<"$(
${FZF_COMMAND} --ansi +s -x -d '\034' --nth ..3 --with-nth 3 \
"${FZF_EXTRA_OPTIONS}" \
Copy link

Copilot AI Apr 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
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[@]}" \

Copilot uses AI. Check for mistakes.
Comment thread sway-launcher-desktop.sh
local filename="${XDG_CONFIG_HOME-${HOME}/.config}/${condition#* }"
local condition
local filename
condition="$(grep "AutostartCondition" "$1" | cut -d'=' -f2)"
Copy link

Copilot AI Apr 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Suggested change
condition="$(grep "AutostartCondition" "$1" | cut -d'=' -f2)"
condition="$(grep -m1 '^AutostartCondition=' "$1" | cut -d'=' -f2-)"

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants