# ~/.config/newsboat/config
# vim: ft=conf:fdm=marker:fdl=0:noml:

# feeds ------------------------------------------------------------------------
auto-reload yes
# reload-threads 4
# reload-time 120
download-retries 4
download-timeout 10
prepopulate-query-feeds yes

# general ----------------------------------------------------------------------
cleanup-on-quit yes
confirm-exit no
# delete-read-articles-on-quit no
mark-as-read-on-hover no
save-path "~/.local/share/newsboat/saved_articles/"

# network ----------------------------------------------------------------------
use-proxy yes
proxy-type socks5h
proxy 10.64.0.1:1080
# proxy localhost:9050
# user-agent "Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Mobile Safari/537.3"

# bookmark ---------------------------------------------------------------------
bookmark-cmd "~/.config/newsboat/scripts/bookmark-bmm"
bookmark-interactive yes
# bookmark-autopilot yes
# bookmark-cmd "~/.config/newsboat/scripts/bookmark.sh"
# bookmark-cmd "~/.config/newsboat/scripts/bookmark"
# bookmark-interactive no

# external-url-viewer "urlview"

# browser ----------------------------------------------------------------------
browser "~/bin/browser %u"

# note: macro prefix key default: ,
bind-key , macro-prefix
macro b set browser "~/bin/browser"         -- "reset to default browser"
macro r set browser "~/bin/browser -r"      -- "open URLs with readability"
# macro f set browser "~/.config/newsboat/scripts/browser-foreground"    -- "open URLs with default browser in foreground"
# macro b set browser "~/.config/newsboat/scripts/browser"               -- "open URLs with default browser in background"
# macro R set browser "~/.config/newsboat/scripts/browser-fivefilters"   -- "retrieve full text from URLs and show resuls"
# macro s set browser "~/.config/newsboat/scripts/full-text-summary"     -- "open with summary"
# macro w set browser "~/.config/newsboat/scripts/browser-console"       -- "open with w3m"
macro i set pager "~/.config/newsboat/scripts/kitty-img-pager"         -- "open with image pager"

# -- play video/podcast with mpv
# macro m set browser "~/.config/newsboat/scripts/media"
macro m set browser "mpv %u >/dev/null 2>&1 &"; open-in-browser-and-mark-read; set browser "$TERM_BROWSER %u"         -- "open URLs in media player"
macro t set browser "bmm save --tags todo %u &"

# open in external browser
# browser "$TERM_BROWSER %u"
# macro o set browser "$BROWSER %u >/dev/null 2>&1 &"; open-in-browser-and-mark-read; set browser "$TERM_BROWSER %u"
# -- open in tmux window
# macro t set browser "[ $TMUX ] && tmux neww -kan article -- $TERM_BROWSER %u || $TERM_BROWSER %u >/dev/null 2>&1 &"; open-in-browser-and-mark-read; set browser "$TERM_BROWSER %u"

# notify-always  yes
# notify-program "notify"
# notify-format  "Newsboat: %n unread articles in %f feeds %t"

# navigation
# ----------------------------------------------------------------------------
goto-next-feed no
goto-first-unread yes
scrolloff 50

unbind-key C

unbind-key a
bind-key a toggle-show-read-feeds
bind-key TAB toggle-article-read
# bind-key SPACE macro-prefix
# bind-key SPACE toggle-article-read
# bind-key a mark-all-above-as-read

# unbind-key M
# bind-key M mark-all-above-as-read
# bind-key m mark-feed-read
# bind-key M mark-all-feeds-read

# unbind-key g
# unbind-key G
bind-key g home all
bind-key G end all

bind-key S sort
bind-key ^S rev-sort

# vim bindings
unbind-key j
bind-key   j down article
bind-key   j next articlelist
bind-key   j next feedlist
bind-key   j next tagselection
bind-key   j next filterselection
unbind-key J
bind-key   J next-unread
bind-key   J next article
bind-key   J next-feed articlelist
bind-key   J next-feed feedlist
unbind-key k
bind-key   k up article
bind-key   k prev articlelist
bind-key   k prev feedlist
bind-key   k prev tagselection
bind-key   k prev filterselection
unbind-key K
bind-key   K prev article
bind-key   K prev-feed articlelist
bind-key   K prev-feed feedlist
unbind-key l
bind-key   l open-in-browser article
bind-key   l open articlelist
bind-key   l open feedlist
bind-key   l open tagselection
bind-key   l open filterselection
unbind-key h
bind-key   h quit

