From bd8321258170b9bc40e62e3df57b9308ca1c499b Mon Sep 17 00:00:00 2001 From: Donovan Glover Date: Sat, 30 Jul 2022 10:19:59 -0400 Subject: [PATCH] sxhkd: Add clipboard to browser This makes it easy to search for text without having to worry about browser extensions or even being in the browser itself. --- sxhkd/.config/sxhkd/ctb.sh | 27 +++++++++++++++++++++++++++ sxhkd/.config/sxhkd/sxhkdrc | 14 +++++++++++++- 2 files changed, 40 insertions(+), 1 deletion(-) create mode 100755 sxhkd/.config/sxhkd/ctb.sh diff --git a/sxhkd/.config/sxhkd/ctb.sh b/sxhkd/.config/sxhkd/ctb.sh new file mode 100755 index 0000000..0996375 --- /dev/null +++ b/sxhkd/.config/sxhkd/ctb.sh @@ -0,0 +1,27 @@ +#!/bin/sh +# Clipboard to browser + +CLIPBOARD="$(xclip -o)" +OPEN="/usr/bin/$BROWSER" +URL="" + +if [[ "$1" == "jisho" ]]; then + URL="https://jisho.org/search/$CLIPBOARD" + +elif [[ "$1" == "weblio" ]]; then + URL="https://ejje.weblio.jp/content/$CLIPBOARD" + +elif [[ "$1" == "forvo" ]]; then + # URL="https://forvo.com/search/$CLIPBOARD" + URL="https://forvo.com/word/$CLIPBOARD/#ja" + +elif [[ "$1" == "deepl" ]]; then + URL="https://www.deepl.com/translator#ja/en/$CLIPBOARD" + +elif [[ "$1" == "cambridge" ]]; then + URL="https://dictionary.cambridge.org/dictionary/english/$CLIPBOARD" +fi + +if [[ "$URL" != "" ]]; then + "$OPEN" "$URL" +fi diff --git a/sxhkd/.config/sxhkd/sxhkdrc b/sxhkd/.config/sxhkd/sxhkdrc index e50b53c..dbcb382 100644 --- a/sxhkd/.config/sxhkd/sxhkdrc +++ b/sxhkd/.config/sxhkd/sxhkdrc @@ -128,6 +128,18 @@ super + F11 notify-send -t 2000 "F11" "No command defined." super + F12 - notify-send -t 2000 "F12" "No command defined." + ~/.config/sxhkd/ctb.sh jisho + +super + Home + ~/.config/sxhkd/ctb.sh forvo + +super + End + ~/.config/sxhkd/ctb.sh weblio + +super + Insert + ~/.config/sxhkd/ctb.sh deepl + +super + Delete + ~/.config/sxhkd/ctb.sh cambridge # vim:ft=sxhkdrc