From e45f50830062ec5dcfd1325c511051b039eea634 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Moritz=20Mei=C3=9Felbach?= Date: Sun, 15 Dec 2019 21:54:50 +0100 Subject: Silence all output of selected command. This seems to be needed for some terminal emulators to completely detach the command. Fixes #13 --- sway-launcher-desktop.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sway-launcher-desktop.sh b/sway-launcher-desktop.sh index f861177..59cce1b 100755 --- a/sway-launcher-desktop.sh +++ b/sway-launcher-desktop.sh @@ -222,4 +222,4 @@ readarray -d ${DEL} -t PROVIDER_ARGS <<<${PROVIDERS[${PARAMS[1]}]} # Substitute {1}, {2} etc with the correct values COMMAND=${PROVIDER_ARGS[2]//\{1\}/${PARAMS[0]}} COMMAND=${COMMAND//\{2\}/${PARAMS[3]}} -(exec setsid /bin/sh -c "${COMMAND}" &) +(exec setsid /bin/sh -c "${COMMAND}" &>/dev/null &) -- cgit v1.2.3 From c20c0f471d9ec397f612405482f672a3c7d2e36f Mon Sep 17 00:00:00 2001 From: Sebastian Hamann Date: Mon, 16 Dec 2019 21:53:31 +0100 Subject: Remove man-page reference from command description --- sway-launcher-desktop.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sway-launcher-desktop.sh b/sway-launcher-desktop.sh index 59cce1b..0e1cfb3 100755 --- a/sway-launcher-desktop.sh +++ b/sway-launcher-desktop.sh @@ -59,7 +59,7 @@ function describe-desktop() { function describe-command() { readarray arr < <(whatis -l "$1" 2>/dev/null) description="${arr[0]}" - description="${description%*-}" + description="${description#* - }" echo -e "\033[33m${1}\033[0m" echo "${description:-No description}" } -- cgit v1.2.3 From 1d5bce7e42ca853301719137b8d497d3051bf96a Mon Sep 17 00:00:00 2001 From: Sebastian Hamann Date: Tue, 17 Dec 2019 09:23:06 +0100 Subject: Support switching between different provider configs --- README.md | 5 ++++- sway-launcher-desktop.sh | 12 +++++++++--- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 5e0de3e..6442d41 100644 --- a/README.md +++ b/README.md @@ -54,4 +54,7 @@ The `list_cmd` generated the list of entries. For each entry, it has to print th The `preview_cmd` renders the contents of the `fzf` preview panel. You can use the template variable `{1}` in your command, which will be substituted with the value of the selected item. -The `launch_cmd` is fired when the user has selected one of the provider's entries. \ No newline at end of file +The `launch_cmd` is fired when the user has selected one of the provider's entries. + +Note: Pass the environment variable `PROVIDERS_FILE` to read custom providers from another file than the default `providers.conf`. +The path in `PROVIDERS_FILE` can either be absolute or relative to `${HOME}/.config/sway-launcher-desktop/`. diff --git a/sway-launcher-desktop.sh b/sway-launcher-desktop.sh index 59cce1b..becf7ba 100755 --- a/sway-launcher-desktop.sh +++ b/sway-launcher-desktop.sh @@ -15,13 +15,17 @@ DEL=$'\34' TERMINAL_COMMAND="${TERMINAL_COMMAND:="urxvt -e"}" GLYPH_COMMAND=" " GLYPH_DESKTOP=" " -HIST_FILE="${XDG_CACHE_HOME:-$HOME/.cache}/${0##*/}-history.txt" CONFIG_DIR="${XDG_CONFIG_HOME:-$HOME/.config}/sway-launcher-desktop" +PROVIDERS_FILE="${PROVIDERS_FILE:=providers.conf}" +if [[ "${PROVIDERS_FILE#/}" == "${PROVIDERS_FILE}" ]]; then + # $PROVIDERS_FILE is a relative path, prepend $CONFIG_DIR + PROVIDERS_FILE="${CONFIG_DIR}/${PROVIDERS_FILE}" +fi # Provider config entries are separated by the field separator \034 and have the following structure: # list_cmd,preview_cmd,launch_cmd declare -A PROVIDERS -if [ -f "${CONFIG_DIR}/providers.conf" ]; then +if [ -f "${PROVIDERS_FILE}" ]; then eval "$(awk -F= ' BEGINFILE{ provider=""; } /^\[.*\]/{sub("^\\[", "");sub("\\]$", "");provider=$0} @@ -36,10 +40,12 @@ if [ -f "${CONFIG_DIR}/providers.conf" ]; then } print "PROVIDERS[\x27" key "\x27]=\x27" providers[key]["list_cmd"] "\034" providers[key]["preview_cmd"] "\034" providers[key]["launch_cmd"] "\x27\n" } - }' "${CONFIG_DIR}/providers.conf")" + }' "${PROVIDERS_FILE}")" + HIST_FILE="${XDG_CACHE_HOME:-$HOME/.cache}/${0##*/}-${PROVIDERS_FILE##*/}-history.txt" else PROVIDERS['desktop']="${0} list-entries${DEL}${0} describe-desktop '{1}'${DEL}${0} run-desktop '{1}' {2}" PROVIDERS['command']="${0} list-commands${DEL}${0} describe-command {1}${DEL}${TERMINAL_COMMAND} {1}" + HIST_FILE="${XDG_CACHE_HOME:-$HOME/.cache}/${0##*/}-history.txt" fi touch "$HIST_FILE" -- cgit v1.2.3