From 69204c648abbd4463b6a1e3b6cbb67a394842379 Mon Sep 17 00:00:00 2001 From: Yaroslav Date: Sat, 4 Apr 2020 22:15:21 +0300 Subject: new menu script for opening different links with different programs (or performing a search) --- dotfiles/.local/bin/linkhandler | 9 +++++---- dotfiles/.local/bin/menuducksearch | 16 ---------------- dotfiles/.local/bin/menuwebsurf | 23 +++++++++++++++++++++++ 3 files changed, 28 insertions(+), 20 deletions(-) delete mode 100755 dotfiles/.local/bin/menuducksearch create mode 100755 dotfiles/.local/bin/menuwebsurf (limited to 'dotfiles/.local') diff --git a/dotfiles/.local/bin/linkhandler b/dotfiles/.local/bin/linkhandler index c616d04..338750d 100755 --- a/dotfiles/.local/bin/linkhandler +++ b/dotfiles/.local/bin/linkhandler @@ -6,7 +6,7 @@ # if a music file or pdf, it will download, # otherwise it opens link in browser. -# If no url given. Opens browser. For using script as $BROWSER. +# If no url given opens browser. [ -z "$1" ] && { "$BROWSER"; exit; } case "$1" in @@ -16,7 +16,8 @@ case "$1" in curl -sL "$1" > "/tmp/$(echo "$1" | sed "s/.*\///")" && sxiv -a "/tmp/$(echo "$1" | sed "s/.*\///")" >/dev/null 2>&1 & ;; *mp3|*flac|*opus|*mp3?source*) setsid tsp curl -LO "$1" >/dev/null 2>&1 & ;; - *) - if [ -f "$1" ]; then "$TERMINAL" -e "$EDITOR $1" - else setsid "$BROWSER" "$1" >/dev/null 2>&1 & fi ;; + *://*|*.*) + setsid "$BROWSER" "$1" >/dev/null 2>&1 & ;; + *) # If it's not a url, perform a search using duckduckgo + setsid "$BROWSER" "https://duckduckgo.com/?q=$1&t=ffab&atb=v1-1" >/dev/null 2>&1 & ;; esac diff --git a/dotfiles/.local/bin/menuducksearch b/dotfiles/.local/bin/menuducksearch deleted file mode 100755 index 54242b1..0000000 --- a/dotfiles/.local/bin/menuducksearch +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/sh - -# Gives a dmenu prompt to search DuckDuckGo. -# Without input, will open DuckDuckGo.com. -# Anything else, it search it. - -# Source settings from .bemenurc -. ~/.config/bemenurc - -choice=$(echo "" | bemenu -i -p "Search DuckDuckGo:" --tf="$BEMENU_TF" --tb="$BEMENU_NB" --fb="$BEMENU_NB" --fn="$BEMENU_FN" --nb="$BEMENU_NB" --nf="$BEMENU_NF" --hf="$BEMENU_HF" --hb="$BEMENU_HB") || exit 1 - -if [ "$choice" = "" ]; then - $BROWSER "https://duckduckgo.com" -else - $BROWSER "https://duckduckgo.com/?q=$choice&t=ffab&atb=v1-1" -fi diff --git a/dotfiles/.local/bin/menuwebsurf b/dotfiles/.local/bin/menuwebsurf new file mode 100755 index 0000000..7c59e3e --- /dev/null +++ b/dotfiles/.local/bin/menuwebsurf @@ -0,0 +1,23 @@ +#!/bin/sh + +# menu prompt to open a link or search with duckduckgo if it's +# not a url + +# Source settings from .bemenurc +. ~/.config/bemenurc + +prompt="🌐" + +# Have to use this "hack" because bemenu doesn't know how to paste +if [ "$1" = "paste" ]; then + prompt="$(wl-paste)" +fi + +choice=$(echo "$prompt" | bemenu -i -p "Enter link or query:" --tf="$BEMENU_TF" --tb="$BEMENU_NB" --fb="$BEMENU_NB" --fn="$BEMENU_FN" --nb="$BEMENU_NB" --nf="$BEMENU_NF" --hf="$BEMENU_HF" --hb="$BEMENU_HB") || exit 1 + +if [ "$choice" = "🌐" ]; then + linkhandler +else + linkhandler "$choice" +fi + -- cgit v1.2.3