diff options
-rw-r--r-- | dotfiles/.config/sway/config | 3 | ||||
-rwxr-xr-x | dotfiles/.local/bin/linkhandler | 9 | ||||
-rwxr-xr-x | dotfiles/.local/bin/menuducksearch | 16 | ||||
-rwxr-xr-x | dotfiles/.local/bin/menuwebsurf | 23 |
4 files changed, 30 insertions, 21 deletions
diff --git a/dotfiles/.config/sway/config b/dotfiles/.config/sway/config index 829c756..6c6d6b7 100644 --- a/dotfiles/.config/sway/config +++ b/dotfiles/.config/sway/config @@ -192,7 +192,8 @@ bindsym --to-code { $mod+o exec --no-startup-id notistats $mod+c exec --no-startup-id camtoggle $mod+grave exec --no-startup-id menuemoji - $mod+Shift+grave exec --no-startup-id menuducksearch + $mod+Ctrl+grave exec --no-startup-id menuwebsurf + $mod+Shift+grave exec --no-startup-id menuwebsurf paste # $mod+F1 exec --no-startup-id zathura ~/.config/i3/i3guide.pdf # TODO: update guide # Network management 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 + |