# ---------------------------------------------------------------------------- #
## \author Sebastien Beaugrand
## \sa http://beaugrand.chez.com/
## \copyright CeCILL 2.1 Free Software license
# ---------------------------------------------------------------------------- #
---
- name: urls
  lineinfile:
    path: "{{ home }}/.newsboat/urls"
    line: https://micronews.debian.org/feeds/feed.rss
    create: yes

- name: unread.sh
  blockinfile:
    path: "{{ home }}/.local/bin/unread.sh"
    block: |
      if ! which newsboat >/dev/null; then
          exit 0
      fi
      count=`newsboat -x reload -x print-unread`
      if echo $count | grep -qv '^0 '; then
          notify-send -t 0 "newsboat" "$count"
      fi
    mode: 0755
    create: yes

- name: autostart
  blockinfile:
    path: "{{ home }}/.config/autostart/newsboat.desktop"
    block: |
      [Desktop Entry]
      Type=Application
      Exec={{ home }}/.local/bin/unread.sh
      X-GNOME-Autostart-enabled=true
      NoDisplay=false
      Hidden=false
      Name[fr_FR]=newsboat
      Comment[fr_FR]=print unread
      X-GNOME-Autostart-Delay=0
    create: yes