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.)
This commit is contained in:
parent
765a22189c
commit
e8db59a9ef
@ -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 "$@" &
|
||||
|
Loading…
Reference in New Issue
Block a user