Featured image of post Arch News Alert

Arch News Alert

A simple Polybar notification system to track Arch Linux news, especially manual interventions.

Why?

I got tired of manually checking archlinux.org/news every day just to see if there were any critical updates requiring manual steps (you know, the dreaded manual intervention). So, I decided to automate it by adding a simple notification to my Polybar that shows the latest news headline.

When clicked, the notification disappears, and if manual intervention is required, it highlights the alert with exclamation marks—ensuring important updates aren’t missed and the system stays stable.

Module

Add the following to your module file inside your rice folder:

1
2
3
4
5
6
7
8
[module/arch_news]
type = custom/script
exec = /home/saiphe/.config/bspwm/src/arch_news.sh
interval = 10  ; fetch every 10 seconds, adjust as needed
format-prefix = ""
format-underline = #5E81AC

click-left = /home/saiphe/.config/bspwm/src/arch_news.sh clear && xdg-open https://archlinux.org/news/

Config

Now, include the new module in your Polybar configuration. Add arch_news to your module list, along with a separator sep if you prefer.

Example:

1
modules-center = arch_news

Script

Save the following script as arch_news.sh in your bspwm script directory ~/.config/bspwm/src/

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/bin/bash

NEWS_FILE="$HOME/.cache/$(whoami)/arch_news_last"
CURRENT_FILE="$HOME/.cache/$(whoami)/arch_news_current"

FEED_URL="https://archlinux.org/feeds/news/"

# Function to fetch the latest news store them to variable and write it to news file
fetch_news() {
    curl -s "$FEED_URL" | grep -oP '(?<=<title>).*?(?=</title>)' | sed '1d' | head -n 1 | sed 's/$/b/'
}

visualize_news() {
    # If news file has "clear", show default message
    if [ "$(cat "$NEWS_FILE")" == "clear" ]; then
        echo "%{F#7aa2f7}📰 %{F-}"  # violet-blue
        exit 0
    fi
    # Orange for regular news, red for manual intervention
    if echo "$(cat "$NEWS_FILE")" | grep -iq "manual"; then
        echo "%{F#f7768e}🔥 $(cat "$NEWS_FILE") %{F-}"  # red
    else
        echo "%{F#dbbc7f}📰 $(cat "$NEWS_FILE") %{F-}"  # yellow
    fi
}

# fetch news, compare them with cached file CURRENT and if different save them to NEWS and CURRENT files
if [ "$1" = "fetch" ]; then
	[ ! -f "$NEWS_FILE" ] && touch "$NEWS_FILE"
	current_news="$(fetch_news)"

    if [ "$current_news" != "$(cat "$CURRENT_FILE")" ]; then
        echo "$current_news" > "$CURRENT_FILE"
		echo "$current_news" > "$NEWS_FILE"
    fi

    visualize_news
    exit 0
fi

# Echo clear to make the news disappear once you read them
if [ "$1" == "clear" ]; then
	echo "clear" > "$NEWS_FILE"
	visualize_news
	exit 0
fi

Make the script executable:

1
chmod +x ~/.config/bspwm/src/arch_news.sh

Usage

Simply wait for new news to be released. Clicking the notification will open the news in a new browser tab. After 10 seconds, the alert will disappear from your Polybar until fresh news is available. If manual intervention is required, exclamation mark symbols will be added to grab your attention.

Life is a choice: reboot or be root


Built with Hugo
Theme Stack designed by Jimmy