diff options
| author | LM-LCL <hello@exaltedelite.club> | 2023-08-30 14:15:03 +0200 |
|---|---|---|
| committer | LM-LCL <hello@exaltedelite.club> | 2023-08-30 14:15:03 +0200 |
| commit | 7cfd731f4abba79af6ddfe3dbd3e6341af665f87 (patch) | |
| tree | cf526647ef233d575b0b97a6352b9b699a597a5a | |
| parent | 289a83c3b6f7e067ca8894283dcd953f69fb75a3 (diff) | |
mouse zoom enabled
| -rw-r--r-- | config.h | 10 | ||||
| -rwxr-xr-x | st-copyout | 8 | ||||
| -rwxr-xr-x | st-urlhandler | 20 |
3 files changed, 15 insertions, 23 deletions
@@ -191,6 +191,8 @@ static MouseShortcut mshortcuts[] = { /* mask button function argument release */ { XK_NO_MOD, Button4, kscrollup, {.i = 2} }, { XK_NO_MOD, Button5, kscrolldown, {.i = 2} }, + { ControlMask, Button4, zoom, {.f = +1} }, + { ControlMask, Button5, zoom, {.f = -1} }, { XK_ANY_MOD, Button2, selpaste, {.i = 0}, 1 }, { ShiftMask, Button4, ttysend, {.s = "\033[5;2~"} }, { XK_ANY_MOD, Button4, ttysend, {.s = "\031"} }, @@ -202,8 +204,7 @@ static MouseShortcut mshortcuts[] = { #define MODKEY Mod4Mask #define TERMMOD (ControlMask|ShiftMask) -static char *openurlcmd[] = { "/bin/sh", "-c", "st-urlhandler -o", "externalpipe", NULL }; -static char *copyurlcmd[] = { "/bin/sh", "-c", "st-urlhandler -c", "externalpipe", NULL }; +static char *copyurlcmd[] = { "/bin/sh", "-c", "st-urlhandler", "externalpipe", NULL }; static char *copyoutput[] = { "/bin/sh", "-c", "st-copyout", "externalpipe", NULL }; static Shortcut shortcuts[] = { @@ -220,9 +221,8 @@ static Shortcut shortcuts[] = { { TERMMOD, XK_Left, zoom, {.f = -1} }, { TERMMOD, XK_L, zoom, {.f = +1} }, { TERMMOD, XK_H, zoom, {.f = -1} }, - { MODKEY, XK_y, externalpipe, {.v = copyurlcmd } }, - { MODKEY, XK_o, externalpipe, {.v = openurlcmd } }, - { MODKEY, XK_p, externalpipe, {.v = copyoutput } }, + { MODKEY, XK_o, externalpipe, {.v = copyoutput } }, + { MODKEY, XK_p, externalpipe, {.v = copyurlcmd } }, }; /* @@ -4,7 +4,7 @@ tmpfile=$(mktemp /tmp/st-cmd-output.XXXXXX) trap 'rm "$tmpfile"' 0 1 15 sed -n "w $tmpfile" sed -i 's/\x0//g' "$tmpfile" -ps1="$(grep "\S" "$tmpfile" | tail -n 1 | sed 's/^\s*//' | cut -d' ' -f1)" -chosen="$(grep -F "$ps1" "$tmpfile" | sed '$ d' | tac | dmenu -p 'Select Command' -i -l 10 | sed 's/[^^]/[&]/g; s/\^/\\^/g')" -eps1="$(echo "$ps1" | sed 's/[^^]/[&]/g; s/\^/\\^/g')" -awk "/^$chosen$/{p=1;print;next} p&&/$eps1/{p=0};p" "$tmpfile" | xclip -sel c +data="$(tac "$tmpfile")" +[ ! -z "$data" ] && printf "%s" "$data" | dmenu -i -l 15 -p 'Select Line' \ + | xargs \ + | xclip -r -sel c diff --git a/st-urlhandler b/st-urlhandler index 5b3f71e..1ed2b23 100755 --- a/st-urlhandler +++ b/st-urlhandler @@ -2,18 +2,10 @@ urlregex="(((http|https|gopher|gemini|ftp|ftps|git)://|www\\.)[a-zA-Z0-9.]*[:;a-zA-Z0-9./+@$&%?$\#=_~-]*)|((magnet:\\?xt=urn:btih:)[a-zA-Z0-9]*)" -urls="$(sed 's/.*│//g' | tr -d '\n' | # First remove linebreaks and mutt sidebars: - grep -aEo "$urlregex" | # grep only urls as defined above. - uniq | # Ignore neighboring duplicates. - sed "s/\(\.\|,\|;\|\!\\|\?\)$//; - s/^www./http:\/\/www\./")" # xdg-open will not detect url without http +urls="$(sed 's/.*│//g' | tr -d '\n' \ + | grep -aEo "$urlregex" \ + | uniq \ + | sed "s/\(\.\|,\|;\|\!\\|\?\)$//;s/^www./http:\/\/www\./")" -[ -z "$urls" ] && exit 1 - -while getopts "hoc" o; do case "${o}" in - h) printf "Optional arguments for custom use:\\n -c: copy\\n -o: xdg-open\\n -h: Show this message\\n" && exit 1 ;; - o) chosen="$(echo "$urls" | dmenu -i -p 'Select URL' -l 10)" - setsid xdg-open "$chosen" >/dev/null 2>&1 & ;; - c) echo "$urls" | dmenu -i -p 'Select URL' -l 10 | tr -d '\n' | xclip -sel c ;; - *) printf "Invalid option: -%s\\n" "$OPTARG" && exit 1 ;; -esac done +[ ! -z "$urls" ] && echo "$urls" | dmenu -i -l 15 -p 'Select URL' \ + | xclip -r -sel c |
