View previous topic :: View next topic |
Author |
Message |
pjp Administrator
Joined: 16 Apr 2002 Posts: 20506
|
Posted: Sun May 30, 2021 3:18 am Post subject: [Tip] News item reminder |
|
|
So eselect news list doesn't have an option to see only the new items. It does have an option to show you how many new items there are.
Nevertheless, until someday when I can dig into the code to offer a patch, this will do for me: Code: | $ ./nir
1 unread news item.
$ ./nir -h
Usage:
nir [-q|-vv]
Examples:
nir
No unread news items.
nir -q
3
nir -v
Title: There's something happening here. Read what it is for all to be clear.
nir -vv
Title: There's something happening here. Read what it is for all to be clear.
I think it's time to stop. Slow down, look around. Everybody read from
here on down.
NOTE: This option only provides a short form of the news item which
includes the Title and first paragraph of the news item.
nir -h
Displays this usage information. |
The portageq query of the repo location does have a slight pause.
Code: | #!/bin/sh -eu
#x
typeset -i numunread opt_quiet opt_verbose
numunread=0
opt_quiet=0
opt_verbose=0
# Left aligned due to the Here Document
show_usage() {
typeset -i e
if test "${1}" -eq 0 ; then
e=1
else
e=2
fi
local myname="${0##*/}"
cat << EOF >&"${e}"
Usage:
${myname} [-q|-vv]
Examples:
${myname}
No unread news items.
${myname} -q
3
${myname} -v
Title: There's something happening here. Read what it is for all to be clear.
${myname} -vv
Title: There's something happening here. Read what it is for all to be clear.
I think it's time to stop. Slow down, look around. Everybody read from
here on down.
NOTE: This option only provides a short form of the news item which
includes the Title and first paragraph of the news item.
${myname} -h
Displays this usage information.
EOF
exit "${1}"
}
if test "${#}" -gt 1; then
show_usage 2
fi
# Give me a parameter. One parameter only, please.
if test "${#}" -eq 1; then
# And it should not be more than 3 characters long: -vv
if test "${#1}" -gt 3 ; then
show_usage 2
else
if test "${1}" == "q" || test "${1}" == "-q" ; then
let opt_quiet=1
elif test "${1}" == "v" || test "${1}" == "-v" ; then
let opt_verbose=1
elif test "${1}" == "vv" || test "${1}" == "-vv" ; then
let opt_verbose=2
elif test "${1}" == "h" || test "${1}" == "-h" ; then
show_usage 0
else
show_usage 2
fi
fi
fi
# Defaulting to en until I stumble upon a more flexible option.
mylang="en"
items_unread="/var/lib/gentoo/news/news-gentoo.unread"
repo_path=$(/usr/bin/portageq get_repo_path / gentoo)
while read item ; do
fname="${repo_path}/metadata/news/${item}/${item}.${mylang}.txt"
if test "${opt_quiet}" -eq 1 || test "${opt_verbose}" -eq 0 ; then
((numunread = numunread + 1))
elif test "${opt_verbose}" -eq 1 ; then
grep -m 1 '^Title:' "${fname}"
elif test "${opt_verbose}" -eq 2 ; then
awk 'BEGIN{n=0} /Title:/ {print}; { if (length == 0) {n++; next;} if (n == 1) print " " $0; next;}' "${fname}"
fi
done < "${items_unread}"
if test "${opt_quiet}" -eq 1 ; then
printf "%d\n" "${numunread}"
exit 0
elif test "${opt_verbose}" -eq 0 ; then
case "${numunread}" in
0) printf "No unread news items.\n";;
1) printf "%d unread news item.\n" "${numunread}";;
*) printf "%d unread news items.\n" "${numunread}";;
esac
exit 0
fi |
My original thought was to add a periodic reminder to PS1, but I haven't gone that far (and probably won't).
My problem is remembering to check between seeing that there's a news item, forgetting about it, then running an upgrade. So maybe I ought to put something in my upgrade alias. I also leave them or mark them unread as a reminder. _________________ Quis separabit? Quo animo? |
|
Back to top |
|
|
fedeliallalinea Administrator
Joined: 08 Mar 2003 Posts: 31335 Location: here
|
Posted: Sun May 30, 2021 6:07 am Post subject: |
|
|
Another way is mark as unread what want to keep and the delete others from the list with eselect news purge _________________ Questions are guaranteed in life; Answers aren't. |
|
Back to top |
|
|
pjp Administrator
Joined: 16 Apr 2002 Posts: 20506
|
Posted: Sun May 30, 2021 6:36 am Post subject: |
|
|
True. I like to keep them around for reference. That way when I think I recall something similar, I check through older news items. Unfortunately they are sometimes deleted. I only use the web reference to mention on forums or if I want a non-terminal reference when performing the tasks mentioned. I could probably use the new count if I could devise a way to make me not forget like I mentioned.
Although that did make me think of another feature. Code: | $ eselect news count all
32
$ eselect news count new
1 | Having "1/32" looks nice, but now I'm not seeing a use for it.
Hmm... maybe sending a text-message when I run my update alias (:
If I find an answer, I could mark them all read then add the "reminder" for the notices I haven't yet addressed. That might be better (for me) so I can stop ignoring the "New" because "Yes, I know."
Good suggestion. _________________ Quis separabit? Quo animo? |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|