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}")
debug_message "open_in_qutebrowser \
return_get_url="1"
debug_message "get_url \
Try to manage ${RED}$(cat "${choice_temp_file}")${COLOR_DEBUG}."
case "${local_content}" in
http* ) ## Classic bookmark
local_url=$(printf "%s" "${local_content}" | sed -e "s;\(http.*\) .*;\1;")
debug_message "open_in_qutebrowser \
Try to open classic bookmark URL ${RED}${local_url}${COLOR_DEBUG}."
url=$(printf "%s" "${local_content}" | sed -e "s;\(http.*\) .*;\1;")
return_get_url="0"
debug_message "get_url \
URL from classic bookmark ${RED}${url}${COLOR_DEBUG}."
;;
*http* ) ## Quickmark
local_url=$(printf "%s" "${local_content}" | sed -e "s;.*\(http.*\);\1;")
debug_message "open_in_qutebrowser \
Try to open quickbookmark URL ${RED}${local_url}${COLOR_DEBUG}."
url=$(printf "%s" "${local_content}" | sed -e "s;.*\(http.*\);\1;")
return_get_url="0"
debug_message "get_url \
URL from quickmark ${RED}${url}${COLOR_DEBUG}."
;;
* )
debug_message "open_in_qutebrowser \
Not yet managed."
debug_message "get_url \
Content not yet managed."
;;
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
search_qb_bookmark \
&& get_url \
&& open_in_qutebrowser
return 0