diff options
| author | Moritz Meißelbach <arbelzapf@gmail.com> | 2020-01-28 20:59:20 +0100 |
|---|---|---|
| committer | Moritz Meißelbach <arbelzapf@gmail.com> | 2020-01-28 20:59:20 +0100 |
| commit | 219f72ea34e882cba829985a382eed6b850e3c17 (patch) | |
| tree | 85b24b55d30d3c707e93b4fb3e4e3e34e0979125 | |
| parent | 96a1109a71aed08352c4bdf6162acc91948106e1 (diff) | |
| parent | 7ba43fb470b94bcbc5cc44b1569535eb9a168b36 (diff) | |
| download | sway-launcher-desktop-219f72ea34e882cba829985a382eed6b850e3c17.tar.gz sway-launcher-desktop-219f72ea34e882cba829985a382eed6b850e3c17.zip | |
Merge branch 'master' into github_actions
| -rw-r--r-- | README.md | 5 | ||||
| -rwxr-xr-x | sway-launcher-desktop.sh | 16 |
2 files changed, 15 insertions, 6 deletions
@@ -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 f861177..c050eb1 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" @@ -59,7 +65,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}" } @@ -222,4 +228,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 &) |
