summaryrefslogtreecommitdiff
path: root/scripts/open_url_in_instance.sh
diff options
context:
space:
mode:
author狼耳 <Rouji@users.noreply.github.com>2017-11-25 11:09:57 +0100
committerGitHub <noreply@github.com>2017-11-25 11:09:57 +0100
commite8db59a9efb8ea0322352579c18f76cfc773d117 (patch)
tree8a5cdca2b75b4bef1e1e865301abbdc2887a7e99 /scripts/open_url_in_instance.sh
parent765a22189c3effa6482e87089739a21d438e261f (diff)
downloadqutebrowser-e8db59a9efb8ea0322352579c18f76cfc773d117.tar.gz
qutebrowser-e8db59a9efb8ea0322352579c18f76cfc773d117.zip
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.)
Diffstat (limited to 'scripts/open_url_in_instance.sh')
-rwxr-xr-xscripts/open_url_in_instance.sh14
1 files 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 "$@" &