[wiki] [sites] Improve externalpipe_buffer.sh script to have more consistent results || Miles Alan
commit 794954616612e4a42531f8a8cbadafd346d712de
Author: Miles Alan <m_AT_milesalan.com>
Date: Sun Aug 11 23:07:25 2019 -0500
Improve externalpipe_buffer.sh script to have more consistent results
diff --git a/st.suckless.org/patches/externalpipe-signal/externalpipe_buffer.sh b/st.suckless.org/patches/externalpipe-signal/externalpipe_buffer.sh
index d16c1667..ad2de9f2 100755
--- a/st.suckless.org/patches/externalpipe-signal/externalpipe_buffer.sh
+++ b/st.suckless.org/patches/externalpipe-signal/externalpipe_buffer.sh
_AT_@ -39,21 +39,19 @@ function write_to_buffer() {
function dedupe_and_sort() {
sort | uniq | grep . | awk '{ print length, $0 }' | sort -n -s | cut -d" " -f2-
}
-function trigger_sigusr1_and_read_buffer() {
- if [ $BUFFER_FILE_FIFO == "true" ]
+function trigger_sigusr1() {
+ rm -f $BUFFER_FILE
+ if [ $BUFFER_FILE_FIFO == true ]
then
test ! -p $BUFFER_FILE && rm -f $BUFFER_FILE && mkfifo $BUFFER_FILE
- pkill -USR1 surf
- pkill -USR1 st
+ pkill -USR1 surf &
+ pkill -USR1 st &
else
test ! -f $BUFFER_FILE && rm -f $BUFFER_FILE && touch $BUFFER_FILE
pkill -USR1 surf
pkill -USR1 st
echo $BUFFER_FILE_R_DELAY | xargs -IN echo N/1000 | bc -l | xargs sleep
fi
-
- cat $BUFFER_FILE
- rm $BUFFER_FILE
}
function dm() { dmenu "$_AT_" -l 10 -i -w $(xdotool getactivewindow); }
_AT_@ -79,7 +77,13 @@ function surf_strings_read() {
dedupe_and_sort |
write_to_buffer
}
-function dmenu_copy() { trigger_sigusr1_and_read_buffer | dm -p 'Screen Copy' | sed 's/↵/
/g' | xclip -i; }
-function dmenu_type() { trigger_sigusr1_and_read_buffer | dm -p 'Screen Type' | sed 's/↵/
/g' | xargs -IC xdotool type --delay 0 "C"; }
+function dmenu_copy() {
+ trigger_sigusr1
+ cat $BUFFER_FILE | dm -p 'Screen Copy' | sed 's/↵/
/g' | xclip -i
+}
+function dmenu_type() {
+ trigger_sigusr1
+ cat $BUFFER_FILE | dm -p 'Screen Type' | sed 's/↵/
/g' | xargs -IC xdotool type --delay 0 "C"
+}
$1
diff --git a/surf.suckless.org/patches/externalpipe-signal/externalpipe_buffer.sh b/surf.suckless.org/patches/externalpipe-signal/externalpipe_buffer.sh
index d16c1667..ad2de9f2 100755
--- a/surf.suckless.org/patches/externalpipe-signal/externalpipe_buffer.sh
+++ b/surf.suckless.org/patches/externalpipe-signal/externalpipe_buffer.sh
_AT_@ -39,21 +39,19 @@ function write_to_buffer() {
function dedupe_and_sort() {
sort | uniq | grep . | awk '{ print length, $0 }' | sort -n -s | cut -d" " -f2-
}
-function trigger_sigusr1_and_read_buffer() {
- if [ $BUFFER_FILE_FIFO == "true" ]
+function trigger_sigusr1() {
+ rm -f $BUFFER_FILE
+ if [ $BUFFER_FILE_FIFO == true ]
then
test ! -p $BUFFER_FILE && rm -f $BUFFER_FILE && mkfifo $BUFFER_FILE
- pkill -USR1 surf
- pkill -USR1 st
+ pkill -USR1 surf &
+ pkill -USR1 st &
else
test ! -f $BUFFER_FILE && rm -f $BUFFER_FILE && touch $BUFFER_FILE
pkill -USR1 surf
pkill -USR1 st
echo $BUFFER_FILE_R_DELAY | xargs -IN echo N/1000 | bc -l | xargs sleep
fi
-
- cat $BUFFER_FILE
- rm $BUFFER_FILE
}
function dm() { dmenu "$_AT_" -l 10 -i -w $(xdotool getactivewindow); }
_AT_@ -79,7 +77,13 @@ function surf_strings_read() {
dedupe_and_sort |
write_to_buffer
}
-function dmenu_copy() { trigger_sigusr1_and_read_buffer | dm -p 'Screen Copy' | sed 's/↵/
/g' | xclip -i; }
-function dmenu_type() { trigger_sigusr1_and_read_buffer | dm -p 'Screen Type' | sed 's/↵/
/g' | xargs -IC xdotool type --delay 0 "C"; }
+function dmenu_copy() {
+ trigger_sigusr1
+ cat $BUFFER_FILE | dm -p 'Screen Copy' | sed 's/↵/
/g' | xclip -i
+}
+function dmenu_type() {
+ trigger_sigusr1
+ cat $BUFFER_FILE | dm -p 'Screen Type' | sed 's/↵/
/g' | xargs -IC xdotool type --delay 0 "C"
+}
$1
Received on Mon Aug 12 2019 - 06:08:13 CEST
This archive was generated by hypermail 2.3.0
: Mon Aug 12 2019 - 06:12:29 CEST