Focus on new started Qutebrowser

This commit is contained in:
gardouille 2020-12-02 16:51:15 +01:00
parent a552beaf0b
commit 15a129feb4
Signed by: gardouille
GPG Key ID: E759BAA22501AF32
1 changed files with 25 additions and 9 deletions

34
qb
View File

@ -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 \