djcev.com

//

Git Repos / dotfiles / bin / get_rss.sh

Last update to this file was on 2024-01-02 at 05:12.

Show get_rss.sh

#!/bin/sh
#
# Copyright (c) 2022, Cameron Vanderzanden. Available under the
# terms of the 2-clause BSD license. Please see the file "LICENSE" in
# the root dir of this repository for more information.
#
#- get_rss.sh 2022/02/05 cev.
## Usage: get_rss.sh [-hxV] [-d directory] [-n name] <URL...>
##
## Retrieve a remote RSS feed using fetch(1)'s if-modified mode,
## store the result in a cache directory (default ~/.cache/rss).
##
## -d Output directory; write to the specified directory.
## -h Show help.
## -n Feed name; don't include any extensions (.xml, for instance).
## -x Don't refresh feed if screensaver is running.
## -V Print version info.
##
#

[ -x $HOME/.local/bin/cev_print.sh ] && . $HOME/.local/bin/cev_print.sh

self="${0##*'/'}"

RSSCACHEDIR="$HOME/.cache/rss"
screensaver=""

while getopts "d:hn:xV?" option; do
case $option in
d) RSSCACHEDIR="$OPTARG" ;;
h) print_help && exit ;;
n) name="$OPTARG" ;;
x) screensaver="YES" ;;
V) print_version && exit ;;
"?") print_help && exit ;;
esac
shift $((OPTIND - 1))
done

if [ -z "$name" ]; then
printf "TODO"
exit 1
fi

# check if xscreensaver has blanked or locked the screen.
if [ ! -z "$screensaver" ]; then
# this is run from cron; set DISPLAY so xscreensaver-command will be quiet
# TODO should do this differently.
DISPLAY=":0.0"
export DISPLAY
xs="$(xscreensaver-command -time | grep -E ' blanked| locked')"
[ ! -z "$xs" ] && exit 0
fi

url="$@"
file="${RSSCACHEDIR}/${name}.xml"

# TODO: add error checking, error messages, proper exit status
if [ ! -f "$file" ]; then
/usr/bin/nice -n 10 fetch -o "$file" "$url" 1>/dev/null 2>&1
else
/usr/bin/nice -n 10 fetch -i "$file" -o "$file" "$url" 1>/dev/null 2>&1
fi

Return to the top of this page or return to the overview of this repo.

Log get_rss.sh

Date Commit Message Author + -
2024-01-02 Change from FreeBSD to Linux, other minor changes cev +1 -1
2022-09-10 New (prelim) Q1 config + a number of minor changes cev +2 -2
2022-02-15 Tabs. cev +2 -2
2022-02-15 get_rss (an rss fetching program), various tweaks cev +64  

Return to the top of this page or return to the overview of this repo.