commit d3de19294e5f9de905b3b1b0c981bedd7032fe69
parent ff4b78a84624b5663f75b7e4336b6f0fab8f4193
Author: Jeff <dev@watertao.xyz>
Date: Mon, 2 Mar 2026 13:24:36 -0800
Reworked the pts stuff for monitoring progress.
tty/pts monitoring of tao_youtube_query.sh is now compatible with
systems running busybox linux utils (at least on postmarketos/alpine)
Using 'ps -e' instead of 'ps -ax' and stripped all the ps options
incompatible with busybox ps. The code is a lot cleaner as a result and
the killing of the process appears to be more consistent.
Diffstat:
2 files changed, 12 insertions(+), 15 deletions(-)
diff --git a/tao_url.sh b/tao_url.sh
@@ -64,7 +64,7 @@ a/v download > play %% mpv --msg-level=all=status,ffmpeg/video=error :: DL MEDIA
a/v/yt stream %% mpv --msg-level=all=status,ffmpeg/video=error :: TERM
yt channel (20) %% yt/channel/20
yt channel (all) %% yt/channel/all
-yt search %% yt/query
+yt search %% yt/query/100
yank %% tao_copy.sh
zathura :: DL
nsxiv :: DL
diff --git a/tao_youtube_query.sh b/tao_youtube_query.sh
@@ -21,7 +21,7 @@
# Defaults (fetching latest from channels list)
typ="d"
-l_dflt=50; l=$l_dflt
+l_dflt=10; l=$l_dflt
pts_title="Fetching latest channel videos..."
yt_prnt_opt="%(upload_date)s @ %(playlist_channel)s > %(title)s < ( %(view_count)s ) [ %(duration_string)s ] %(webpage_url)s"
yt_url="-a -"
@@ -31,7 +31,7 @@ export FETCHING_LATEST=1
dn=/dev/null
cmdf(){ command -v $1 >$dn 2>&1; }
prnt(){ printf "%s\n" "$1"; }
-usepts=$( cmdf "ps" && ps -ax 2>$dn 1>&2 && printf "1" )
+usepts=$(cmdf "ps" && ps -e 2>$dn 1>&2 && printf "1")
# dmenu command
if [ -z "$DMENU" ]
@@ -62,11 +62,7 @@ cu(){
rm -fr "$t" 2>$dn 1>&2
if [ "$usepts" = "1" ]; then
- ptsid="$(ps --no-headers -t pts/$ttyno -o pid)" && \
- [ -n "$ptsid" ] && kill -9 "$ptsid" 2>$dn 1>&2
- #dbl chk
- a=$(ps -C $TERMINAL -o args,pid | grep "$(printf "%.15s" "$pts_title")")
- [ -n "$a" ] && kill -9 ${a##* }
+ [ -n "$ttypid" ] && kill -9 "$ttypid" 2>$dn 1>&2
fi
exit 0
}
@@ -113,13 +109,14 @@ pts_open()
then
"$TERMINAL" -t "$pts_title $q" -- tail - 2>$dn &
a="$!"
- sleep 0.2
- ttyno=$(ps -ax | \
- sed -n "/^ \?$a/ {
- :start n
- /pts/!{ b start }
- s/[ 0-9a-z]\+\/\([0-9]\+\).*$/\1/p
- }" | tr -d "\n")
+ sleep 1
+ b=$(ps -e -opid,tty | sed -n "/^ *$a /{
+ :st n; /\?$/{b st}
+ s/^ *\(.*\)$/\1/p; q}" | \
+ tr -d "\n")
+
+ ttypid="${b%% *}"
+ ttyno=$(printf "%s" "$b" | sed -n "s/.*\([0-9]\+$\)$/\1/p")
prnt_tty="--print-to-file playlist:%(title)s /dev/pts/$ttyno"
fi
}