Home

Awesome

Polybar Module - News & Podcasts

Description

This polybar module displays news and podcast titles, so you can read/listen to them in your browser/audio|video player with a simple click on the bar. You can also search/choose a specific news/podcast through a menu (via rofi) opened by a keyboard shortcut.

Screenshot

<figure> <img alt="Animated gif of the menu with all news" src="screenshots/polybar-module-news-menu.gif" width="860"> <figcaption>The menu with all news opened above the bar</figcaption> </figure>

Installation/Update

Clone (or download) this repository:

git clone https://github.com/nivit/polybar-module-news.git

then run the following commands:

$ cd polybar-module-news  # directory where you cloned the repository or unzipped the release file
$ sh install.sh

Add links of your favorite news/podcast sites to

~/.config/.polybar/scripts/news/conf/feeds_list

and/or to

~/.config/.polybar/scripts/news/conf/feeds_list_breaking_news

Enable this module in your bar, e.g:


[bar/mybar]
...
modules-left = news ...

(It is advisable to use a whole bar for this module only).

Configure the module (see below) and then restart polybar.

Dependencies

This script requires

N.B. After installing Python 3 and the other dependencies you need to wait about 10 seconds before the error message of missing requirement disappears.

Configuration

Edit the file ~/.config/polybar/scripts/news/conf/news.conf and set up the right Python 3 interpreter.

All available options:

namedescriptiondefault value
quiet_modeno output if there are no news/podcasts titlesno
show_siteshow the name of the site as prefix to the titleyes
show_dateshow the news date, if availableyes
date_as_prefixshow the date before the title (otherwise as suffix), if show_date=yesyes
date_formatsee manpage strftime(3) for the conversation specs.%d %b. %R -
show_prefixshow icon, date and site nameyes
news_prefixthe prefix to show before the titlethe character U+F09E
use_colorsfor news/podcast title and diagnostic messagesyes
colorsa list of colors, separated by spaces or commas, to use for the news titles#28FFBF #FFEF78 #49FF00
error_bg_colorbackground color for error messages#F44336
error_fg_colorforeground color for error messages#FFFFFF
warning_bg_colorbackground color for warning messages#FFC107
warning_fg_colorforeground color for the warning messages#212121
reverse_orderreverse the order of the news in the search listyes
show_menudisplay a menu with all news (via rofi, right click)yes
menu_linesnumber of news to show in the menu, definible also in config.rasi, (height of menu)20
media_linksuse link to a multimedial file if availableyes
audio_playerprogram to open audio files of podcastgmplayer
video_playerprogram to open video files of podcastmpv
audio_prefixprefix for the audio titles U+F2CE (audio)
video_prefixprefix for the video titles U+F144 (video)
search_promptstring to use as search prompt"Search"
max_newsmax number of news per feed (a whole number or 0 for all news). It takes effect with the next download.0
lengthnumber of characters for the output to the bar; zero means no limit0
use_ellipsisadd ... where the title length is > 0yes
open_cmdprogram for opening URLsxdg-open
breaking_newsenable breaking news (see below)yes
rofi_configpath to the rofi configuration file${HOME}/.config/polybar/scripts/news/conf/config.rasi
rofi_widthwidth of the rofi menu (see rofi(1))auto
python_cmda python 3 interpreterpython3

You can change the interval between two headlines by editing the relative option in the following file:

~/.config/polybar/scripts/news/conf/module.conf

To configure the menu you can edit the file ~/.config/polybar/scripts/news/conf/config.rasi.

Breaking News Configuration

Add the feed URL of the breaking news sites to

~/.config/polybar/scripts/news/conf/feeds_list_breaking_news

then, in your terminal, run the command:

crontab -e

and add the following line:

*/5 * * * * /usr/bin/python3 $HOME/.config/polybar/scripts/news/download_feeds.py -c '#0cffc8,#cae970' -l 5 $HOME/.config/polybar/scripts/news/data

then save and exit the editor.

Change the list of colors after the -c option, and the number of minutes after the first slash and the option -l, if you want.

Change the value of the variable breaking_news to "yes" in the configuration file:

~/.config/polybar/scripts/news/conf/news.conf

When the headlines are available, they take immediately precedence over other news.

Running

Click on the news headline on the bar to open the relative web page in your browser. With a right click on the bar you can open a menu with all news. You may also show that menu by defining a key shortcut. The command to bind is:

~/.config/polybar/scripts/news/news.sh show_menu

For example, for bspwm/sxhkd, you can add these lines to ~/.config/sxhkd/sxhkdrc:

super + ctrl + shift + r
    $HOME/.config/polybar/scripts/news/news.sh show_menu

or for i3wm this line to ~/.config/i3/config:

bindsym Mod4 + Control + Shift + r exec --no-startup-id ~/.config/polybar/scripts/news/news.sh show_menu

You can also open the current news with a keyboard shortcut by binding the following command:

$HOME/.config/polybar/scripts/news/news.sh open

To select the feeds at runtime, you can bind the following command to a keyboard shortcut or run it from a terminal:

$HOME/.config/polybar/scripts/news/news.sh select

You can always force a download with the command:

$HOME/.config/polybar/scripts/news/news.sh download

Notes

  1. The feed URL of a site is generally available at /feed/ address, but you can also find it by searching for an RSS icon in the page or viewing its HTML page source. You may also use the Ukora news search engine;
  2. in the feed title the tag [BN] marks a breaking news site;
  3. see the site https://colorhunt.co/palettes or https://colorswall.com/ for some hint of colors;
  4. to see icons you need to install a suitable font like Font Awesome;
  5. as video player you could consider the program umpv.

License

This software is licensed under the MIT license. See LICENSE.