qutebrowser/scripts/open_url_in_instance.sh
狼耳 765a22189c
check if qutebrowser process is running
Sometimes when qutebrowser crashes, it leaves the IPC socket file behind. In those cases this script still tried to use it, failed, and didn't open your URL at all.
2017-11-24 14:52:33 +01:00

20 lines
616 B
Bash
Executable File

#!/bin/bash
# initial idea: Florian Bruhin (The-Compiler)
# author: Thore Bödecker (foxxx0)
_url="$1"
_qb_version='0.10.1'
_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