diff options
| -rw-r--r-- | README.md | 5 | ||||
| -rwxr-xr-x | sway-launcher-desktop.sh | 12 |
2 files changed, 13 insertions, 4 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 0e1cfb3..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" |
