From 15a129feb40faede940e95e3d9efa8386b21f5c1 Mon Sep 17 00:00:00 2001 From: Gardouille Date: Wed, 2 Dec 2020 16:51:15 +0100 Subject: [PATCH] Focus on new started Qutebrowser --- qb | 34 +++++++++++++++++++++++++--------- 1 file changed, 25 insertions(+), 9 deletions(-) diff --git a/qb b/qb index 4b5f83c..5efd39c 100755 --- a/qb +++ b/qb @@ -176,9 +176,6 @@ goto_existing_qutebrowser() { # {{{ debug_message "goto_existing_qutebrowser − \ Try to open content in existing instance." - ## Focus to Qutebrowser window - focus_to_qutebrowser - ## Try to open Qutebrowser content search_qb_bookmark \ && open_in_qutebrowser @@ -207,6 +204,27 @@ Search aborded or can't find matching bookmark." return "${local_search_qb_bookmark_return}" +} +# }}} +start_qutebrowser() { # {{{ + + local_start_qutebrowser_return="1" + + if is_proc_running "${qutebrowser_proc_pattern}"; then + debug_message "start_qutebrowser − \ +Qutebrowser is already started." + else + debug_message "start_qutebrowser − \ +No existing instance of Qutebrowser. Starting…" + "${QUTEBROWSER_BIN}" + local_start_qutebrowser_return="0" + fi + + ## In any case, be sure to focus to Qutebrowser + focus_to_qutebrowser + + return "${local_start_qutebrowser_return}" + } # }}} open_in_qutebrowser() { # {{{ @@ -248,12 +266,10 @@ main() { # {{{ get_qutebrowser_bin \ || error_message "Can't find a working qutebrowser binary." "1" - ## If nothing related to Qutebrowser is currently running - ### Try to start qutebrowser - ### Then exit with success - is_proc_running "${qutebrowser_proc_pattern}" \ - || "${QUTEBROWSER_BIN}" \ - || exit 0 + ## Start Qutebrowser if needed + ### And exit + start_qutebrowser \ + && exit 0 ## Manage existing instance goto_existing_qutebrowser \