commit a839124b7942f2b41e0451ed0190385aa69af452
parent 047b86a77a40fba869492ca797da2216b14a501f
Author: Jacob R. Edwards <jacob@jacobedwards.org>
Date: Tue, 28 Feb 2023 17:27:20 -0800
Add sticky option to notify
This option prevents the notification from timing out; it must be
explicitly dismissed.
Diffstat:
4 files changed, 26 insertions(+), 13 deletions(-)
diff --git a/local/bin/bin/buf b/local/bin/bin/buf
@@ -80,13 +80,16 @@ delbuf() {
}
swap() {
- swap="$(mktemp "$bufs"/swapXXXXXX)"
- swapname="$(basename "$swap")"
- trap 'rm -f "$swap"; exit 1' TERM INT
- getbuf "$1" | setbuf "$swapname"
+ swap="swap$$"
+
+ setbuf "$swap" < /dev/null
+ trap 'delbuf "$swap"; exit 1' TERM INT
+
+ getbuf "$1" | setbuf "$swap"
getbuf "$2" | setbuf "$1"
- getbuf "$swapname" | setbuf "$2"
- rm -f "$swap"
+ getbuf "$swap" | setbuf "$2"
+ delbuf "$swap"
+
trap '' TERM INT
}
diff --git a/local/bin/bin/notify b/local/bin/bin/notify
@@ -5,13 +5,14 @@
usage() {
echo "${1:+error: $1
-}usage: ${0##*/} [-i image] [-v progress] [-u urgency] subject [message]" 1>&2
+}usage: ${0##*/} [-s] [-i image] [-v progress] [-u urgency] subject [message]" 1>&2
exit 1
}
while test $# -gt 0
do
case "$1" in
+ (-s) sticky=true ;;
(-i) image="$2"; shift ;;
(-v) value="$2"; shift ;;
(-u)
@@ -35,4 +36,4 @@ case "$#" in
esac
# The targeted backend is currently dunst(1)
-notify-send ${image:+-i "$image"} ${level:+-u "$level"} ${value:+-h int:value:"$value"} "$s" ${m:+"$m"}
+notify-send ${sticky:+-t 0} ${image:+-i "$image"} ${level:+-u "$level"} ${value:+-h int:value:"$value"} "$s" ${m:+"$m"}
diff --git a/local/bin/bin/pkg_list b/local/bin/bin/pkg_list
@@ -10,9 +10,18 @@ function matchunless(s, re, unless) {
return match(s, unless) ? !_: _
}
+function parseargs() {
+ if (ARGV[1] == "-p") {
+ namef = 2
+ return 2
+ }
+ namef = 1
+ return 1
+}
+
BEGIN {
re = "^any$|(^!?| )" myarch "( |$)"
- for (i = 1; i <= ARGC; ++i) {
+ for (i = parseargs(); i <= ARGC; ++i) {
argv[i] = tolower(ARGV[i])
delete ARGV[i]
}
@@ -20,14 +29,14 @@ BEGIN {
}
{
- name = tolower($1)
+ name = tolower($namef)
desc = tolower($4)
arch = tolower($11)
for (i in argv)
if (!match(name, argv[i]) && !match(desc, argv[i]))
next
if (NF != 14 || matchunless(arch, re, "^!"))
- print($1, $4);
+ print($namef, $4);
else
- print($1, $4 " (for " $11 "; not " myarch ")");
+ print($namef, $4 " (for " $11 "; not " myarch ")");
}' "$@" < /usr/local/share/ports-INDEX
diff --git a/local/bin/bin/urls b/local/bin/bin/urls
@@ -1,7 +1,7 @@
#!/usr/local/plan9/bin/rc -e
# Copyright 2021 Jacob R. Edwards
-cd $home^/etc/urls
+cd $home^/own/etc/urls
if (~ $#* 0)
* = *