-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathopen-browser
More file actions
executable file
·83 lines (74 loc) · 2.69 KB
/
open-browser
File metadata and controls
executable file
·83 lines (74 loc) · 2.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#!/usr/bin/env bash
#
# ############################################################################
# Project: scripts (none)
# File...: open-browser
# Created: Friday, 2022/02/11 - 21:11:37
# Author.: @fbnmtz, (fabiano.matoz@gmail.com)
# ~·~·~·~·~·~·~·~·~·~·~·~·~~·~·~·~·~·~·~·~·~·~·~·~·~~·~·~·~·~·~~·~·~·~·~·~·~·~
# Last Modified: Monday, 2024/12/09 - 17:40:42
# Modified By..: @fbnmtz, (fabiano.matoz@gmail.com)
# ~·~·~·~·~·~·~·~·~·~·~·~·~~·~·~·~·~·~·~·~·~·~·~·~·~~·~·~·~·~·~~·~·~·~·~·~·~·~
# Version: 0.4.1.369
# ~·~·~·~·~·~·~·~·~·~·~·~·~~·~·~·~·~·~·~·~·~·~·~·~·~~·~·~·~·~·~~·~·~·~·~·~·~·~
# Description:
# >
# ############################################################################
# HISTORY:
#
# Tuesday, 2022/03/15 - 13:11:47: (@fbnmtz)
# -> * new requirement (socat)
# * user input without '-q' option automatic set as query
# * remove one arg requirement
# * add mpv socket to append files/urls in playlist
# * add new sites to open in mpv as default
# ignore some shellcheck expression
# shellcheck disable=SC1091,SC2046,2068
source "$xSHELL_INIT"
use args utils openbrowser.lib
xrequirements rofi grep mpv socat xdotool
xarg --id -b,--browser --var name+r --desc "inform a installed browser to open url/query"
xarg --id -q,--query --var query+r --desc "query to search OR url to open"
# xarg --id -c,--class --var f:c,classname+r --desc "define current x11 classname"
xrun --xversionrc --xcolors "$@"
# user defined browser?
[ -n "$name" ] && BROWSER_RUN=$name
xrequirements "${BROWSER_RUN}"
# no query given by command line?
if [ -z "$query" ]; then
# no user input by first arg?
if [ -z "${_PARAMS_[1]}" ]; then
# ask user input with rofi
query="$(rofi -dmenu -no-config -lines 1 -p "Browser")"
else
# Given input, set param as query
query=${_PARAMS_[1]}
notify-send "open-browser" "open $query"
fi
fi
# query still null?
if [ -z "$query" ]; then
# quit application
exit 1
elif isUrl "$query"; then
# 'query' is a url. so lets get current domain
domain=$(getDomain "$query")
notify-send "$APP" "$domain"
mpv_domains="youtu.be|youtube.com|youtube.com.br|\
*vimeo.com|\
bitchute.com|\
cloudflare.tv\
$customUrls"
_case="case \$domain in
# domains to open with 'mpv'
$mpv_domains) mpv_command "\$query" ;;
# use RID (Reddit Image Downloader)
reddit.com) rid \$query ;;
# other domains open in default browser
*) "\$BROWSER_RUN" "\${query}"
esac"
eval "$_case"
else
# no url given? search this 'query' on browser with default search engine
"$BROWSER_RUN" "${SEARCH_ENGINES[0]}""${query}"
fi