others/xselgo.sh

26 lines
802 B
Bash
Raw Permalink Normal View History

2023-05-04 07:10:19 +02:00
#!/bin/sh
2024-01-21 04:09:33 +01:00
## open web browser with the content of x selection ##
2024-02-26 05:30:45 +01:00
# xselgo.sh by @root_informatica.
2023-05-04 07:10:19 +02:00
2024-01-21 04:09:33 +01:00
. $HOME/.config/wms/wms_var
2023-05-04 07:10:19 +02:00
2024-01-21 04:09:33 +01:00
COLORS="-menu-background-color 0x$BC \
2023-05-04 07:10:19 +02:00
-menu-foreground-color 0x$AC \
-scroll-bar-bar-color 0x$AC \
2024-01-21 04:09:33 +01:00
-scroll-bar-frame-color 0x$IC \
-html-g-background-color 0x$BC
"
2024-01-22 13:14:02 +01:00
# browser and selection.
2023-08-04 20:22:54 +02:00
BROWSER="links -g $COLORS"
2024-02-12 04:50:35 +01:00
XSEL=$(xclip -selection clipboard -o)
2023-05-04 07:10:19 +02:00
2024-01-22 13:14:02 +01:00
# 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 \
2023-05-04 07:10:19 +02:00
|| $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))
2023-05-27 06:16:58 +02:00
# with xclip: XSEL=$(xclip -o)