# default bindings
# bind-key  ^B  bookmark
# bind-key  ^L  redraw
# bind-key  ^R  reload-urls

# look -------------------------------------------------------------------------
display-article-progress no
show-read-articles yes
show-read-feeds no
# feed-sort-order lastupdated
# article-sort-order date-asc

datetime-format "%Y-%m-%d"
# articlelist-format "%f%?T?%-14T ? %t%> %D"
# articlelist-title-format "%T %U - %u"
# feedlist-format "%4i %n %11u %t"
articlelist-format "%f │ %D │ %?T?|%-17T|  &?%t"
# feedlist-format "%n │ %11u │ %t"
text-width 80
feedlist-format "%?T?%  %n %8u %t &--------------------------------------------------------------- %t?"

# color ------------------------------------------------------------------------
# ref: https://newsboat.org/releases/2.24/docs/newsboat.html#_configuring_colors
# keep an eye on issue: https://github.com/newsboat/newsboat/issues/2054
color background         default default
color listnormal         default default
color listnormal_unread  default default bold
color listfocus          green default reverse standout
color listfocus_unread   green default reverse bold
color info               default default
# color info               black white reverse bold
color article            default default
color end-of-text-marker default default
search-highlight-colors  red default reverse bold

# highlight
# highlight all "---(.*)---" blue
# highlight all "---.*---" yellow

# highlight article "^(Feed|Title): .+" blue default bold
# highlight article "^(Author|Link|Date): .+" default default
# highlight article "^(Feed|Title|Author|Link|Date):" default default
# highlight article "(^Feed:.*|^Title:.*|^Author:.*)" default default bold
# highlight article "(^Link:.*|^Date:.*)" default default
highlight article "^(Title):.*$" green default
# highlight article "https?://[^ ]+" red default
highlight article "https?://[^ ]+" blue default
highlight article "\\[[0-9][0-9]*\\]" magenta default bold
highlight article "\\[image\\ [0-9]+\\]" green default
highlight article ":.*\\(link\\)$" cyan default
highlight article ":.*\\(image\\)$" blue default

highlight article "\\`[^\\`]*\\`" green default bold # green text between ` and `
highlight article "^# \\.*" blue default bold # headings as bold blue
highlight article "^## \\.*" cyan default bold # subheadings as bold cyan
highlight article "^### \\.*" green default bold # subsubheadings as bold green
# highlight article "^(\t| )*(-|\\*) \\.*" yellow  default bold # list items as yellow
# highlight article "\\[\\.\\.\\.?\\]" color12 default bold # [..] or [...]

# highlight URLs with regex
# highlight article "[a-z]+://[^ ]+" green default underline
# highlight article "/r/[^/ ]+" blue default
# highlight article "/u/[^/ ]+" green default

# highlight-article "age > 90" default default dim

# subheadings hack (there are nbsps in there)
highlight feedlist ".*0/0.*< " blue default invis
highlight feedlist " >.*"      blue default invis
highlight feedlist "< .* >"    blue default bold

# highlight feedlist "(0/0)" red default
# highlight feedlist ".*(0/0))" black
# highlight feedlist "^─.*$" color6 color6 bold
# highlight feedlist "---.*---" yellow default bold
highlight article "(matches .*)$" red default

highlight-article "tags # \"red\"" red default
selecttag-format "%5n - %T (%n) %f/%u"

# hide articles matching these patterns
# ignore-mode "display"
# ignore-article "*" "title =~ \".*(sponsor|advertisement).*\""
# ignore-article "*" "link =~ \"youtube\.com/shorts\""
ignore-article "*" "title =~ \"\[\$\].*\""

# filters
# define-filter "all feeds with 'fun' tag" "tags # \"fun\""
define-filter "unread feeds" "unread_count > 0"
define-filter "unread articles" "unread = \"yes\""
