diff --git a/README.md b/README.md new file mode 100644 index 0000000..d588dc0 --- /dev/null +++ b/README.md @@ -0,0 +1,7 @@ +## st + +My build of st + +NOTE: Scripts (by default) require [spmenu](https://codeberg.org/speedie/spmenu) + +TODO: Write decent documentation for this. diff --git a/scripts/st_buffer b/scripts/st_buffer index 39c3e78..d43bdce 100755 --- a/scripts/st_buffer +++ b/scripts/st_buffer @@ -2,6 +2,8 @@ # externalpipe_buffer.sh: use with surf/st externalpipe-signal patches # Input Usage: echo st or surf content from externalpipe | ./externalpipe_buffer.sh {st,surf}_strings_read # Menus Usage: ./externalpipe_buffer.sh dmenu_{copy, type} + +[ -z "$RUNLAUNCHER" ] && RUNLAUNCHER=spmenu BUFFER_FILE=/tmp/content_buffer function st_strings_read() { INPUT="$(cat)" @@ -33,11 +35,11 @@ function trigger_sigusr1() { } function dmenu_copy() { trigger_sigusr1 - cat $BUFFER_FILE | dmenu -l 10 -i -w $(xdotool getactivewindow) -p 'Screen Copy' | sed 's/↵/\n/g' | xclip -i + cat $BUFFER_FILE | $RUNLAUNCHER -l 10 -i -w $(xdotool getactivewindow) -p 'Screen Copy' | sed 's/↵/\n/g' | xclip -i } function dmenu_type() { trigger_sigusr1 - cat $BUFFER_FILE | dmenu -l 10 -i -w $(xdotool getactivewindow) -p 'Screen Type' | sed 's/↵/\n/g' | xargs -IC xdotool type --delay 0 "C" + cat $BUFFER_FILE | $RUNLAUNCHER -l 10 -i -w $(xdotool getactivewindow) -p 'Screen Type' | sed 's/↵/\n/g' | xargs -IC xdotool type --delay 0 "C" } function pipe_combine() { trigger_sigusr1 diff --git a/scripts/st_copyout b/scripts/st_copyout index 0727ba8..684f1b6 100755 --- a/scripts/st_copyout +++ b/scripts/st_copyout @@ -1,10 +1,11 @@ #!/bin/sh # original script by Jaywalker and Luke Smith (https://github.com/Lukesmithxyz/st) +[ -z "$RUNLAUNCHER" ] && RUNLAUNCHER=spmenu tmpfile=$(mktemp /tmp/st-cmd-output.XXXXXX) trap 'rm -f "$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 "Copy which command's output?" -i -l 10 -w $WINDOWID -g 1 | sed 's/[^^]/[&]/g; s/\^/\\^/g')" +chosen="$(grep -F "$ps1" "$tmpfile" | sed '$ d' | tac | $RUNLAUNCHER -p "Copy which command's output?" -na -i -l 10 -w $WINDOWID -g 1 | 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 -selection clipboard diff --git a/scripts/st_emojicopy b/scripts/st_emojicopy index 59b7fb9..5b2e2ce 100755 --- a/scripts/st_emojicopy +++ b/scripts/st_emojicopy @@ -2,6 +2,8 @@ # https://codeberg.org/speedie/speedwm-extras # Script licensed under GNU GPLv3 +[ -z "$RUNLAUNCHER" ] && RUNLAUNCHER=spmenu + EMOJILIST() { printf "\ @@ -1656,6 +1658,6 @@ printf "\ " } -EMOJISEL="$(printf "%s" "$(EMOJILIST)" | dmenu -l 5 -w $WINDOWID -p 'Pick an emoji: ' | awk '{ print $1 }')" +EMOJISEL="$(printf "%s" "$(EMOJILIST)" | $RUNLAUNCHER -l 5 -na -w $WINDOWID -p 'Pick an emoji: ' | awk '{ print $1 }')" [ -z "$EMOJISEL" ] && exit printf "%s" "$EMOJISEL" | xclip -selection clipboard && notify-send "$EMOJISEL copied to clipboard." diff --git a/scripts/st_pipebuffer b/scripts/st_pipebuffer deleted file mode 100755 index ac2292e..0000000 --- a/scripts/st_pipebuffer +++ /dev/null @@ -1,47 +0,0 @@ -#!/bin/bash -# input Usage: echo st or surf content from externalpipe | ./externalpipe_buffer.sh {st,surf}_strings_read -# menus Usage: ./externalpipe_buffer.sh dmenu_{copy, type} -command -v xdotool > /dev/null || exit -BUFFER_FILE=/tmp/content_buffer -function st_strings_read() { - INPUT="$(cat)" - echo "$( - echo "$INPUT" | grep -Eo '\S+' | tr -d '[:blank:]' - echo "$INPUT" | grep -oP '"[^"]+"' | tr -d '"' - echo "$INPUT" | sed 's/^ *[0-9]\+.//g' | awk '{$1=$1};1' - )" | uniq | grep . | awk '{ print length, $0 }' | sort -n -s | cut -d" " -f2- \ - >> $BUFFER_FILE & -} -function surf_strings_read() { - awk '{printf "%sNEWLINE_REPLACE", $0} END {printf "\n"}' | - xmllint --html --xpath "//*" - | - awk '{ gsub("<[^>]*>", ""); print($0); }' | - sed 's/NEWLINE_REPLACE/↵/g' | - awk '{ gsub("<[^>]*>",""); print $0 }' | - sed 's/<//g' | - uniq | grep . | awk '{ print length, $0 }' | sort -n -s | cut -d" " -f2- \ - >> $BUFFER_FILE & -} -function trigger_sigusr1() { - USE_FIFO=F # Recomended as T but only if using dmenu-stdin patch w/ FIFO - rm -f $BUFFER_FILE - if [ $USE_FIFO == T ]; then mkfifo $BUFFER_FILE; else touch $BUFFER_FILE; fi - pkill -USR1 "surf" & - pkill -USR1 "^st$" & - if [ $USE_FIFO != T ]; then sleep 0.8; fi -} -function dmenu_copy() { - trigger_sigusr1 - cat $BUFFER_FILE | dmenu -l 10 -i -w $(xdotool getactivewindow) -p 'Screen Copy' | sed 's/↵/\n/g' | xclip -i -} -function dmenu_type() { - trigger_sigusr1 - cat $BUFFER_FILE | dmenu -l 10 -i -w $(xdotool getactivewindow) -p 'Screen Type' | sed 's/↵/\n/g' | xargs -IC xdotool type --delay 0 "C" -} -function pipe_combine() { - trigger_sigusr1 - cat - $BUFFER_FILE -} - -$1