- Notifications
You must be signed in to change notification settings - Fork0
📰 News display module for Polybar & i3blocks
License
zemmsoares/polybar-news
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
A module to display the latest news on Polybar and i3blocks from multiple sources.
- requests - Python requests
- zscroll - For Polybar text scrolling(optional)
- scroll - For i3blocks text scrolling(optional)
Clone the repository
Set up a Python environment and install dependencies(optional but recommended)
# Create the environmentpython -m venv /path/to/environment# Activate the environmentsource /path/to/environment/bin/activate# Install the dependenciespip install requests
Create a
config.py
file in the root of the project folder. You can use the following examples as a template depending on the news source you want to use.For Hackernews:
news_source="hackernews"# Number of news articles to fetchnumber_news=5
For NewsAPI:
news_source="newsapi"# Number of news articles to fetchnumber_news=5# Register at NewsAPI.org to receive your API key.api_key="<your_api_key_here>"# Configure your desired news sources.# For available options, refer to NewsAPI.org/sources.sources="<your_desired_sources_here>"# Configure your desired country.# Note: You can only filter either by sources or country. (leave one empty "")country="<your_desired_country_here>"
Add the following modules to your Polybar or i3blocks configuration file. Be sure to replace
/path/to/environment
and/path/to/polybar-news
with your own paths.; Fetches news from API and saves it into articles.json[module/news-fetcher]type = custom/scriptexec = /path/to/environment/bin/python /path/to/polybar-news/news_fetcher.py; This module runs every 900 seconds (15 minutes) if the news source is NewsAPI due to its API limit of 100 calls per day for free tier accountsinterval = 900; Rotates through the list of news articles in articles.json; and saves the current article's title and URL in separate text files; This module runs every X seconds to change the displayed article[module/news-rotator]type = custom/scriptinterval = 60exec = /path/to/environment/bin/python /path/to/polybar-news/news_rotator.py; Displays the current news article title; Refreshes every second to ensure updated information is displayed; On left click, opens the current article's URL in the default web browser[module/news-display]type = custom/scripttail = trueinterval = 1format-prefix =" "format = <label>label-padding = 1label-maxlen = 50exec = /path/to/polybar-news/print_current_article.shclick-left = < /path/to/polybar-news/current_article_url.txt xargs -I % xdg-open %
# Fetches news from API and saves it into articles.json[news-fetcher]command=/path/to/environment/bin/python /path/to/polybar-news/news_fetcher.pyinterval=900separator=false# Rotates through the list of news articles in articles.json# and saves the current article's title and URL in separate text files# This module runs every X seconds to change the displayed article[news-rotator]command=/path/to/environment/bin/python /path/to/polybar-news/news_rotator.pyinterval=60separator=false# Displays the current news article title# Refreshes every second to ensure updated information is displayed# On left click, opens the current article's URL in the default web browser[news-display]command=path/to/polybar-news/print_current_article.shinterval=1separator=truemarkup=pangolabel=command=if [ $button ]; then xdg-open "$(cat /path/to/polybar-news/current_article_url.txt)"; else $HOME/.config/i3/i3blocks/scroll path/to/polybar-news/print_current_article.sh; fi
Text Scrolling (Optional)
Installzscroll
Modify the
news-display
module in your Polybar configuration file to use thescroll_current_article.sh
script:[module/news-display]...exec = /path/to/polybar-news/scroll_current_article.sh...
Download the
scroll
script:curl -o~/.config/i3blocks/scroll https://raw.githubusercontent.com/Anachron/i3blocks/master/blocks/scroll
Make the
scroll
script executable:chmod +x~/.config/i3blocks/scroll
Modify the
news-display
module in your i3blocks configuration file to use thescroll
script andprint_current_article.sh
script:[news-display]command=~/.config/i3blocks/scroll /path/to/polybar-news/print_current_article.shinterval=1separator=truemarkup=pangolabel=command=if [ $button ]; then xdg-open "$(cat /path/to/polybar-news/current_article_url.txt)"; else $HOME/.config/i3/i3blocks/scroll path/to/polybar-news/print_current_article.sh; fi
Contributions are always welcome! Feel free to open a pull request to contribute code, or create an issue to report a bug or suggest a new feature.
This project is licensed under the MIT License - see theLICENSE file for details.
About
📰 News display module for Polybar & i3blocks
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Releases
Packages0
Uh oh!
There was an error while loading.Please reload this page.