aboutsummaryrefslogtreecommitdiff
path: root/dotfiles/.local/bin/newssync
blob: ebe41e1f737f97921e82e0fb0a669318a17591fd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/bin/sh

# Run only if user logged in (prevent cron errors)
w | grep "^$USER\W" >/dev/null || exit

# Don't try to update feed if newsboat is already running
if pidof newsboat; then
  exit
fi

# Check several times before giving up, useful when just waking up from sleep
# since internet is usually not available right away
wget -q --tries=5 --timeout=20 --spider 1.1.1.1 > /dev/null || exit

# Source the needed env variables so that it can function properly from cron
. ~/.cache/sessionenv

touch ~/.cache/newssynclive
killall -42 waybar

newsboat -x reload || true

rm -f ~/.cache/newssynclive
killall -42 waybar