Focus improvment (better detection of buffer title)
This commit is contained in:
parent
486cf251db
commit
096c505479
19
qb
19
qb
|
@ -67,9 +67,12 @@ define_vars() { # {{{
|
|||
QUTEBROWSER_GLOBAL_CONTENT="/tmp/qutebrowser_global_content"
|
||||
rm -f -- "${QUTEBROWSER_GLOBAL_CONTENT}" ; touch "${QUTEBROWSER_GLOBAL_CONTENT}"
|
||||
|
||||
## Variables to get Qutebrowser *marks from current user
|
||||
QUTEBROWSER_QUICKMARK_FILE="${HOME}/.config/qutebrowser/quickmarks"
|
||||
QUTEBROWSER_BOOKMARK_FILE="${HOME}/.config/qutebrowser/bookmarks/urls"
|
||||
|
||||
## Default window pattern to search
|
||||
QUTEBROWSER_WINDOW_TITLE="qutebrowser"
|
||||
}
|
||||
# }}}
|
||||
debug_message() { # {{{
|
||||
|
@ -183,9 +186,6 @@ No existing instance of Qutebrowser. Starting…" >> /tmp/qb.log
|
|||
return_start_qutebrowser="0"
|
||||
fi
|
||||
|
||||
## In any case, be sure to focus to Qutebrowser
|
||||
focus_to_qutebrowser
|
||||
|
||||
return "${return_start_qutebrowser}"
|
||||
|
||||
}
|
||||
|
@ -193,8 +193,8 @@ No existing instance of Qutebrowser. Starting…" >> /tmp/qb.log
|
|||
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)
|
||||
qutebrowser_desktop_id=$(command wmctrl -l | grep --max-count=1 -E -- "${QUTEBROWSER_WINDOW_TITLE}" | cut -d" " -f3)
|
||||
qutebrowser_window_id=$(command wmctrl -l | grep --max-count=1 -E -- "${QUTEBROWSER_WINDOW_TITLE}" | 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}."
|
||||
|
@ -279,6 +279,9 @@ Try to switch to buffer id: ${buffer_id}."
|
|||
echo "{\"args\":[\":buffer ${buffer_id}\"], \"target_arg\":\"\", \"protocol_version\":1}" |\
|
||||
socat - UNIX-CONNECT:"${QUTEBROWSER_SOCKET_FILE}"
|
||||
|
||||
## Ensure to focus on expected buffer
|
||||
QUTEBROWSER_WINDOW_TITLE="${buffer_title}"
|
||||
|
||||
}
|
||||
# }}}
|
||||
get_url() { # {{{
|
||||
|
@ -307,9 +310,10 @@ URL from quickmark ${RED}${url}${COLOR_DEBUG}."
|
|||
;;
|
||||
ff* ) ## Buffer
|
||||
buffer_id=$(printf "%s" "${local_content}" | cut -d" " -f2)
|
||||
buffer_title=$(printf "%s" "${local_content}" | sed "s;ff ${buffer_id} \(.*\) PyQt5.QtCore.QUrl.*;\1;")
|
||||
return_get_url="0"
|
||||
debug_message "get_url − \
|
||||
Buffer from Qutebrowser ${buffer_id}."
|
||||
Buffer title from Qutebrowser: ${RED}${buffer_title}${COLOR_DEBUG}."
|
||||
switch_qutebrowser_buffer
|
||||
;;
|
||||
* )
|
||||
|
@ -331,6 +335,9 @@ Try to open content in existing instance."
|
|||
search_qb_content \
|
||||
&& get_url
|
||||
|
||||
## Be sure to focus to the expected buffer
|
||||
focus_to_qutebrowser
|
||||
|
||||
return 0
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue