others/xselgo.sh

26 lines
802 B
Bash
Executable File

#!/bin/sh
## open web browser with the content of x selection ##
# xselgo.sh by @root_informatica.
. $HOME/.config/wms/wms_var
COLORS="-menu-background-color 0x$BC \
-menu-foreground-color 0x$AC \
-scroll-bar-bar-color 0x$AC \
-scroll-bar-frame-color 0x$IC \
-html-g-background-color 0x$BC
"
# browser and selection.
BROWSER="links -g $COLORS"
XSEL=$(xclip -selection clipboard -o)
# check if the selection is a url. If it is, open it. If not, search for results on the internet.
printf "$XSEL" | grep -Eq "^https://|^http://|^www." && $BROWSER $XSEL \
|| $BROWSER "https://duckduckgo.com/?q=$XSEL"
## xselection ##
# under xprop: XSEL=$(xprop -root | awk -F "=" '/CUT_BUFFER0/ {gsub("\"","",$2); print $2}')
# under wmutils: XSEL=$(atomx CUT_BUFFER0 $(lsw -r))
# with xclip: XSEL=$(xclip -o)