aboutsummaryrefslogtreecommitdiff
path: root/dotfiles/.local/bin/rofiwebsurf
blob: bcba65fae0dc8c85bcfb496105728183a7cf592f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/bin/bash

if [ "$ROFI_RETV" != 0 ]; then
	choice="$1"
	if echo "$choice" | egrep ".*://.*" >/dev/null 2>&1; then
		choice="$(echo "$choice" | grep -Eo "[^[:space:]]*:\/\/[^[:space:]]*" |
			head -n1 | 
			grep -E "https?:" || echo "$choice")"
		mimeo "$choice" > /dev/null
	else
		setsid $BROWSER "$choice" > /dev/null &
	fi
	exit 0
fi

qmarks="$HOME/.config/qutebrowser/quickmarks"
bmarks="$HOME/.config/qutebrowser/bookmarks/urls"
hist="$HOME/.local/share/qutebrowser/history.sqlite"
prompt="$(sqlite3 -separator ' ' "$hist" \
	'select title, url from CompletionHistory' |
	cat "$qmarks" - | cat "$bmarks" -)"

echo -ne "\0prompt\x1fEnter query or link\n"
printf "%s" "$prompt"