Focus to Qutebrowser window

This commit is contained in:
gardouille 2020-12-02 16:35:28 +01:00
parent 14c06c8b87
commit a552beaf0b
Signed by: gardouille
GPG Key ID: E759BAA22501AF32
1 changed files with 23 additions and 1 deletions

24
qb
View File

@ -154,6 +154,21 @@ Qutebrowser from ${RED}git repository${COLOR_DEBUG} not selected or can't be use
return "${local_get_qutebrowser_bin_return}"
}
# }}}
focus_to_qutebrowser() { # {{{
## Get desktop and window ID of the first "qutebrowser" window
qutebrowser_desktop_id=$(command wmctrl -l | grep --max-count=1 "qutebrowser" | cut -d" " -f3)
qutebrowser_window_id=$(command wmctrl -l | grep --max-count=1 "qutebrowser" | cut -d" " -f1)
debug_message "focus_to_qutebrowser \
Qutebrowser window ID: ${RED}${qutebrowser_window_id}${COLOR_DEBUG} on desktop ID: ${RED}${qutebrowser_desktop_id}${COLOR_DEBUG}."
## Switch to Qutebrowser desktop and first window
command wmctrl -s "${qutebrowser_desktop_id}"
command wmctrl -i -R "${qutebrowser_window_id}"
}
# }}}
goto_existing_qutebrowser() { # {{{
@ -161,9 +176,15 @@ 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
return 0
}
# }}}
search_qb_bookmark() { # {{{
@ -235,7 +256,8 @@ main() { # {{{
|| exit 0
## Manage existing instance
goto_existing_qutebrowser
goto_existing_qutebrowser \
&& exit 0
}
# }}}