Focus on new started Qutebrowser

This commit is contained in:
Jeremy Gardais 2020-12-02 16:51:15 +01:00
parent a552beaf0b
commit 15a129feb4
Signed by: jegardai
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 \ debug_message "goto_existing_qutebrowser \
Try to open content in existing instance." Try to open content in existing instance."
## Focus to Qutebrowser window
focus_to_qutebrowser
## Try to open Qutebrowser content ## Try to open Qutebrowser content
search_qb_bookmark \ search_qb_bookmark \
&& open_in_qutebrowser && open_in_qutebrowser
@ -207,6 +204,27 @@ Search aborded or can't find matching bookmark."
return "${local_search_qb_bookmark_return}" 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() { # {{{ open_in_qutebrowser() { # {{{
@ -248,12 +266,10 @@ main() { # {{{
get_qutebrowser_bin \ get_qutebrowser_bin \
|| error_message "Can't find a working qutebrowser binary." "1" || error_message "Can't find a working qutebrowser binary." "1"
## If nothing related to Qutebrowser is currently running ## Start Qutebrowser if needed
### Try to start qutebrowser ### And exit
### Then exit with success start_qutebrowser \
is_proc_running "${qutebrowser_proc_pattern}" \ && exit 0
|| "${QUTEBROWSER_BIN}" \
|| exit 0
## Manage existing instance ## Manage existing instance
goto_existing_qutebrowser \ goto_existing_qutebrowser \