I’m using Arch on my new laptop because of problems with Fedora. But one problem with Arch linux is that it sometimes requires manual intervention when updating. If you don’t pay attention, this command might break your system.
The solution of course is to diligently check archlinux.org/news for breaking changes. But I obviously forget that all the time. If I have time at all.
Thinking this over, I was reminded of an annoying feature in OS X where if a cron job produced output, it would put that output in an mbox file. As long as you don’t clean up that file, every new terminal will say “You have new mail.” at the top.
Wouldn’t it be great if every new terminal would warn you about upgrading? Wish no more. I did exactly that with a few small scripts.
The first is a script that downloads the Arch RSS feed to a mbox, added to my crontab.
sudo systemctl enable cronie crontab -e 0 * * * * /home/pepijn/bin/archheadline.py
#!/usr/bin/env python import feedparser from email.mime.text import MIMEText from mailbox import mbox, mboxMessage feed = feedparser.parse("https://www.archlinux.org/feeds/news/") mail = mbox('/var/spool/mail/news') ids = set([m['Message-ID'] for m in mail]) for entry in feed.entries: if entry.id not in ids: message = MIMEText(entry.summary, 'html') message['From'] = "ArchNews" message['Subject'] = entry.title message['Message-ID'] = entry.id mail.add(message) mail.close()
The second is a script that should be added to your
.bashrc depending on your shell. It will check the mbox file for new messages and print a notice to your terminal.
~/bin/unread.py || echo "$? breaking changes."
#!/usr/bin/env python from mailbox import mbox, mboxMessage mail = mbox('/var/spool/mail/news') new = 0 for m in mail: if 'O' not in m.get_flags(): new += 1 mail.close() exit(new)
To get rid of the warning, open the mbox with a mail viewer. Probably mutt, knowing a few Arch users. I simply run
mail -f /var/spool/mail/news p 1 # print first message q # write mbox and quit