diff --git a/nbrowser b/nbrowser index 557c4a9..d7c0aa9 100644 --- a/nbrowser +++ b/nbrowser @@ -2,7 +2,7 @@ # nbrowser v0.2 # author : odnar-dev # source : https://github.com/MyOS-ArchLinux/nbrowser -# license: GPLv3+ +# license: GPLv3 # shellcheck disable=SC2190,SC2086,SC1091 NBROWSER_CONFIG_DIR="${XDG_CONFIG_HOME:-$HOME/.config}/nbrowser" @@ -10,21 +10,20 @@ NBROWSER_DEFAULT_SEARCH=${NBROWSER_DEFAULT_SEARCH:-duckduckgo} declare -A ENGINES -ENGINES+=(["duckduckgo"]="https://duckduckgo.com/?q=") -ENGINES+=(["ddg"]="https://duckduckgo.com/?q=") -ENGINES+=(["google"]="https://www.google.com/search?q=") -ENGINES+=(["startpage"]="https://www.startpage.com/do/search?query=") - -ENGINES+=(["archwiki"]="https://wiki.archlinux.org/index.php?title=Special:Search&search=") -ENGINES+=(["aur"]="https://aur.archlinux.org/packages/?O=0&SeB=nd&outdated=&SB=n&SO=a&PP=50&do_Search=Go&K=") - -ENGINES+=(["git"]="https://github.com/search?q=") -ENGINES+=(["github"]="https://github.com/search?q=") - -ENGINES+=(["mal"]="https://myanimelist.net/search/all?q=") -ENGINES+=(["imdb"]="https://www.imdb.com/find?q=") -ENGINES+=(["tmdb"]="https://www.themoviedb.org/search?query=") -ENGINES+=(["tvdb"]="https://www.thetvdb.com/search?query=") +ENGINES=( + ["google"]="https://www.google.com/search?q=" + ["duckduckgo"]="https://duckduckgo.com/?q=" + ["ddg"]="https://duckduckgo.com/?q=" + ["startpage"]="https://www.startpage.com/do/search?query=" + ["archwiki"]="https://wiki.archlinux.org/index.php?title=Special:Search&search=" + ["aur"]="https://aur.archlinux.org/packages/?O=0&SeB=nd&outdated=&SB=n&SO=a&PP=50&do_Search=Go&K=" + ["github"]="https://github.com/search?q=" + ["git"]="https://github.com/search?q=" + ["imdb"]="https://www.imdb.com/find?q=" + ["tmdb"]="https://www.themoviedb.org/search?query=" + ["tvdb"]="https://www.thetvdb.com/search?query=" + ["mal"]="https://myanimelist.net/search/all?q=" +) has() { case "$(command -v "$1" 2>/dev/null)" in @@ -135,7 +134,6 @@ open_a_browser(){ { setsid -f ${selected_browser} >/dev/null 2>&1 ; } ;; esac - } open_video_with(){ @@ -143,24 +141,31 @@ open_video_with(){ case "$selected_action" in "Play") - if has 'play' ; then - { setsid -f play "play://$*" >/dev/null 2>&1 ; } - else + if [ -n "${NBROWSER_PLAYER}" ] ; then + { setsid -f ${NBROWSER_PLAYER} "$*" >/dev/null 2>&1 ; } + elif has 'mpv'; then { setsid -f mpv "$*" >/dev/null 2>&1 ; } + elif has 'vlc'; then + { setsid -f vlc "$*" >/dev/null 2>&1 ; } + else + _pemx "mpv is not installed in your system!" fi ;; "Download") - if has 'dwld' ; then - { setsid -f dwld "dwld://$*" >/dev/null 2>&1 ; } + if [ -n "${NBROWSER_DOWNLOADER}" ] ; then + { setsid -f ${NBROWSER_DOWNLOADER} "$*" >/dev/null 2>&1 ; } + elif has 'youtube-dl'; then + { setsid -f "${TERMINAL:-st}" -e sh -c "youtube-dl $* || read" >/dev/null 2>&1 ; } + elif has 'yt-dlp'; then + { setsid -f "${TERMINAL:-st}" -e sh -c "yt-dlp $* || read" >/dev/null 2>&1 ; } else - { setsid -f "${TERMINAL:-st}" -e sh -c "youtube-dl $*" >/dev/null 2>&1 ; } + _pemx "youtube-dl is not installed in your system!" fi ;; "Open in Browser") open_in_browser "$1" ;; esac - } open_picture_with(){ @@ -168,25 +173,26 @@ open_picture_with(){ case "$selected_action" in "View") - if has 'sxiv' ; then + if has 'sxiv'; then curl -sL "$1" > "/tmp/$(echo "$@" | sed "s/.*\///;s/%20/ /g")" && \ { setsid -f sxiv -a "/tmp/$(echo "$@" | sed "s/.*\///;s/%20/ /g")" >/dev/null 2>&1 ; } + elif has 'feh'; then + { setsid -f feh "$*" >/dev/null 2>&1 ; } else - _pemx "sxiv is no installed in your system!" + _pemx "sxiv is not installed in your system!" fi ;; "Edit with Gimp") - if has 'gimp' ; then + if has 'gimp'; then { setsid -f gimp "$*" >/dev/null 2>&1 ; } else - _pemx "gimp is no installed in your system!" + _pemx "gimp is not installed in your system!" fi ;; "Open in Browser") open_in_browser "$1" ;; esac - } open_in_browser(){ @@ -211,7 +217,6 @@ open_in_browser(){ { setsid -f $selected_browser "$*" >/dev/null 2>&1 ; } ;; esac - } url_handler(){ @@ -296,7 +301,7 @@ main(){ # handle local pdf [ -z "$NBROWSER_PDF_VIEWER" ] || installed_browsers[0]="PDF Reader : ${NBROWSER_PDF_VIEWER}" ;; - *.html) + *.html) # handle local html [ -z "$NBROWSER_HTML_EDITOR" ] || installed_browsers[0]="Text Editor : ${NBROWSER_HTML_EDITOR}" esac