aboutsummaryrefslogtreecommitdiff
path: root/surfraw.sh
blob: 86b4512d32d53ee08ed744558e3cebaf9ad5e050 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#!/bin/sh

# Do stuff using surfraw. Take back internet browsing from evil.

search=$(echo "" | dmenu -p "Search:")
[ -n "$search" ] || exit 0
dunstify "Searching $search"
target="$(ddgr --json "$search" |
	grep -E '"title": |"url": ' |
	sed '/"title": / N;s/\n//g' |
	awk '-F ["]' '{print $3 "[" $5 "]" }' |
	sed 's/"//g;s/,\s*\[/  \[/' |
	dmenu -i -l 10 -p "Target:" |
	awk '-F [[]' '{print $2}' |
	sed 's/]\s*$//')"
dunstify "Trying to play result of $target"
dunstify "Url: $target"
mpv "$target" || qutebrowser "$target" || dunstify "URL not valid."