{"id":13732747,"url":"https://github.com/zemmsoares/polybar-news","last_synced_at":"2025-03-18T23:30:44.687Z","repository":{"id":63593912,"uuid":"139731971","full_name":"zemmsoares/polybar-news","owner":"zemmsoares","description":"📰 News display module for Polybar \u0026 i3blocks","archived":false,"fork":false,"pushed_at":"2023-07-12T22:43:29.000Z","size":5871,"stargazers_count":48,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-11T04:04:24.758Z","etag":null,"topics":["hackernews","hackernews-api","i3-blocks","newsaggregator","polybar","polybar-config","polybar-module","polybar-scripts"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zemmsoares.png","metadata":{"files":{"readme":"README.md","changelog":"news_fetcher.py","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-07-04T14:21:49.000Z","updated_at":"2024-11-06T07:55:25.000Z","dependencies_parsed_at":"2024-01-06T12:19:03.619Z","dependency_job_id":"98d6b017-e0b3-4e6c-919b-d55c72205794","html_url":"https://github.com/zemmsoares/polybar-news","commit_stats":null,"previous_names":["zemmsoares/polynews"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zemmsoares%2Fpolybar-news","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zemmsoares%2Fpolybar-news/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zemmsoares%2Fpolybar-news/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zemmsoares%2Fpolybar-news/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zemmsoares","download_url":"https://codeload.github.com/zemmsoares/polybar-news/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243955715,"owners_count":20374372,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["hackernews","hackernews-api","i3-blocks","newsaggregator","polybar","polybar-config","polybar-module","polybar-scripts"],"created_at":"2024-08-03T03:00:33.341Z","updated_at":"2025-03-18T23:30:44.344Z","avatar_url":"https://github.com/zemmsoares.png","language":"Python","funding_links":[],"categories":["Plugins"],"sub_categories":[],"readme":"# Polybar-news\n\nA module to display the latest news on Polybar and i3blocks from multiple sources.\n\n![Polybar-news](assets/example.gif)\n\n## Table of Contents\n- [Polybar-news](#polybar-news)\n  - [Table of Contents](#table-of-contents)\n  - [Dependencies](#dependencies)\n  - [Setup Instructions](#setup-instructions)\n  - [Contributing](#contributing)\n  - [License](#license)\n\n\n## Dependencies\n\n- [requests](https://pypi.org/project/requests/) - Python requests\n- [zscroll](https://github.com/noctuid/zscroll#installation) - For Polybar text scrolling *(optional)*\n- [scroll](https://github.com/Anachron/i3blocks/blob/master/blocks/scroll) - For i3blocks text scrolling *(optional)*\n\n## Setup Instructions\n\n1. Clone the repository\n2. Set up a Python environment and install dependencies *(optional but recommended)*\n\n    ```bash\n    # Create the environment\n    python -m venv /path/to/environment\n\n    # Activate the environment\n    source /path/to/environment/bin/activate\n\n    # Install the dependencies\n    pip install requests\n    ```\n    ##### *Note: If you don't want to use a Python virtual environment, you can install the dependencies globally with pip install requests, but be aware this might conflict with other Python software on your system.\u003cbr\u003e\u003cbr\u003e\n\n3. 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.     \n\n    **For Hackernews:**\n    ```python\n    news_source = \"hackernews\" \n\n    # Number of news articles to fetch\n    number_news = 5\n    ```\n    **For NewsAPI:**\n    ```python\n    news_source = \"newsapi\" \n\n    # Number of news articles to fetch\n    number_news = 5\n\n    # Register at NewsAPI.org to receive your API key.\n    api_key = \"\u003cyour_api_key_here\u003e\" \n\n    # Configure your desired news sources. \n    # For available options, refer to NewsAPI.org/sources.\n\n    sources = \"\u003cyour_desired_sources_here\u003e\"\n\n    # Configure your desired country. \n    # Note: You can only filter either by sources or country. (leave one empty \"\")\n    country = \"\u003cyour_desired_country_here\u003e\"  \n    ```\n4. 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.\n\n    ## Polybar Modules\n\n    ```ini\n    ; Fetches news from API and saves it into articles.json\n    [module/news-fetcher]\n    type = custom/script\n    exec = /path/to/environment/bin/python /path/to/polybar-news/news_fetcher.py\n    ; 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 accounts\n    interval = 900\n\n    ; Rotates through the list of news articles in articles.json \n    ; and saves the current article's title and URL in separate text files\n    ; This module runs every X seconds to change the displayed article\n    [module/news-rotator]\n    type = custom/script\n    interval = 60\n    exec = /path/to/environment/bin/python /path/to/polybar-news/news_rotator.py\n\n    ; Displays the current news article title\n    ; Refreshes every second to ensure updated information is displayed \n    ; On left click, opens the current article's URL in the default web browser\n    [module/news-display]\n    type = custom/script\n    tail = true\n    interval = 1\n    format-prefix = \"  \"\n    format = \u003clabel\u003e\n    label-padding = 1\n    label-maxlen = 50\n    exec = /path/to/polybar-news/print_current_article.sh\n    click-left = \u003c /path/to/polybar-news/current_article_url.txt xargs -I % xdg-open %\n    ```\n\n\n    ## i3Blocks\n\n    ```ini\n    # Fetches news from API and saves it into articles.json\n    [news-fetcher]\n    command=/path/to/environment/bin/python /path/to/polybar-news/news_fetcher.py\n    interval=900\n    separator=false\n\n    # Rotates through the list of news articles in articles.json\n    # and saves the current article's title and URL in separate text files\n    # This module runs every X seconds to change the displayed article\n    [news-rotator]\n    command=/path/to/environment/bin/python /path/to/polybar-news/news_rotator.py\n    interval=60\n    separator=false\n\n    # Displays the current news article title\n    # Refreshes every second to ensure updated information is displayed\n    # On left click, opens the current article's URL in the default web browser\n    [news-display]\n    command=path/to/polybar-news/print_current_article.sh\n    interval=1\n    separator=true\n    markup=pango\n    label= \n    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\n\n    ```\n\n6. Text Scrolling (Optional)\n\n    ### Polybar\n\n    1. Install [zscroll](https://github.com/noctuid/zscroll#installation)\n\n    2. Modify the `news-display` module in your Polybar configuration file to use the `scroll_current_article.sh` script:\n\n        ```ini\n        [module/news-display]\n        ...\n        exec = /path/to/polybar-news/scroll_current_article.sh\n        ...\n        ```\n\n    ### i3blocks\n\n    1. Download the `scroll` script:\n\n        ```bash\n        curl -o ~/.config/i3blocks/scroll https://raw.githubusercontent.com/Anachron/i3blocks/master/blocks/scroll\n        ```\n    \n    2. Make the `scroll` script executable:\n\n        ```bash\n        chmod +x ~/.config/i3blocks/scroll\n        ```\n\n    3. Modify the `news-display` module in your i3blocks configuration file to use the `scroll` script and `print_current_article.sh` script:\n\n        ```ini\n        [news-display]\n        command=~/.config/i3blocks/scroll /path/to/polybar-news/print_current_article.sh\n        interval=1\n        separator=true\n        markup=pango\n        label= \n        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\n        ```\n\n## Contributing\n\nContributions 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.\n\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzemmsoares%2Fpolybar-news","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzemmsoares%2Fpolybar-news","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzemmsoares%2Fpolybar-news/lists"}