From e8db59a9efb8ea0322352579c18f76cfc773d117 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8B=BC=E8=80=B3?= Date: Sat, 25 Nov 2017 11:09:57 +0100 Subject: [PATCH] Use socat exit status to determine if the socket is usable Instead of checking, if *any* qutebrowser process is running (which may or may not have an IPC socket where we expect it), simply launch a new instance *if socat fails*. Which it does, if: * the socket file doesn't exist (qutebrowser simply not running), or * the socket isn't connectable (qutebrowser crashed, left orphaned socket) Also put new instances into background, so the script behaves a bit more consistently. (Else it *sometimes* blocks and *sometimes doesn't*, when run.) --- scripts/open_url_in_instance.sh | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/scripts/open_url_in_instance.sh b/scripts/open_url_in_instance.sh index e9c6db2a1..85cd919d4 100755 --- a/scripts/open_url_in_instance.sh +++ b/scripts/open_url_in_instance.sh @@ -8,12 +8,8 @@ _proto_version=1 _ipc_socket="${XDG_RUNTIME_DIR}/qutebrowser/ipc-$(echo -n "$USER" | md5sum | cut -d' ' -f1)" _qute_bin="/usr/bin/qutebrowser" -if [[ -e "${_ipc_socket}" ]] && [[ `pgrep -f $_qute_bin` ]]; then - exec printf '{"args": ["%s"], "target_arg": null, "version": "%s", "protocol_version": %d, "cwd": "%s"}\n' \ - "${_url}" \ - "${_qb_version}" \ - "${_proto_version}" \ - "${PWD}" | socat - UNIX-CONNECT:"${_ipc_socket}" -else - exec $_qute_bin --backend webengine "$@" -fi +exec printf '{"args": ["%s"], "target_arg": null, "version": "%s", "protocol_version": %d, "cwd": "%s"}\n' \ + "${_url}" \ + "${_qb_version}" \ + "${_proto_version}" \ + "${PWD}" | socat - UNIX-CONNECT:"${_ipc_socket}" 2>/dev/null || $_qute_bin --backend webengine "$@" &