diff options
| author | Adrian Haasler García <dev@adrianhaasler.com> | 2019-11-22 21:12:05 +0100 |
|---|---|---|
| committer | Adrian Haasler García <dev@adrianhaasler.com> | 2019-11-22 21:19:03 +0100 |
| commit | 30f71a98c2dfcfe6efc755f01ea8ae44bd516f58 (patch) | |
| tree | ee06f3cae0913c4017b1176a15d416c465098bbf /sway-launcher-desktop.sh | |
| parent | e81161a7900556a563594a051d4fad58733cafb7 (diff) | |
| download | sway-launcher-desktop-30f71a98c2dfcfe6efc755f01ea8ae44bd516f58.tar.gz sway-launcher-desktop-30f71a98c2dfcfe6efc755f01ea8ae44bd516f58.zip | |
Use a FIFO as fzf input
The named pipe is used as input for fzf, which means that there is no
need to tail the file and kill that process.
Diffstat (limited to 'sway-launcher-desktop.sh')
| -rwxr-xr-x | sway-launcher-desktop.sh | 18 |
1 files changed, 7 insertions, 11 deletions
diff --git a/sway-launcher-desktop.sh b/sway-launcher-desktop.sh index ff788ba..2441cbe 100755 --- a/sway-launcher-desktop.sh +++ b/sway-launcher-desktop.sh @@ -142,9 +142,9 @@ esac touch "$HIST_FILE" readarray HIST_LINES <"$HIST_FILE" -FZFPIPE=$(mktemp) -PIDFILE=$(mktemp) -trap 'rm "$FZFPIPE" "$PIDFILE"' EXIT INT +FZFPIPE=$(mktemp -u) +mkfifo "$FZFPIPE" +trap 'rm "$FZFPIPE"' EXIT INT # Append Launcher History, removing usage count (printf '%s' "${HIST_LINES[@]#* }" >>"$FZFPIPE") & @@ -173,14 +173,10 @@ entries ${DIRS[@]} >>"$FZFPIPE" ) & COMMAND_STR=$( - ( - tail -n +0 -f "$FZFPIPE" & - echo $! >"$PIDFILE" - ) | - fzf +s -x -d '\034' --nth ..3 --with-nth 3 \ - --preview "$0 describe {1} {2}" \ - --preview-window=up:3:wrap --ansi - (kill -9 "$(<"$PIDFILE")"; exit 0) | tail -n1 + fzf +s -x -d '\034' --nth ..3 --with-nth 3 \ + --preview "$0 describe {1} {2}" \ + --preview-window=up:3:wrap --ansi \ + <"$FZFPIPE" ) || exit 1 [ -z "$COMMAND_STR" ] && exit 1 |
