Skip to content

Commit

Permalink
Merge pull request #10 from ahaasler/use-fifo
Browse files Browse the repository at this point in the history
Use a FIFO to stop the loading animation when finished
  • Loading branch information
Biont authored Nov 23, 2019
2 parents e81161a + 30f71a9 commit 8aa7fe6
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions sway-launcher-desktop.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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") &
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 8aa7fe6

Please sign in to comment.