Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Undesired newline at the end of command metadata #85

Open
aivarsV opened this issue Dec 27, 2024 · 1 comment
Open

Undesired newline at the end of command metadata #85

aivarsV opened this issue Dec 27, 2024 · 1 comment

Comments

@aivarsV
Copy link

aivarsV commented Dec 27, 2024

Like title says, in latest version, command metadata ends with \n character. This might not be an issue, if using passing {2} as the last argument to launch command as in example from README.MD. But it will fail to launch desktop entries with extra arguments, if {2} is used in the middle of launch_cmd, like following:

[desktop]
list_cmd=sway-launcher-desktop list-entries
preview_cmd=sway-launcher-desktop describe-desktop "{1}"
launch_cmd=riverctl spawn "$(sway-launcher-desktop generate-command '{1}' '{2}' | sed -e 's/^exec //')"

For me, quick and dirty solution was to remove any new lined from COMMAND just before it is executed:

diff --git a/tmp/sway-launcher-desktop.sh b/usr/bin/sway-launcher-desktop
old mode 100644
new mode 100755
index 6c0ba38..c684a2c
--- a/tmp/sway-launcher-desktop.sh
+++ b/usr/bin/sway-launcher-desktop
@@ -363,6 +363,7 @@ readarray -d ${DEL} -t PROVIDER_ARGS <<<${PROVIDERS[${PARAMS[1]}]}
 COMMAND=${PROVIDER_ARGS[2]//\{1\}/${PARAMS[0]}}
 COMMAND=${COMMAND//\{2\}/${PARAMS[3]}}
 COMMAND=${COMMAND%%[[:space:]]}
+COMMAND=${COMMAND//[$'\n']}
 
 if [ -t 1 ]; then
   echo "Launching command: ${COMMAND}" >&3

However, I believe, undesired newline comes from

COMMAND_STR=$(printf '%s\n' "${COMMAND_STR[@]: -1}")

@bkmgit
Copy link

bkmgit commented Dec 27, 2024

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

No branches or pull requests

2 participants