[vimb] Moving from qb to vimb for browsing

This commit is contained in:
2021-02-14 23:32:05 -05:00
parent 2814cccf84
commit 864ce914e4
5 changed files with 44 additions and 23 deletions

View File

@ -43,6 +43,20 @@ gen_list() {
done
}
urlencode() {
# urlencode <string>
local LANG=C
local length="${#1}"
for ((i = 0; i < length; i++)); do
local c="${1:i:1}"
case $c in
[a-zA-Z0-9.~_-]) printf "$c" ;;
*) printf '%%%02X' "'$c" ;;
esac
done
}
main() {
# Pass the list to rofi
platform=$( (gen_list) | rofi -dmenu -matching fuzzy -no-custom -location 0 -p "Search > ")
@ -51,8 +65,8 @@ main() {
query=$( (echo) | rofi -dmenu -matching fuzzy -location 0 -p "Query > ")
if [[ -n "$query" ]]; then
url=${URLS[$platform]}$query
/home/powellc/.asdf/shims/qutebrowser ":open -w $url"
URL=${URLS[$platform]}$(urlencode "$query")
/usr/local/bin/vimb $URL
else
exit
fi

View File

@ -5,23 +5,21 @@ OPTS=-u "$AGENT" -z 1.1
#OPTS="-z 1.5"
HISTORY=~/var/rofi-www-history
if [ "$1" = "" ]
then
URL=`cat $HISTORY | rofi -hide-scrollbar -dmenu -p "URL: "`
echo "$URL" | grep -e ^http || CLIP=https://$CLIP
echo "$URL" >> $HISTORY
if [ "$1" = "" ]; then
URL=$(cat $HISTORY | rofi -hide-scrollbar -dmenu -p "URL: ")
echo "$URL" | grep -e ^http || CLIP=https://$CLIP
echo "$URL" >>$HISTORY
else
URL=$@
echo "$@" | grep -e ^http && CLIP=https://$CLIP
echo "$@" >> $HISTORY
URL=$@
echo "$@" | grep -e ^http && CLIP=https://$CLIP
echo "$@" >>$HISTORY
fi
TMP=`tempfile`
cat $HISTORY | sort | uniq >> $TMP && mv $TMP $HISTORY
rm -f $TMP
TMP=$(tempfile)
cat $HISTORY | sort | uniq >>$TMP && mv $TMP $HISTORY
rm -f $TMP
if [ "$URL" = "" ]
then
exit 0
if [ "$URL" = "" ]; then
exit 0
fi
/home/powellc/.asdf/shims/qutebrowser ":open -w $URL"
/usr/local/bin/vimb "$URL"