Now switch to buffer!

This commit is contained in:
Jeremy Gardais 2020-12-02 19:24:49 +01:00
parent 56f3abd860
commit 486cf251db
Signed by: jegardai
GPG Key ID: E759BAA22501AF32
1 changed files with 29 additions and 17 deletions

42
qb
View File

@ -260,6 +260,25 @@ Search aborded or can't find matching bookmark."
return "${return_search_qb_content}"
}
# }}}
open_in_qutebrowser() { # {{{
debug_message "open_in_qutebrowser \
Try to open ${RED}${url}${COLOR_DEBUG}"
sh -c "${QUTEBROWSER_BIN} ${url}"
}
# }}}
switch_qutebrowser_buffer() { # {{{
debug_message "switch_qutebrowser_buffer \
Try to switch to buffer id: ${buffer_id}."
echo "{\"args\":[\":buffer ${buffer_id}\"], \"target_arg\":\"\", \"protocol_version\":1}" |\
socat - UNIX-CONNECT:"${QUTEBROWSER_SOCKET_FILE}"
}
# }}}
get_url() { # {{{
@ -277,18 +296,21 @@ Try to manage ${RED}$(cat "${choice_temp_file}")${COLOR_DEBUG}."
return_get_url="0"
debug_message "get_url \
URL from classic bookmark ${RED}${url}${COLOR_DEBUG}."
open_in_qutebrowser
;;
qq*http* ) ## Quickmark
url=$(printf "%s" "${local_content}" | sed -e "s;qq .*\(http.*\);\1;")
return_get_url="0"
debug_message "get_url \
URL from quickmark ${RED}${url}${COLOR_DEBUG}."
open_in_qutebrowser
;;
ff*http ) ## Buffer
url=""
return_get_url="1"
ff* ) ## Buffer
buffer_id=$(printf "%s" "${local_content}" | cut -d" " -f2)
return_get_url="0"
debug_message "get_url \
Buffer not yet managed."
Buffer from Qutebrowser ${buffer_id}."
switch_qutebrowser_buffer
;;
* )
debug_message "get_url \
@ -298,15 +320,6 @@ Content not yet managed."
return "${return_get_url}"
}
# }}}
open_in_qutebrowser() { # {{{
debug_message "open_in_qutebrowser \
Try to open ${RED}${url}${COLOR_DEBUG}"
sh -c "${QUTEBROWSER_BIN} ${url}"
}
# }}}
goto_existing_qutebrowser() { # {{{
@ -316,8 +329,7 @@ Try to open content in existing instance."
## Try to open Qutebrowser content
search_qb_content \
&& get_url \
&& open_in_qutebrowser
&& get_url
return 0