Specific function to get the choosen URL

This commit is contained in:
Jeremy Gardais 2020-12-02 17:31:02 +01:00
parent 4ab2928f82
commit 18d39a2834
Signed by: jegardai
GPG Key ID: E759BAA22501AF32
1 changed files with 25 additions and 11 deletions

36
qb
View File

@ -218,31 +218,44 @@ Search aborded or can't find matching bookmark."
} }
# }}} # }}}
open_in_qutebrowser() { # {{{ get_url() { # {{{
local_content=$(cat "${choice_temp_file}") local_content=$(cat "${choice_temp_file}")
debug_message "open_in_qutebrowser \ return_get_url="1"
debug_message "get_url \
Try to manage ${RED}$(cat "${choice_temp_file}")${COLOR_DEBUG}." Try to manage ${RED}$(cat "${choice_temp_file}")${COLOR_DEBUG}."
case "${local_content}" in case "${local_content}" in
http* ) ## Classic bookmark http* ) ## Classic bookmark
local_url=$(printf "%s" "${local_content}" | sed -e "s;\(http.*\) .*;\1;") url=$(printf "%s" "${local_content}" | sed -e "s;\(http.*\) .*;\1;")
debug_message "open_in_qutebrowser \ return_get_url="0"
Try to open classic bookmark URL ${RED}${local_url}${COLOR_DEBUG}." debug_message "get_url \
URL from classic bookmark ${RED}${url}${COLOR_DEBUG}."
;; ;;
*http* ) ## Quickmark *http* ) ## Quickmark
local_url=$(printf "%s" "${local_content}" | sed -e "s;.*\(http.*\);\1;") url=$(printf "%s" "${local_content}" | sed -e "s;.*\(http.*\);\1;")
debug_message "open_in_qutebrowser \ return_get_url="0"
Try to open quickbookmark URL ${RED}${local_url}${COLOR_DEBUG}." debug_message "get_url \
URL from quickmark ${RED}${url}${COLOR_DEBUG}."
;; ;;
* ) * )
debug_message "open_in_qutebrowser \ debug_message "get_url \
Not yet managed." Content not yet managed."
;; ;;
esac esac
~/src/qutebrowser-venv/bin/python3 -m qutebrowser "${local_url}" return "${return_get_url}"
}
# }}}
open_in_qutebrowser() { # {{{
debug_message "open_in_qutebrowser \
Try to open ${RED}${url}${COLOR_DEBUG}"
sh -c "${QUTEBROWSER_BIN} ${url}"
} }
# }}} # }}}
@ -253,6 +266,7 @@ Try to open content in existing instance."
## Try to open Qutebrowser content ## Try to open Qutebrowser content
search_qb_bookmark \ search_qb_bookmark \
&& get_url \
&& open_in_qutebrowser && open_in_qutebrowser
return 0 return 0