mirror of
https://github.com/LukeSmithxyz/voidrice.git
synced 2026-03-20 01:37:45 +01:00
27 lines
1.7 KiB
Bash
Executable File
27 lines
1.7 KiB
Bash
Executable File
#!/bin/sh
|
|
# Dependencies are xclip and xorg-xprop.
|
|
# qrencode required for qrcode generation.
|
|
# groff/zathura required for man pages.
|
|
prim="$(xclip -o)"; [ -z "$prim" ] && exit
|
|
|
|
PID=$(xprop -id "$(xprop -root | awk '/_NET_ACTIVE_WINDOW\(WINDOW\)/{print $NF}')" | grep -m 1 PID | cut -d " " -f 3)
|
|
PID=$(echo "$(pstree -lpA "$PID" | tail -n 1)" | awk -F'---' '{print $NF}' | sed -re 's/[^0-9]//g')
|
|
cd "$(readlink /proc/"$PID"/cwd)"
|
|
[ -f "$prim" ] && xdg-open "$prim" && exit
|
|
[ -d "$prim" ] && "$TERMINAL" "$prim" && exit
|
|
|
|
x="websearch" && funcs="$funcs\n$x" && eval "${x}() { \"$BROWSER\" \"https://duckduckgo.com/?q=\$@\" ;}"
|
|
x="wikipedia" && funcs="$funcs\n$x" && eval "${x}() { \"$BROWSER\" \"https://en.wikipedia.org/wiki/\$@\" ;}"
|
|
x="wiktionary" && funcs="$funcs\n$x" && eval "${x}() { \"$BROWSER\" \"https://en.wiktionary.org/wiki/\$@\" ;}"
|
|
x="maps" && funcs="$funcs\n$x" && eval "${x}() { \"$BROWSER\" \"https://www.openstreetmap.org/search?query=\$@\" ;}"
|
|
x="ebay" && funcs="$funcs\n$x" && eval "${x}() { \"$BROWSER\" \"https://www.ebay.com/sch/\$@\" ;}"
|
|
|
|
echo "$prim" | grep "^.*\.[A-Za-z]\+.*" >/dev/null && x="gotourl" && funcs="$funcs\n$x" && eval "${x}() { \"$BROWSER\" \"\$@\" ;}"
|
|
echo "$prim" | grep "^.*@.*\.[A-Za-z]\+$" >/dev/null && x="email" && funcs="$funcs\n$x" && eval "${x}() { xdg-email \"\$@\" ;}"
|
|
command -v qrencode >/dev/null && x="qrcode" && funcs="$funcs\n$x" && eval "${x}() { qrencode \"\$@\" -s 10 -o /tmp/qr.png && xdg-open /tmp/qr.png ;}"
|
|
man -k "^$prim$" >/dev/null && x="manual" && funcs="$funcs\n$x" && eval "${x}() { man -Tpdf \"\$prim\" | zathura - ;}"
|
|
|
|
func="$(echo -e $funcs | tail -n +2 | dmenu -p "Plumb \"$(echo "$prim" | cut -c -30)\" to?" -i -l 15)"
|
|
|
|
[ -z "$func" ] || "$func" "$prim"
|