From 809113cb77bf5b79f90b32652068188e23cf5809 Mon Sep 17 00:00:00 2001 From: rnhmjoj Date: Sun, 7 Feb 2021 11:14:40 +0100 Subject: [PATCH] scripts/qutebrowser: fix multiprocess --- scripts/qutebrowser | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/scripts/qutebrowser b/scripts/qutebrowser index 8916a5c..34beaaa 100755 --- a/scripts/qutebrowser +++ b/scripts/qutebrowser @@ -1,10 +1,14 @@ #!/bin/sh -url="$1" -ver='1.6.3' -proto=1 -sock="$XDG_RUNTIME_DIR/qutebrowser/ipc-$(printf "%s" "$USER" | md5sum | cut -d\ -f1)" bin=$(env PATH="$(echo "$PATH" | sed "s|$(dirname "$0"):||g")" sh -c 'command -v qutebrowser') -fmt='{"args": ["%s"], "target_arg": null, "version": "%s", "protocol_version": %d, "cwd": "%s"}\n' -printf "$fmt" "$url" "$ver" "$proto" "$PWD" | nc -U "$sock" 2>/dev/null || exec "$bin" "$@" & +if pgrep qutebrowser >/dev/null; then + "$bin" "$@" +else + url="$1" + ver='1.6.3' + proto=1 + sock="$XDG_RUNTIME_DIR/qutebrowser/ipc-$(printf "%s" "$USER" | md5sum | cut -d\ -f1)" + fmt='{"args": ["%s"], "target_arg": null, "version": "%s", "protocol_version": %d, "cwd": "%s"}\n' + printf "$fmt" "$url" "$ver" "$proto" "$PWD" | nc -U "$sock" 2>/dev/null || exec "$bin" "$@" & +fi