Drop newsboat and add sfeed, fix few things

This commit is contained in:
Alex 2020-06-21 00:10:44 +02:00
parent 8b49f0b882
commit dc4c2b037e
Signed by: caskd
GPG Key ID: F92BA85F61F4C173
8 changed files with 37 additions and 10 deletions

View File

@ -2,6 +2,6 @@ source "${ZDOTDIR}/custom/prependsudo.zsh"
source "${ZDOTDIR}/custom/aliases.zsh"
source "${ZDOTDIR}/custom/gpg.zsh"
fpath+=("${ZDOTDIR}/custom/functions" "${ZDOTDIR}/custom/segments")
function {prompt_c_{covid_19,docker_host,mpv_mpris,new_mail,todo,weather,youtube,mumble},cprompts:cache:async:{covid,weather},get{mangareader,nhentai},gitsubrepo,osutab,ffmpeg-{compress,gif}}() {
function {prompt_c_{covid_19,docker_host,mpv_mpris,new_mail,todo,weather,newsboat,mumble,sfeed},cprompts:cache:async:{covid,weather,rss},get{mangareader,nhentai},gitsubrepo,osutab,ffmpeg-{compress,gif}}() {
autoload -X
}

View File

@ -0,0 +1,12 @@
setopt local_options shwordsplit
local count=0
for f in $feedpath/*; do
local IFS=$'\n'
local content=($(< $f))
for l in ${content[@]}; do
local IFS=$'\t'
local options=($l)
[[ ${options[6]:0:9} == "yt:video:" ]] && [ $options[1] -gt $(($epochtime[1]-14400)) ] && ((count++))
done
done
print $count > $tmpfile

View File

@ -5,7 +5,7 @@ zstyle -s ':custom:prompts:covid' country REPLY
local -a stats
if [ ! -v _cprompts_covid ]; then
zstat -A stats +mtime -- $tmpfile 2>/dev/null
if [[ $stats[1] < $(($epochtime[1]-86400)) ]]; then
if [ $stats[1] -lt $(($epochtime[1]-86400)) ]; then
cprompts:cache:async:covid &!
else
typeset -g _cprompts_covid=$(< $tmpfile)

View File

@ -0,0 +1,6 @@
[ -v commands\[sqlite3\] ] || return
local newsboatdb=~/.newsboat/cache.db
if [ ! -v _cprompts_newsboat ]; then
typeset -g _cprompts_newsboat="$(sqlite3 ${newsboatdb} --ascii 'SELECT COUNT(id) FROM rss_item WHERE unread == 1 AND guid GLOB "yt:video:*"')"
fi
p10k segment -b red -i '' -t "${_cprompts_newsboat}"

View File

@ -0,0 +1,14 @@
feedpath=~/.sfeed/feeds/
tmpfile=$CACHEPATH/rss
[ -r $feedpath ] || return
local -a rss
local -a cache
zstat -A rss +mtime -- $feedpath/* 2>/dev/null
zstat -A cache +mtime -- $tmpfile 2>/dev/null
if [ -r $tmpfile ]; then
([ ! -v _cprompts_sfeed ] || [ $rss[1] -gt $cache[1] ]) && cprompts:cache:async:rss &!
typeset -g _cprompts_sfeed=$(< $tmpfile)
else
cprompts:cache:async:rss &!
fi
[ ${_cprompts_sfeed:-0} -ne 0 ] && p10k segment -b red -i '' -t "+${_cprompts_sfeed:-unknown}"

View File

@ -28,7 +28,7 @@ colors[sn]="white"
if [ ! -v _cprompts_weather ]; then
zstat -A stats +mtime -- $tmpfile 2>/dev/null
if [[ $stats[1] < $(($epochtime[1]-21600)) ]]; then
if [ $stats[1] -lt $(($epochtime[1]-21600)) ]; then
cprompts:cache:async:weather &!
else
typeset -g _cprompts_weather=($(< $tmpfile))

View File

@ -1,6 +0,0 @@
[ -v commands\[sqlite3\] ] || return
local newsboatdb=~/.newsboat/cache.db
if [ ! -v _cprompts_youtube ]; then
typeset -g _cprompts_youtube="$(sqlite3 ${newsboatdb} --ascii 'SELECT COUNT(id) FROM rss_item WHERE unread == 1 AND guid GLOB "yt:video:*"')"
fi
p10k segment -b red -i '' -t "${_cprompts_youtube}"

View File

@ -19,7 +19,8 @@ POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS+=(
c_mpv_mpris
c_todo
c_new_mail
# c_youtube
c_sfeed
# c_newsboat
# c_mumble
c_weather
c_covid_19