From 486cf251dbafe1ffa82f699ecf85e03db1f36030 Mon Sep 17 00:00:00 2001 From: Gardouille Date: Wed, 2 Dec 2020 19:24:49 +0100 Subject: [PATCH] Now switch to buffer! --- qb | 46 +++++++++++++++++++++++++++++----------------- 1 file changed, 29 insertions(+), 17 deletions(-) diff --git a/qb b/qb index 67295df..1c6ab46 100755 --- a/qb +++ b/qb @@ -229,7 +229,7 @@ get_qutebrowser_buffers() { # {{{ } # }}} -get_qutebrowser_content() { # {{{ +get_qutebrowser_content() { # {{{ [ -S "${QUTEBROWSER_SOCKET_FILE}" ] && get_qutebrowser_buffers @@ -238,7 +238,7 @@ get_qutebrowser_content() { # {{{ } # }}} -search_qb_content() { # {{{ +search_qb_content() { # {{{ get_qutebrowser_content @@ -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