https://wiki.archlinux.org/api.php?action=feedcontributions&user=Captaincurrie&feedformat=atomArchWiki - User contributions [en]2024-03-28T14:47:05ZUser contributionsMediaWiki 1.41.0https://wiki.archlinux.org/index.php?title=Newsboat&diff=767286Newsboat2023-02-11T01:42:45Z<p>Captaincurrie: /* Amalgamating multiple feeds into one */ minor edit to make clear that metafeed is a made up tag</p>
<hr />
<div>[[Category:News aggregators]]<br />
[[Category:Console applications]]<br />
[[ja:Newsboat]]<br />
{{Related articles start}}<br />
{{Related|Web feed}}<br />
{{Related articles end}}<br />
<br />
[https://newsboat.org/ Newsboat] is an open source news aggregator licensed under the MIT License.<br />
<br />
From {{man|1|newsboat|DESCRIPTION}}:<br />
<br />
:Newsboat is an RSS/Atom feed reader for text terminals. RSS and Atom are a number of widely-used XML formats to transmit, publish and syndicate articles, for example news or blog articles. Newsboat is designed to be used on text terminals on Unix or Unix-like systems such as GNU/Linux, BSD or macOS. <br />
<br />
Newsboat is a [https://groups.google.com/forum/#!topic/newsbeuter/RPtlWX8CPGU fork] of abandoned Newsbeuter.<br />
<br />
== Installation ==<br />
<br />
[[Install]] the {{Pkg|newsboat}} package. For the development version, install the {{AUR|newsboat-git}} package.<br />
<br />
== Usage ==<br />
<br />
Newsboat cannot start without any configured feeds. Feeds can be configured in {{ic|~/.newsboat/urls}}. Newsboat can be started from the command line with<br />
<br />
$ newsboat<br />
<br />
Press the {{ic|?}} key to see a list of all keybindings. Keybindings can be rebound, see [[#Configuration]].<br />
<br />
== Managing feeds ==<br />
<br />
Adding, removing, and tagging feeds is done by editing the urls file. By default that is either {{ic|~/.newsboat/urls}} or<br />
{{ic|~/.config/newsboat/urls}}. We will use {{ic|~/.config/newsboat/urls}} for the rest of the section.<br />
<br />
{{Tip|In addition to newsboat specific feeds in this section, be sure to see the [[Web feed]] article for additional options.}}<br />
<br />
=== RSS or ATOM sources ===<br />
<br />
To add URLs, open {{ic|~/.config/newsboat/urls}} with your favorite text editor and add the URLs, one per line:<br />
<br />
{{hc|~/.config/newsboat/urls|<br />
<nowiki>http://rss.cnn.com/rss/cnn_topstories.rss</nowiki><br />
<nowiki>http://newsrss.bbc.co.uk/rss/newsonline_world_edition/front_page/rss.xml</nowiki><br />
}}<br />
<br />
To add URLs that have restricted access via username/password, simply provide the username/password in the following way:<br />
<br />
{{hc|~/.config/newsboat/urls|<br />
<nowiki>http://username:password@hostname.domain.tld/feed.rss</nowiki><br />
}}<br />
In order to protect username and password, make sure that {{ic|~/.config/newsboat/urls}} has the appropriate permissions. Newsboat also makes sure that usernames and passwords within URLs aren’t displayed in its user interface. In case there is a @ in the username, type it as %40 instead so that it can be distinguished from the @ that separates the username/password part from the hostname part.<br />
<br />
To configure local files as feeds, simply prefix the local path with {{ic|file://}}:<br />
<br />
{{hc|~/.config/newsboat/urls|<br />
file:///var/log/rss_eventlog.xml<br />
}}<br />
<br />
=== HTML as a source ===<br />
<br />
If HTML sources can be converted to RSS via a user supplied script, newboat can both execute this script and consume the output.<br />
<br />
This is accomplished by using the {{ic|filter:}} prefix in the configuration file. For example, write a script that can read HTML from stdin and print out an RSS or Atom feed to stdout. Save that script to {{ic|~/.config/newsboat/html2rss.sh}} and add the following feed:<br />
<br />
{{hc|~/.config/newsboat/urls|<br />
<nowiki>filter:~/.config/newsboat/html2rss.sh:https://myurl.com</nowiki><br />
}}<br />
<br />
* For several examples using this strategy, see [https://github.com/graysky2/newsboat_custom_stuff graysky's newsboat repo].<br />
* For more discussion, see [https://github.com/newsboat/newsboat/issues/1157 Possible to config newsboat to look at a web exposed directory and report changes #1157].<br />
<br />
=== Tagging feeds ===<br />
<br />
Every feed can be assigned 0 or more tags. This makes it easy to categorize your feeds as well as the ability to easily apply commands to multiple feeds at once.<br />
<br />
Usually, the {{ic|~/.config/newsboat/urls}} file contains one RSS feed URL per line. To assign a tag to an RSS feed, simply attach it as a single word, separated by blanks such as space or tab. If the tag needs to contain spaces, use quotes (") around the tag (see example below). An example may look like this:<br />
<br />
{{hc|~/.config/newsboat/urls|<br />
<nowiki>http://blog.fefe.de/rss.xml?html interesting conspiracy news "cool stuff"</nowiki><br />
<nowiki>http://rss.orf.at/news.xml news orf</nowiki><br />
<nowiki>http://www.heise.de/newsticker/heise.rdf news interesting</nowiki><br />
}}<br />
<br />
Starting Newsboat with this configuration, one can press {{ic|t}} to select a tag. Upon selecting the tag "news", one will see all three RSS feeds. Pressing {{ic|t}} again and e.g. selecting the "conspiracy" tag, will only show the {{ic|<nowiki>http://blog.fefe.de/rss.xml?html</nowiki>}} RSS feed. Pressing {{ic|Ctrl-T}} clears the current tag,<br />
and again shows all RSS feeds, regardless of their assigned tags.<br />
<br />
{{Note| If the tag name contains spaces, the tag must be bounded by {{ic|"}}}}<br />
<br />
==== Special tags ====<br />
<br />
===== Custom feed names =====<br />
<br />
The name of a feed can be defined with a special tag in your urls file. Simply '''prefix''' the tag name with the {{ic|~}} character and the tag name will become the feed name.<br />
<br />
For example:<br />
<br />
{{hc|~/.config/newsboat/urls|<br />
<nowiki>http://rss.cnn.com/rss/cnn_topstories.rss</nowiki> "~CNN Top stories"<br />
}}<br />
<br />
will define the feed with feed-name "CNN Top stories"<br />
<br />
===== Hidden feeds =====<br />
<br />
A feed can be '''hidden''' from the regular list of feeds by '''prefixing''' the tag name with an {{ic|!}}.<br />
<br />
For example:<br />
<br />
{{hc|~/.config/newsboat/urls|<br />
<nowiki>http://rss.orf.at/news.xml</nowiki> "!ORF News (hidden)"<br />
}}<br />
<br />
The content of a '''hidden''' feed can only be found through a query feed.<br />
<br />
=== Query feeds ===<br />
<br />
Custom feeds can be created from existing feeds by creating what is called a ''query feed'': A feed generated by matching articles against a query. Query feeds are defined in your {{ic|~/.config/newsboat/urls}} file like a normal feed.<br />
They have the following syntax:<br />
<br />
<nowiki>query:FEEDNAME:FILTER_EXPRESSION [TAG ...]</nowiki><br />
<br />
Like a normal feed, a query feed has a name, {{ic|FEEDNAME}}, which is displayed in the feedlist.<br />
The filter expression language for {{ic|FILTER_EXPRESSION}} is defined in the [https://newsboat.org/releases/2.13/docs/newsboat.html#_filter_language newsboat manual].<br />
Query feeds can be optionally tagged, just like a normal feed. See [[#Tagging feeds]].<br />
<br />
==== Basic examples ====<br />
<br />
{{hc|~/.config/newsboat/urls|2=<br />
"query:Example1:age > 1"<br />
"query:Example2:(tags # \"example2\") and (title =~ \"example2\")"<br />
"query:Example3:(rssurl =~ \"example3\") or (total_count > 3)"<br />
}}<br />
<br />
The first example defines a feed named {{ic|Example1}} that will contain all articles that are older than a day<br />
<br />
The second example defines a feed named {{ic|Example2}} that will contain all articles whose feed was tagged {{ic|example2}}<br />
'''and''' whose article title matches {{ic|example2}}. Here the {{ic|#}} is the "contains" operator.<br />
<br />
The third example defines a feed named {{ic|Example3}} that will contain all articles whose feed url matches the<br />
regular expression {{ic|example3}} '''or''' all articles that are apart of a feed that contain more than 3 articles.<br />
<br />
{{Note|The query feed definition must be encapsulated in double quotes. Therefore any other double quotes in its declaration must be escaped}}<br />
<br />
==== Unread articles ====<br />
<br />
To create a feed named {{ic|Unread Articles}} that contains all unread articles, define the following:<br />
<br />
{{hc|~/.config/newsboat/urls|<br />
"query:Unread Articles:unread {{=}} \"yes\""<br />
}}<br />
<br />
==== Amalgamating multiple feeds into one ====<br />
<br />
A good use of query feeds is when you are following a creator whose content is spread across multiple feeds. You can use a query feed to amalgamate all his content into one place.<br />
<br />
{{hc|~/.config/newsboat/urls|<br />
"query:Metafeed:tags # \"metafeed\""<nowiki><br />
https://feed.url/1 metafeed !<br />
https://feed.url/2 metafeed !<br />
https://feed.url/3 metafeed !<br />
</nowiki>}}<br />
<br />
The trick is to assign each individual feed a unique tag - here we used {{ic|metafeed}} - so that we can match against it in the filter expression. We also make use of [[#Hidden feeds]] - the {{ic|!}} at the end of each feed - so that the individual feeds do not show up in the feedlist.<br />
<br />
==== Filtering a specific feed ====<br />
<br />
If a feed contains content you do not want to see, you can filter it by using a query feed.<br />
For example, to monitor package updates you are interested in, you can use:<br />
<br />
{{hc|~/.config/newsboat/urls|<br />
"query:Package Updates:(tags # \"packageupdates\") and (title {{=}}~ \"linux [0-9]{{!}}newsboat\")"<br />
<nowiki>https://archlinux.org/feeds/packages/</nowiki> packageupdates !<br />
}}<br />
<br />
This feed will only display updates to {{Pkg|linux}} and {{Pkg|newsboat}}.<br />
<br />
=== Ignoring articles ===<br />
<br />
As with [[#Filtering a specific feed|query feeds]], another way to filter feeds is by using the {{ic|ignore-article}} command in your {{ic|~/.config/newsboat/config}}. It has the following syntax<br />
<br />
ignore-article FEEDURL FILTER_EXPRESSION<br />
<br />
==== Examples ====<br />
<br />
{{hc|~/.config/newsboat/config|<nowiki><br />
ignore-article "https://feed/url1" "content =~ \"tele(phone|communications)\"" <br />
ignore-article "https://feed/url2" "title =~ \"text_1|text_2\""<br />
</nowiki>}}<br />
<br />
The first example will ignore all articles in {{ic|<nowiki>https://feed/url1</nowiki>}} whose content matches<br />
{{ic|tele(phone{{!}}communications)}}<br />
<br />
The second example will ignore all articles in {{ic|<nowiki>https://feed/url2</nowiki>}} whose title matches {{ic|text_1{{!}}text_2}}<br />
<br />
==== Ignore modes ====<br />
<br />
In contrast to filtering with query feeds, Newsboat allows you to decide what to do with articles that match an {{ic|ignore-article}} command: you can delete them or not show them.<br />
<br />
{{hc|~/.config/newsboat/config|<br />
# ignore-mode "download" # Default: Delete them.<br />
# ignore-mode "display" # Do not show them.<br />
}}<br />
<br />
==== Comparison with query feeds ====<br />
<br />
In terms of pure filtering, whatever you can do with {{ic|ignore-article}} you can also do with a [[#Filtering a specific feed|query feed]].<br />
<br />
Query feeds are defined in your {{ic|~/.config/newsboat/urls}} file while {{ic|ignore-article}} commands are placed in your {{ic|~/.config/newsboat/config}}. So if you prefer having all feed related things in one place, you might want to stick<br />
to using query feeds.<br />
<br />
However if you want to save space and prevent newsboat from downloading certain articles, then<br />
using {{ic|ignore-article}} is your only choice.<br />
<br />
== Configuration ==<br />
<br />
Several aspects of Newsboat’s behaviour can be configured via a configuration file which is located, by default, in {{ic|~/.newsboat/config}} or {{ic|~/.config/newsboat/config}}. This configuration file contains lines of the form:<br />
<br />
<config-command> <arg1> ...<br />
<br />
=== Color schemes ===<br />
<br />
The package ships with a number of schemes in {{ic|/usr/share/doc/newsboat/contrib/colorschemes/}} which can be loaded with the include command like so:<br />
<br />
include /usr/share/doc/newsboat/contrib/colorschemes/inkpot<br />
<br />
=== Additional options ===<br />
<br />
The configuration file can also contain comments, which start with the {{ic|#}} character and go as far as the end of line. To enter a configuration argument that contains spaces, use quotes {{ic|"}} around the whole argument. It is even possible to integrate the output of external commands into the configuration. The text between two backticks {{ic|`}} is evaluated as shell command, and its output is put on its place instead. This works like backtick evaluation in Bourne-compatible shells and allows users to use external information from the system within the configuration.<br />
<br />
See [https://gist.github.com/anonymous/42d2f5956e7bc8ee1ebc] and [http://moparx.com/configs/newsbeuter/] for example configurations.<br />
<br />
{{Note|To see a complete list of configuration command, consult {{man|1|newsboat|CONFIGURATION COMMANDS}}.}}<br />
<br />
== Tips and tricks ==<br />
<br />
=== Automatic feed reloads ===<br />
<br />
Newsboat can automatically reload all feeds on startup with the following configuration:<br />
<br />
auto-reload yes<br />
<br />
With this setting, Newsboat also runs periodic auto-reloads – by default, every 60 minutes. The number of minutes between automatic reloads can be configured like so:<br />
<br />
reload-time <desired number of minutes><br />
<br />
Alternatively, use [[cron]] or [[systemd]] to automatically reload feeds. Just add a line in your crontab, or create a systemd service/timer unit combo that issues the following command:<br />
<br />
/usr/bin/newsboat -x reload<br />
<br />
=== Loading of feeds in parallel for faster updates ===<br />
<br />
By default, Newsboat will attempt to update entries in {{ic|~/.newsboat/urls}} in sequence; however, the following setting will update them n at a time, in parallel. Adjust n to your liking.<br />
<br />
reload-threads 100<br />
<br />
=== Pass article URL to external command ===<br />
<br />
A clever little hack allows one to pass the URL of an article to an external command. The idea is to use a macro to set the browser that Newsboat opens the article with to the path of some other command and then change it back afterwards.<br />
<br />
For example, subscribers of a particular youtube channel can open the video with [[mpv]], by doing the following:<br />
<br />
macro y set browser "mpv %u" ; open-in-browser ; set browser "elinks %u"<br />
<br />
{{Note| First press the {{ic|,}} key, followed by the keybind to use the macro. In the example above, type {{ic|,}} + {{ic|y}} }}<br />
<br />
=== Subheadings ===<br />
<br />
There is another little hack that allows the user to add subheadings to sort feeds more effectively. This hack involves adding fake feeds to the {{ic|urls}} file like so:<br />
<br />
---Heading---<br />
<br />
{{Note|the {{ic|---}} characters are optional but having some sort of character identifying the headings is useful for styling.}}<br />
<br />
Then in {{ic|~/.config/newsboat/config}}, add the following two lines:<br />
<br />
highlight feedlist "---.*---" ''COLOR_OF_YOUR_CHOOSING'' default bold<br />
highlight feedlist ".*0/0.." default default invis<br />
<br />
Of course, replace {{ic|''COLOR_OF_YOUR_CHOOSING''}} with a [https://newsboat.org/releases/2.24/docs/newsboat.html#_configuring_colors newsboat supported color].<br />
<br />
This trick can also interact with Tags by replacing {{ic|---Heading---}} with:<br />
<br />
"query:---Heading---:tags # \"Tag\""<br />
<br />
Then tagging all the feeds below the heading with {{ic|Tag}}.<br />
<br />
== Troubleshooting ==<br />
<br />
=== Newsboat will not start ===<br />
<br />
Newsboat cannot start without any configured feeds! To add URLs, see [[#Managing feeds]]. If that is not the problem, check to see if another instance of Newsboat is running. Newsboat issues a lock on its database so that only one instance can access it at a time; thus, attempting to open a second instance will fail.<br />
<br />
== See also ==<br />
<br />
*[https://newsboat.org/ Official web site]<br />
*[https://newsboat.org/releases/2.24/docs/newsboat.html Full documentation]<br />
*[https://sanctum.geek.nz/arabesque/rss-with-newsboat/ Arabesque: RSS with Newsboat]</div>Captaincurriehttps://wiki.archlinux.org/index.php?title=Newsboat&diff=766279Newsboat2023-02-02T17:35:31Z<p>Captaincurrie: /* Managing feeds */ Made ~/.config/newsboat/urls the targeted config across the entire section. Added config header to every example to make it always clear where feeds are defined</p>
<hr />
<div>[[Category:News aggregators]]<br />
[[Category:Console applications]]<br />
[[ja:Newsboat]]<br />
{{Related articles start}}<br />
{{Related|Web feed}}<br />
{{Related articles end}}<br />
<br />
[https://newsboat.org/ Newsboat] is an open source news aggregator licensed under the MIT License.<br />
<br />
From {{man|1|newsboat|DESCRIPTION}}:<br />
<br />
:Newsboat is an RSS/Atom feed reader for text terminals. RSS and Atom are a number of widely-used XML formats to transmit, publish and syndicate articles, for example news or blog articles. Newsboat is designed to be used on text terminals on Unix or Unix-like systems such as GNU/Linux, BSD or macOS. <br />
<br />
Newsboat is a [https://groups.google.com/forum/#!topic/newsbeuter/RPtlWX8CPGU fork] of abandoned Newsbeuter.<br />
<br />
== Installation ==<br />
<br />
[[Install]] the {{Pkg|newsboat}} package. For the development version, install the {{AUR|newsboat-git}} package.<br />
<br />
== Usage ==<br />
<br />
Newsboat cannot start without any configured feeds. Feeds can be configured in {{ic|~/.newsboat/urls}}. Newsboat can be started from the command line with<br />
<br />
$ newsboat<br />
<br />
Press the {{ic|?}} key to see a list of all keybindings. Keybindings can be rebound, see [[#Configuration]].<br />
<br />
== Managing feeds ==<br />
<br />
Adding, removing, and tagging feeds is done by editing the urls file. By default that is either {{ic|~/.newsboat/urls}} or<br />
{{ic|~/.config/newsboat/urls}}. We will use {{ic|~/.config/newsboat/urls}} for the rest of the section.<br />
<br />
{{Tip|In addition to newsboat specific feeds in this section, be sure to see the [[Web feed]] article for additional options.}}<br />
<br />
=== RSS or ATOM sources ===<br />
<br />
To add URLs, open {{ic|~/.config/newsboat/urls}} with your favorite text editor and add the URLs, one per line:<br />
<br />
{{hc|~/.config/newsboat/urls|<br />
<nowiki>http://rss.cnn.com/rss/cnn_topstories.rss</nowiki><br />
<nowiki>http://newsrss.bbc.co.uk/rss/newsonline_world_edition/front_page/rss.xml</nowiki><br />
}}<br />
<br />
To add URLs that have restricted access via username/password, simply provide the username/password in the following way:<br />
<br />
{{hc|~/.config/newsboat/urls|<br />
<nowiki>http://username:password@hostname.domain.tld/feed.rss</nowiki><br />
}}<br />
In order to protect username and password, make sure that {{ic|~/.config/newsboat/urls}} has the appropriate permissions. Newsboat also makes sure that usernames and passwords within URLs aren’t displayed in its user interface. In case there is a @ in the username, type it as %40 instead so that it can be distinguished from the @ that separates the username/password part from the hostname part.<br />
<br />
To configure local files as feeds, simply prefix the local path with {{ic|file://}}:<br />
<br />
{{hc|~/.config/newsboat/urls|<br />
file:///var/log/rss_eventlog.xml<br />
}}<br />
<br />
=== HTML as a source ===<br />
<br />
If HTML sources can be converted to RSS via a user supplied script, newboat can both execute this script and consume the output.<br />
<br />
This is accomplished by using the {{ic|filter:}} prefix in the configuration file. For example, write a script that can read HTML from stdin and print out an RSS or Atom feed to stdout. Save that script to {{ic|~/.config/newsboat/html2rss.sh}} and add the following feed:<br />
<br />
{{hc|~/.config/newsboat/urls|<br />
<nowiki>filter:~/.config/newsboat/html2rss.sh:https://myurl.com</nowiki><br />
}}<br />
<br />
* For several examples using this strategy, see [https://github.com/graysky2/newsboat_custom_stuff graysky's newsboat repo].<br />
* For more discussion, see [https://github.com/newsboat/newsboat/issues/1157 Possible to config newsboat to look at a web exposed directory and report changes #1157].<br />
<br />
=== Tagging feeds ===<br />
<br />
Every feed can be assigned 0 or more tags. This makes it easy to categorize your feeds as well as the ability to easily apply commands to multiple feeds at once.<br />
<br />
Usually, the {{ic|~/.config/newsboat/urls}} file contains one RSS feed URL per line. To assign a tag to an RSS feed, simply attach it as a single word, separated by blanks such as space or tab. If the tag needs to contain spaces, use quotes (") around the tag (see example below). An example may look like this:<br />
<br />
{{hc|~/.config/newsboat/urls|<br />
<nowiki>http://blog.fefe.de/rss.xml?html interesting conspiracy news "cool stuff"</nowiki><br />
<nowiki>http://rss.orf.at/news.xml news orf</nowiki><br />
<nowiki>http://www.heise.de/newsticker/heise.rdf news interesting</nowiki><br />
}}<br />
<br />
Starting Newsboat with this configuration, one can press {{ic|t}} to select a tag. Upon selecting the tag "news", one will see all three RSS feeds. Pressing {{ic|t}} again and e.g. selecting the "conspiracy" tag, will only show the {{ic|<nowiki>http://blog.fefe.de/rss.xml?html</nowiki>}} RSS feed. Pressing {{ic|Ctrl-T}} clears the current tag,<br />
and again shows all RSS feeds, regardless of their assigned tags.<br />
<br />
{{Note| If the tag name contains spaces, the tag must be bounded by {{ic|"}}}}<br />
<br />
==== Special tags ====<br />
<br />
===== Custom feed names =====<br />
<br />
The name of a feed can be defined with a special tag in your urls file. Simply '''prefix''' the tag name with the {{ic|~}} character and the tag name will become the feed name.<br />
<br />
For example:<br />
<br />
{{hc|~/.config/newsboat/urls|<br />
<nowiki>http://rss.cnn.com/rss/cnn_topstories.rss</nowiki> "~CNN Top stories"<br />
}}<br />
<br />
will define the feed with feed-name "CNN Top stories"<br />
<br />
===== Hidden feeds =====<br />
<br />
A feed can be '''hidden''' from the regular list of feeds by '''prefixing''' the tag name with an {{ic|!}}.<br />
<br />
For example:<br />
<br />
{{hc|~/.config/newsboat/urls|<br />
<nowiki>http://rss.orf.at/news.xml</nowiki> "!ORF News (hidden)"<br />
}}<br />
<br />
The content of a '''hidden''' feed can only be found through a query feed.<br />
<br />
=== Query feeds ===<br />
<br />
Custom feeds can be created from existing feeds by creating what is called a ''query feed'': A feed generated by matching articles against a query. Query feeds are defined in your {{ic|~/.config/newsboat/urls}} file like a normal feed.<br />
They have the following syntax:<br />
<br />
<nowiki>query:FEEDNAME:FILTER_EXPRESSION [TAG ...]</nowiki><br />
<br />
Like a normal feed, a query feed has a name, {{ic|FEEDNAME}}, which is displayed in the feedlist.<br />
The filter expression language for {{ic|FILTER_EXPRESSION}} is defined in the [https://newsboat.org/releases/2.13/docs/newsboat.html#_filter_language newsboat manual].<br />
Query feeds can be optionally tagged, just like a normal feed. See [[#Tagging feeds]].<br />
<br />
==== Basic examples ====<br />
<br />
{{hc|~/.config/newsboat/urls|2=<br />
"query:Example1:age > 1"<br />
"query:Example2:(tags # \"example2\") and (title =~ \"example2\")"<br />
"query:Example3:(rssurl =~ \"example3\") or (total_count > 3)"<br />
}}<br />
<br />
The first example defines a feed named {{ic|Example1}} that will contain all articles that are older than a day<br />
<br />
The second example defines a feed named {{ic|Example2}} that will contain all articles whose feed was tagged {{ic|example2}}<br />
'''and''' whose article title matches {{ic|example2}}. Here the {{ic|#}} is the "contains" operator.<br />
<br />
The third example defines a feed named {{ic|Example3}} that will contain all articles whose feed url matches the<br />
regular expression {{ic|example3}} '''or''' all articles that are apart of a feed that contain more than 3 articles.<br />
<br />
{{Note|The query feed definition must be encapsulated in double quotes. Therefore any other double quotes in its declaration must be escaped}}<br />
<br />
==== Unread articles ====<br />
<br />
To create a feed named {{ic|Unread Articles}} that contains all unread articles, define the following:<br />
<br />
{{hc|~/.config/newsboat/urls|<br />
"query:Unread Articles:unread {{=}} \"yes\""<br />
}}<br />
<br />
==== Amalgamating multiple feeds into one ====<br />
<br />
A good use of query feeds is when you are following a creator whose content is spread across multiple feeds. You can use a query feed to amalgamate all his content into one place.<br />
<br />
{{hc|~/.config/newsboat/urls|<br />
"query:Metafeed:tags # \"metafeed\""<nowiki><br />
https://feed.url/1 metafeed !<br />
https://feed.url/2 metafeed !<br />
https://feed.url/3 metafeed !<br />
</nowiki>}}<br />
<br />
The trick is to assign each individual feed a unique tag - here {{ic|metafeed}} - so that we can match against it in the filter expression. We also make use of [[#Hidden feeds]] - the {{ic|!}} at the end of each feed - so that the individual feeds do not show up in the feedlist.<br />
<br />
==== Filtering a specific feed ====<br />
<br />
If a feed contains content you do not want to see, you can filter it by using a query feed.<br />
For example, to monitor package updates you're interested in, you can use:<br />
<br />
{{hc|~/.config/newsboat/urls|<br />
"query:Package Updates:(tags # \"packageupdates\") and (title {{=}}~ \"linux [0-9]{{!}}newsboat\")"<br />
<nowiki>https://archlinux.org/feeds/packages/</nowiki> packageupdates !<br />
}}<br />
<br />
This feed will only display updates to {{Pkg|linux}} and {{Pkg|newsboat}}.<br />
<br />
=== Ignoring articles ===<br />
<br />
As with [[#Filtering a specific feed|query feeds]], another way to filter feeds is by using the {{ic|ignore-article}} command in your {{ic|~/.config/newsboat/config}}. It has the following syntax<br />
<br />
ignore-article FEEDURL FILTER_EXPRESSION<br />
<br />
==== Examples ====<br />
<br />
{{hc|~/.config/newsboat/config|<nowiki><br />
ignore-article "https://feed/url1" "content =~ \"tele(phone|communications)\"" <br />
ignore-article "https://feed/url2" "title =~ \"text_1|text_2\""<br />
</nowiki>}}<br />
<br />
The first example will ignore all articles in {{ic|<nowiki>https://feed/url1</nowiki>}} whose content matches<br />
{{ic|tele(phone{{!}}communications)}}<br />
<br />
The second example will ignore all articles in {{ic|<nowiki>https://feed/url2</nowiki>}} whose title matches {{ic|text_1{{!}}text_2}}<br />
<br />
==== Ignore modes ====<br />
<br />
In contrast to filtering with query feeds, Newsboat allows you to decide what to do with articles that match an {{ic|ignore-article}} command: you can delete them or not show them.<br />
<br />
{{hc|~/.config/newsboat/config|<br />
# ignore-mode "download" # Default: Delete them.<br />
# ignore-mode "display" # Do not show them.<br />
}}<br />
<br />
==== Comparison with query feeds ====<br />
<br />
In terms of pure filtering, whatever you can do with {{ic|ignore-article}} you can also do with a [[#Filtering a specific feed|query feed]].<br />
<br />
Query feeds are defined in your {{ic|~/.config/newsboat/urls}} file while {{ic|ignore-article}} commands are placed in your {{ic|~/.config/newsboat/config}}. So if you prefer having all feed related things in one place, you might want to stick<br />
to using query feeds.<br />
<br />
However if you want to save space and prevent newsboat from downloading certain articles, then<br />
using {{ic|ignore-article}} is your only choice.<br />
<br />
== Configuration ==<br />
<br />
Several aspects of Newsboat’s behaviour can be configured via a configuration file which is located, by default, in {{ic|~/.newsboat/config}} or {{ic|~/.config/newsboat/config}}. This configuration file contains lines of the form:<br />
<br />
<config-command> <arg1> ...<br />
<br />
=== Color schemes ===<br />
<br />
The package ships with a number of schemes in {{ic|/usr/share/doc/newsboat/contrib/colorschemes/}} which can be loaded with the include command like so:<br />
<br />
include /usr/share/doc/newsboat/contrib/colorschemes/inkpot<br />
<br />
=== Additional options ===<br />
<br />
The configuration file can also contain comments, which start with the {{ic|#}} character and go as far as the end of line. To enter a configuration argument that contains spaces, use quotes {{ic|"}} around the whole argument. It is even possible to integrate the output of external commands into the configuration. The text between two backticks {{ic|`}} is evaluated as shell command, and its output is put on its place instead. This works like backtick evaluation in Bourne-compatible shells and allows users to use external information from the system within the configuration.<br />
<br />
See [https://gist.github.com/anonymous/42d2f5956e7bc8ee1ebc] and [http://moparx.com/configs/newsbeuter/] for example configurations.<br />
<br />
{{Note|To see a complete list of configuration command, consult {{man|1|newsboat|CONFIGURATION COMMANDS}}.}}<br />
<br />
== Tips and tricks ==<br />
<br />
=== Automatic feed reloads ===<br />
<br />
Newsboat can automatically reload all feeds on startup with the following configuration:<br />
<br />
auto-reload yes<br />
<br />
With this setting, Newsboat also runs periodic auto-reloads – by default, every 60 minutes. The number of minutes between automatic reloads can be configured like so:<br />
<br />
reload-time <desired number of minutes><br />
<br />
Alternatively, use [[cron]] or [[systemd]] to automatically reload feeds. Just add a line in your crontab, or create a systemd service/timer unit combo that issues the following command:<br />
<br />
/usr/bin/newsboat -x reload<br />
<br />
=== Loading of feeds in parallel for faster updates ===<br />
<br />
By default, Newsboat will attempt to update entries in {{ic|~/.newsboat/urls}} in sequence; however, the following setting will update them n at a time, in parallel. Adjust n to your liking.<br />
<br />
reload-threads 100<br />
<br />
=== Pass article URL to external command ===<br />
<br />
A clever little hack allows one to pass the URL of an article to an external command. The idea is to use a macro to set the browser that Newsboat opens the article with to the path of some other command and then change it back afterwards.<br />
<br />
For example, subscribers of a particular youtube channel can open the video with [[mpv]], by doing the following:<br />
<br />
macro y set browser "mpv %u" ; open-in-browser ; set browser "elinks %u"<br />
<br />
{{Note| First press the {{ic|,}} key, followed by the keybind to use the macro. In the example above, type {{ic|,}} + {{ic|y}} }}<br />
<br />
=== Subheadings ===<br />
<br />
There is another little hack that allows the user to add subheadings to sort feeds more effectively. This hack involves adding fake feeds to the {{ic|urls}} file like so:<br />
<br />
---Heading---<br />
<br />
{{Note|the {{ic|---}} characters are optional but having some sort of character identifying the headings is useful for styling.}}<br />
<br />
Then in {{ic|~/.config/newsboat/config}}, add the following two lines:<br />
<br />
highlight feedlist "---.*---" ''COLOR_OF_YOUR_CHOOSING'' default bold<br />
highlight feedlist ".*0/0.." default default invis<br />
<br />
Of course, replace {{ic|''COLOR_OF_YOUR_CHOOSING''}} with a [https://newsboat.org/releases/2.24/docs/newsboat.html#_configuring_colors newsboat supported color].<br />
<br />
This trick can also interact with Tags by replacing {{ic|---Heading---}} with:<br />
<br />
"query:---Heading---:tags # \"Tag\""<br />
<br />
Then tagging all the feeds below the heading with {{ic|Tag}}.<br />
<br />
== Troubleshooting ==<br />
<br />
=== Newsboat will not start ===<br />
<br />
Newsboat cannot start without any configured feeds! To add URLs, see [[#Managing feeds]]. If that is not the problem, check to see if another instance of Newsboat is running. Newsboat issues a lock on its database so that only one instance can access it at a time; thus, attempting to open a second instance will fail.<br />
<br />
== See also ==<br />
<br />
*[https://newsboat.org/ Official web site]<br />
*[https://newsboat.org/releases/2.24/docs/newsboat.html Full documentation]<br />
*[https://sanctum.geek.nz/arabesque/rss-with-newsboat/ Arabesque: RSS with Newsboat]</div>Captaincurriehttps://wiki.archlinux.org/index.php?title=Newsboat&diff=766278Newsboat2023-02-02T17:24:35Z<p>Captaincurrie: /* Managing feeds */ added the other default feed config file</p>
<hr />
<div>[[Category:News aggregators]]<br />
[[Category:Console applications]]<br />
[[ja:Newsboat]]<br />
{{Related articles start}}<br />
{{Related|Web feed}}<br />
{{Related articles end}}<br />
<br />
[https://newsboat.org/ Newsboat] is an open source news aggregator licensed under the MIT License.<br />
<br />
From {{man|1|newsboat|DESCRIPTION}}:<br />
<br />
:Newsboat is an RSS/Atom feed reader for text terminals. RSS and Atom are a number of widely-used XML formats to transmit, publish and syndicate articles, for example news or blog articles. Newsboat is designed to be used on text terminals on Unix or Unix-like systems such as GNU/Linux, BSD or macOS. <br />
<br />
Newsboat is a [https://groups.google.com/forum/#!topic/newsbeuter/RPtlWX8CPGU fork] of abandoned Newsbeuter.<br />
<br />
== Installation ==<br />
<br />
[[Install]] the {{Pkg|newsboat}} package. For the development version, install the {{AUR|newsboat-git}} package.<br />
<br />
== Usage ==<br />
<br />
Newsboat cannot start without any configured feeds. Feeds can be configured in {{ic|~/.newsboat/urls}}. Newsboat can be started from the command line with<br />
<br />
$ newsboat<br />
<br />
Press the {{ic|?}} key to see a list of all keybindings. Keybindings can be rebound, see [[#Configuration]].<br />
<br />
== Managing feeds ==<br />
<br />
Adding, removing, and tagging feeds is done by editing the urls file. By default that is either {{ic|~/.newsboat/urls}} or<br />
{{ic|~/.config/newsboat/urls}}.<br />
<br />
{{Tip|In addition to newsboat specific feeds in this section, be sure to see the [[Web feed]] article for additional options.}}<br />
<br />
=== RSS or ATOM sources ===<br />
<br />
To add URLs, open {{ic|~/.newsboat/urls}} with your favorite text editor and add the URLs, one per line:<br />
<br />
<nowiki>http://rss.cnn.com/rss/cnn_topstories.rss</nowiki><br />
<nowiki>http://newsrss.bbc.co.uk/rss/newsonline_world_edition/front_page/rss.xml</nowiki><br />
<br />
To add URLs that have restricted access via username/password, simply provide the username/password in the following way:<br />
<br />
<nowiki>http://username:password@hostname.domain.tld/feed.rss</nowiki><br />
<br />
In order to protect username and password, make sure that {{ic|~/.newsboat/urls}} has the appropriate permissions. Newsboat also makes sure that usernames and passwords within URLs aren’t displayed in its user interface. In case there is a @ in the username, type it as %40 instead so that it can be distinguished from the @ that separates the username/password part from the hostname part.<br />
<br />
To configure local files as feeds, simply prefix the local path with {{ic|file://}} and add it to the {{ic|~/.newsboat/urls}} file:<br />
<br />
file:///var/log/rss_eventlog.xml<br />
<br />
=== HTML as a source ===<br />
<br />
If HTML sources can be converted to RSS via a user supplied script, newboat can both execute this script and consume the output.<br />
<br />
This is accomplished by using the {{ic|filter:}} prefix in the configuration file. For example, write a script that can read HTML from stdin and print out an RSS or Atom feed to stdout. Save that script to {{ic|~/.newsboat/html2rss.sh}} and add the following line to the {{ic|urls}}:<br />
<br />
<nowiki>filter:~/.newsboat/html2rss.sh:https://myurl.com</nowiki><br />
<br />
* For several examples using this strategy, see [https://github.com/graysky2/newsboat_custom_stuff graysky's newsboat repo].<br />
* For more discussion, see [https://github.com/newsboat/newsboat/issues/1157 Possible to config newsboat to look at a web exposed directory and report changes #1157].<br />
<br />
=== Tagging feeds ===<br />
<br />
Every feed can be assigned 0 or more tags. This makes it easy to categorize your feeds as well as the ability to easily apply commands to multiple feeds at once.<br />
<br />
Usually, the {{ic|~/.newsboat/urls}} file contains one RSS feed URL per line. To assign a tag to an RSS feed, simply attach it as a single word, separated by blanks such as space or tab. If the tag needs to contain spaces, use quotes (") around the tag (see example below). An example may look like this:<br />
<br />
<nowiki>http://blog.fefe.de/rss.xml?html interesting conspiracy news "cool stuff"</nowiki><br />
<nowiki>http://rss.orf.at/news.xml news orf</nowiki><br />
<nowiki>http://www.heise.de/newsticker/heise.rdf news interesting</nowiki><br />
<br />
Starting Newsboat with this configuration, one can press {{ic|t}} to select a tag. Upon selecting the tag "news", one will see all three RSS feeds. Pressing {{ic|t}} again and e.g. selecting the "conspiracy" tag, will only show the {{ic|<nowiki>http://blog.fefe.de/rss.xml?html</nowiki>}} RSS feed. Pressing {{ic|Ctrl-T}} clears the current tag,<br />
and again shows all RSS feeds, regardless of their assigned tags.<br />
<br />
{{Note| If the tag name contains spaces, the tag must be bounded by {{ic|"}}}}<br />
<br />
==== Special tags ====<br />
<br />
===== Custom feed names =====<br />
<br />
The name of a feed can be defined with a special tag in your urls file. Simply '''prefix''' the tag name with the {{ic|~}} character and the tag name will become the feed name.<br />
<br />
For example:<br />
<br />
<nowiki>http://rss.cnn.com/rss/cnn_topstories.rss</nowiki> "~CNN Top stories"<br />
<br />
will define the feed with feed-name "CNN Top stories"<br />
<br />
===== Hidden feeds =====<br />
<br />
A feed can be '''hidden''' from the regular list of feeds by '''prefixing''' the tag name with an {{ic|!}}.<br />
<br />
For example:<br />
<br />
<nowiki>http://rss.orf.at/news.xml</nowiki> "!ORF News (hidden)"<br />
<br />
The content of a '''hidden''' feed can only be found through a query feed.<br />
<br />
=== Query feeds ===<br />
<br />
Custom feeds can be created from existing feeds by creating what is called a ''query feed'': A feed generated by matching articles against a query. Query feeds are defined in your {{ic|~/.config/newsboat/urls}} file like a normal feed.<br />
They have the following syntax:<br />
<br />
<nowiki>query:FEEDNAME:FILTER_EXPRESSION [TAG ...]</nowiki><br />
<br />
Like a normal feed, a query feed has a name, {{ic|FEEDNAME}}, which is displayed in the feedlist.<br />
The filter expression language for {{ic|FILTER_EXPRESSION}} is defined in the [https://newsboat.org/releases/2.13/docs/newsboat.html#_filter_language newsboat manual].<br />
Query feeds can be optionally tagged, just like a normal feed. See [[#Tagging feeds]].<br />
<br />
==== Basic examples ====<br />
<br />
{{hc|~/.config/newsboat/urls|2=<br />
"query:Example1:age > 1"<br />
"query:Example2:(tags # \"example2\") and (title =~ \"example2\")"<br />
"query:Example3:(rssurl =~ \"example3\") or (total_count > 3)"<br />
}}<br />
<br />
The first example defines a feed named {{ic|Example1}} that will contain all articles that are older than a day<br />
<br />
The second example defines a feed named {{ic|Example2}} that will contain all articles whose feed was tagged {{ic|example2}}<br />
'''and''' whose article title matches {{ic|example2}}. Here the {{ic|#}} is the "contains" operator.<br />
<br />
The third example defines a feed named {{ic|Example3}} that will contain all articles whose feed url matches the<br />
regular expression {{ic|example3}} '''or''' all articles that are apart of a feed that contain more than 3 articles.<br />
<br />
{{Note|The query feed definition must be encapsulated in double quotes. Therefore any other double quotes in its declaration must be escaped}}<br />
<br />
==== Unread articles ====<br />
<br />
To create a feed named {{ic|Unread Articles}} that contains all unread articles, define the following:<br />
<br />
{{hc|~/.config/newsboat/urls|<br />
"query:Unread Articles:unread {{=}} \"yes\""<br />
}}<br />
<br />
==== Amalgamating multiple feeds into one ====<br />
<br />
A good use of query feeds is when you are following a creator whose content is spread across multiple feeds. You can use a query feed to amalgamate all his content into one place.<br />
<br />
{{hc|~/.config/newsboat/urls|<br />
"query:Metafeed:tags # \"metafeed\""<nowiki><br />
https://feed.url/1 metafeed !<br />
https://feed.url/2 metafeed !<br />
https://feed.url/3 metafeed !<br />
</nowiki>}}<br />
<br />
The trick is to assign each individual feed a unique tag - here {{ic|metafeed}} - so that we can match against it in the filter expression. We also make use of [[#Hidden feeds]] - the {{ic|!}} at the end of each feed - so that the individual feeds do not show up in the feedlist.<br />
<br />
==== Filtering a specific feed ====<br />
<br />
If a feed contains content you do not want to see, you can filter it by using a query feed.<br />
For example, to monitor package updates you're interested in, you can use:<br />
<br />
{{hc|~/.config/newsboat/urls|<br />
"query:Package Updates:(tags # \"packageupdates\") and (title {{=}}~ \"linux [0-9]{{!}}newsboat\")"<br />
<nowiki>https://archlinux.org/feeds/packages/</nowiki> packageupdates !<br />
}}<br />
<br />
This feed will only display updates to {{Pkg|linux}} and {{Pkg|newsboat}}.<br />
<br />
=== Ignoring articles ===<br />
<br />
As with [[#Filtering a specific feed|query feeds]], another way to filter feeds is by using the {{ic|ignore-article}} command in your {{ic|~/.config/newsboat/config}}. It has the following syntax<br />
<br />
ignore-article FEEDURL FILTER_EXPRESSION<br />
<br />
==== Examples ====<br />
<br />
{{hc|~/.config/newsboat/config|<nowiki><br />
ignore-article "https://feed/url1" "content =~ \"tele(phone|communications)\"" <br />
ignore-article "https://feed/url2" "title =~ \"text_1|text_2\""<br />
</nowiki>}}<br />
<br />
The first example will ignore all articles in {{ic|<nowiki>https://feed/url1</nowiki>}} whose content matches<br />
{{ic|tele(phone{{!}}communications)}}<br />
<br />
The second example will ignore all articles in {{ic|<nowiki>https://feed/url2</nowiki>}} whose title matches {{ic|text_1{{!}}text_2}}<br />
<br />
==== Ignore modes ====<br />
<br />
In contrast to filtering with query feeds, Newsboat allows you to decide what to do with articles that match an {{ic|ignore-article}} command: you can delete them or not show them.<br />
<br />
{{hc|~/.config/newsboat/config|<br />
# ignore-mode "download" # Default: Delete them.<br />
# ignore-mode "display" # Do not show them.<br />
}}<br />
<br />
==== Comparison with query feeds ====<br />
<br />
In terms of pure filtering, whatever you can do with {{ic|ignore-article}} you can also do with a [[#Filtering a specific feed|query feed]].<br />
<br />
Query feeds are defined in your {{ic|~/.config/newsboat/urls}} file while {{ic|ignore-article}} commands are placed in your {{ic|~/.config/newsboat/config}}. So if you prefer having all feed related things in one place, you might want to stick<br />
to using query feeds.<br />
<br />
However if you want to save space and prevent newsboat from downloading certain articles, then<br />
using {{ic|ignore-article}} is your only choice.<br />
<br />
== Configuration ==<br />
<br />
Several aspects of Newsboat’s behaviour can be configured via a configuration file which is located, by default, in {{ic|~/.newsboat/config}} or {{ic|~/.config/newsboat/config}}. This configuration file contains lines of the form:<br />
<br />
<config-command> <arg1> ...<br />
<br />
=== Color schemes ===<br />
<br />
The package ships with a number of schemes in {{ic|/usr/share/doc/newsboat/contrib/colorschemes/}} which can be loaded with the include command like so:<br />
<br />
include /usr/share/doc/newsboat/contrib/colorschemes/inkpot<br />
<br />
=== Additional options ===<br />
<br />
The configuration file can also contain comments, which start with the {{ic|#}} character and go as far as the end of line. To enter a configuration argument that contains spaces, use quotes {{ic|"}} around the whole argument. It is even possible to integrate the output of external commands into the configuration. The text between two backticks {{ic|`}} is evaluated as shell command, and its output is put on its place instead. This works like backtick evaluation in Bourne-compatible shells and allows users to use external information from the system within the configuration.<br />
<br />
See [https://gist.github.com/anonymous/42d2f5956e7bc8ee1ebc] and [http://moparx.com/configs/newsbeuter/] for example configurations.<br />
<br />
{{Note|To see a complete list of configuration command, consult {{man|1|newsboat|CONFIGURATION COMMANDS}}.}}<br />
<br />
== Tips and tricks ==<br />
<br />
=== Automatic feed reloads ===<br />
<br />
Newsboat can automatically reload all feeds on startup with the following configuration:<br />
<br />
auto-reload yes<br />
<br />
With this setting, Newsboat also runs periodic auto-reloads – by default, every 60 minutes. The number of minutes between automatic reloads can be configured like so:<br />
<br />
reload-time <desired number of minutes><br />
<br />
Alternatively, use [[cron]] or [[systemd]] to automatically reload feeds. Just add a line in your crontab, or create a systemd service/timer unit combo that issues the following command:<br />
<br />
/usr/bin/newsboat -x reload<br />
<br />
=== Loading of feeds in parallel for faster updates ===<br />
<br />
By default, Newsboat will attempt to update entries in {{ic|~/.newsboat/urls}} in sequence; however, the following setting will update them n at a time, in parallel. Adjust n to your liking.<br />
<br />
reload-threads 100<br />
<br />
=== Pass article URL to external command ===<br />
<br />
A clever little hack allows one to pass the URL of an article to an external command. The idea is to use a macro to set the browser that Newsboat opens the article with to the path of some other command and then change it back afterwards.<br />
<br />
For example, subscribers of a particular youtube channel can open the video with [[mpv]], by doing the following:<br />
<br />
macro y set browser "mpv %u" ; open-in-browser ; set browser "elinks %u"<br />
<br />
{{Note| First press the {{ic|,}} key, followed by the keybind to use the macro. In the example above, type {{ic|,}} + {{ic|y}} }}<br />
<br />
=== Subheadings ===<br />
<br />
There is another little hack that allows the user to add subheadings to sort feeds more effectively. This hack involves adding fake feeds to the {{ic|urls}} file like so:<br />
<br />
---Heading---<br />
<br />
{{Note|the {{ic|---}} characters are optional but having some sort of character identifying the headings is useful for styling.}}<br />
<br />
Then in {{ic|~/.config/newsboat/config}}, add the following two lines:<br />
<br />
highlight feedlist "---.*---" ''COLOR_OF_YOUR_CHOOSING'' default bold<br />
highlight feedlist ".*0/0.." default default invis<br />
<br />
Of course, replace {{ic|''COLOR_OF_YOUR_CHOOSING''}} with a [https://newsboat.org/releases/2.24/docs/newsboat.html#_configuring_colors newsboat supported color].<br />
<br />
This trick can also interact with Tags by replacing {{ic|---Heading---}} with:<br />
<br />
"query:---Heading---:tags # \"Tag\""<br />
<br />
Then tagging all the feeds below the heading with {{ic|Tag}}.<br />
<br />
== Troubleshooting ==<br />
<br />
=== Newsboat will not start ===<br />
<br />
Newsboat cannot start without any configured feeds! To add URLs, see [[#Managing feeds]]. If that is not the problem, check to see if another instance of Newsboat is running. Newsboat issues a lock on its database so that only one instance can access it at a time; thus, attempting to open a second instance will fail.<br />
<br />
== See also ==<br />
<br />
*[https://newsboat.org/ Official web site]<br />
*[https://newsboat.org/releases/2.24/docs/newsboat.html Full documentation]<br />
*[https://sanctum.geek.nz/arabesque/rss-with-newsboat/ Arabesque: RSS with Newsboat]</div>Captaincurriehttps://wiki.archlinux.org/index.php?title=Newsboat&diff=766276Newsboat2023-02-02T17:23:15Z<p>Captaincurrie: /* Filtering a specific feed */ grammer</p>
<hr />
<div>[[Category:News aggregators]]<br />
[[Category:Console applications]]<br />
[[ja:Newsboat]]<br />
{{Related articles start}}<br />
{{Related|Web feed}}<br />
{{Related articles end}}<br />
<br />
[https://newsboat.org/ Newsboat] is an open source news aggregator licensed under the MIT License.<br />
<br />
From {{man|1|newsboat|DESCRIPTION}}:<br />
<br />
:Newsboat is an RSS/Atom feed reader for text terminals. RSS and Atom are a number of widely-used XML formats to transmit, publish and syndicate articles, for example news or blog articles. Newsboat is designed to be used on text terminals on Unix or Unix-like systems such as GNU/Linux, BSD or macOS. <br />
<br />
Newsboat is a [https://groups.google.com/forum/#!topic/newsbeuter/RPtlWX8CPGU fork] of abandoned Newsbeuter.<br />
<br />
== Installation ==<br />
<br />
[[Install]] the {{Pkg|newsboat}} package. For the development version, install the {{AUR|newsboat-git}} package.<br />
<br />
== Usage ==<br />
<br />
Newsboat cannot start without any configured feeds. Feeds can be configured in {{ic|~/.newsboat/urls}}. Newsboat can be started from the command line with<br />
<br />
$ newsboat<br />
<br />
Press the {{ic|?}} key to see a list of all keybindings. Keybindings can be rebound, see [[#Configuration]].<br />
<br />
== Managing feeds ==<br />
<br />
Adding, removing, and tagging feeds is done by editing the urls file. By default that is {{ic|~/.newsboat/urls}}.<br />
<br />
{{Tip|In addition to newsboat specific feeds in this section, be sure to see the [[Web feed]] article for additional options.}}<br />
<br />
=== RSS or ATOM sources ===<br />
<br />
To add URLs, open {{ic|~/.newsboat/urls}} with your favorite text editor and add the URLs, one per line:<br />
<br />
<nowiki>http://rss.cnn.com/rss/cnn_topstories.rss</nowiki><br />
<nowiki>http://newsrss.bbc.co.uk/rss/newsonline_world_edition/front_page/rss.xml</nowiki><br />
<br />
To add URLs that have restricted access via username/password, simply provide the username/password in the following way:<br />
<br />
<nowiki>http://username:password@hostname.domain.tld/feed.rss</nowiki><br />
<br />
In order to protect username and password, make sure that {{ic|~/.newsboat/urls}} has the appropriate permissions. Newsboat also makes sure that usernames and passwords within URLs aren’t displayed in its user interface. In case there is a @ in the username, type it as %40 instead so that it can be distinguished from the @ that separates the username/password part from the hostname part.<br />
<br />
To configure local files as feeds, simply prefix the local path with {{ic|file://}} and add it to the {{ic|~/.newsboat/urls}} file:<br />
<br />
file:///var/log/rss_eventlog.xml<br />
<br />
=== HTML as a source ===<br />
<br />
If HTML sources can be converted to RSS via a user supplied script, newboat can both execute this script and consume the output.<br />
<br />
This is accomplished by using the {{ic|filter:}} prefix in the configuration file. For example, write a script that can read HTML from stdin and print out an RSS or Atom feed to stdout. Save that script to {{ic|~/.newsboat/html2rss.sh}} and add the following line to the {{ic|urls}}:<br />
<br />
<nowiki>filter:~/.newsboat/html2rss.sh:https://myurl.com</nowiki><br />
<br />
* For several examples using this strategy, see [https://github.com/graysky2/newsboat_custom_stuff graysky's newsboat repo].<br />
* For more discussion, see [https://github.com/newsboat/newsboat/issues/1157 Possible to config newsboat to look at a web exposed directory and report changes #1157].<br />
<br />
=== Tagging feeds ===<br />
<br />
Every feed can be assigned 0 or more tags. This makes it easy to categorize your feeds as well as the ability to easily apply commands to multiple feeds at once.<br />
<br />
Usually, the {{ic|~/.newsboat/urls}} file contains one RSS feed URL per line. To assign a tag to an RSS feed, simply attach it as a single word, separated by blanks such as space or tab. If the tag needs to contain spaces, use quotes (") around the tag (see example below). An example may look like this:<br />
<br />
<nowiki>http://blog.fefe.de/rss.xml?html interesting conspiracy news "cool stuff"</nowiki><br />
<nowiki>http://rss.orf.at/news.xml news orf</nowiki><br />
<nowiki>http://www.heise.de/newsticker/heise.rdf news interesting</nowiki><br />
<br />
Starting Newsboat with this configuration, one can press {{ic|t}} to select a tag. Upon selecting the tag "news", one will see all three RSS feeds. Pressing {{ic|t}} again and e.g. selecting the "conspiracy" tag, will only show the {{ic|<nowiki>http://blog.fefe.de/rss.xml?html</nowiki>}} RSS feed. Pressing {{ic|Ctrl-T}} clears the current tag,<br />
and again shows all RSS feeds, regardless of their assigned tags.<br />
<br />
{{Note| If the tag name contains spaces, the tag must be bounded by {{ic|"}}}}<br />
<br />
==== Special tags ====<br />
<br />
===== Custom feed names =====<br />
<br />
The name of a feed can be defined with a special tag in your urls file. Simply '''prefix''' the tag name with the {{ic|~}} character and the tag name will become the feed name.<br />
<br />
For example:<br />
<br />
<nowiki>http://rss.cnn.com/rss/cnn_topstories.rss</nowiki> "~CNN Top stories"<br />
<br />
will define the feed with feed-name "CNN Top stories"<br />
<br />
===== Hidden feeds =====<br />
<br />
A feed can be '''hidden''' from the regular list of feeds by '''prefixing''' the tag name with an {{ic|!}}.<br />
<br />
For example:<br />
<br />
<nowiki>http://rss.orf.at/news.xml</nowiki> "!ORF News (hidden)"<br />
<br />
The content of a '''hidden''' feed can only be found through a query feed.<br />
<br />
=== Query feeds ===<br />
<br />
Custom feeds can be created from existing feeds by creating what is called a ''query feed'': A feed generated by matching articles against a query. Query feeds are defined in your {{ic|~/.config/newsboat/urls}} file like a normal feed.<br />
They have the following syntax:<br />
<br />
<nowiki>query:FEEDNAME:FILTER_EXPRESSION [TAG ...]</nowiki><br />
<br />
Like a normal feed, a query feed has a name, {{ic|FEEDNAME}}, which is displayed in the feedlist.<br />
The filter expression language for {{ic|FILTER_EXPRESSION}} is defined in the [https://newsboat.org/releases/2.13/docs/newsboat.html#_filter_language newsboat manual].<br />
Query feeds can be optionally tagged, just like a normal feed. See [[#Tagging feeds]].<br />
<br />
==== Basic examples ====<br />
<br />
{{hc|~/.config/newsboat/urls|2=<br />
"query:Example1:age > 1"<br />
"query:Example2:(tags # \"example2\") and (title =~ \"example2\")"<br />
"query:Example3:(rssurl =~ \"example3\") or (total_count > 3)"<br />
}}<br />
<br />
The first example defines a feed named {{ic|Example1}} that will contain all articles that are older than a day<br />
<br />
The second example defines a feed named {{ic|Example2}} that will contain all articles whose feed was tagged {{ic|example2}}<br />
'''and''' whose article title matches {{ic|example2}}. Here the {{ic|#}} is the "contains" operator.<br />
<br />
The third example defines a feed named {{ic|Example3}} that will contain all articles whose feed url matches the<br />
regular expression {{ic|example3}} '''or''' all articles that are apart of a feed that contain more than 3 articles.<br />
<br />
{{Note|The query feed definition must be encapsulated in double quotes. Therefore any other double quotes in its declaration must be escaped}}<br />
<br />
==== Unread articles ====<br />
<br />
To create a feed named {{ic|Unread Articles}} that contains all unread articles, define the following:<br />
<br />
{{hc|~/.config/newsboat/urls|<br />
"query:Unread Articles:unread {{=}} \"yes\""<br />
}}<br />
<br />
==== Amalgamating multiple feeds into one ====<br />
<br />
A good use of query feeds is when you are following a creator whose content is spread across multiple feeds. You can use a query feed to amalgamate all his content into one place.<br />
<br />
{{hc|~/.config/newsboat/urls|<br />
"query:Metafeed:tags # \"metafeed\""<nowiki><br />
https://feed.url/1 metafeed !<br />
https://feed.url/2 metafeed !<br />
https://feed.url/3 metafeed !<br />
</nowiki>}}<br />
<br />
The trick is to assign each individual feed a unique tag - here {{ic|metafeed}} - so that we can match against it in the filter expression. We also make use of [[#Hidden feeds]] - the {{ic|!}} at the end of each feed - so that the individual feeds do not show up in the feedlist.<br />
<br />
==== Filtering a specific feed ====<br />
<br />
If a feed contains content you do not want to see, you can filter it by using a query feed.<br />
For example, to monitor package updates you're interested in, you can use:<br />
<br />
{{hc|~/.config/newsboat/urls|<br />
"query:Package Updates:(tags # \"packageupdates\") and (title {{=}}~ \"linux [0-9]{{!}}newsboat\")"<br />
<nowiki>https://archlinux.org/feeds/packages/</nowiki> packageupdates !<br />
}}<br />
<br />
This feed will only display updates to {{Pkg|linux}} and {{Pkg|newsboat}}.<br />
<br />
=== Ignoring articles ===<br />
<br />
As with [[#Filtering a specific feed|query feeds]], another way to filter feeds is by using the {{ic|ignore-article}} command in your {{ic|~/.config/newsboat/config}}. It has the following syntax<br />
<br />
ignore-article FEEDURL FILTER_EXPRESSION<br />
<br />
==== Examples ====<br />
<br />
{{hc|~/.config/newsboat/config|<nowiki><br />
ignore-article "https://feed/url1" "content =~ \"tele(phone|communications)\"" <br />
ignore-article "https://feed/url2" "title =~ \"text_1|text_2\""<br />
</nowiki>}}<br />
<br />
The first example will ignore all articles in {{ic|<nowiki>https://feed/url1</nowiki>}} whose content matches<br />
{{ic|tele(phone{{!}}communications)}}<br />
<br />
The second example will ignore all articles in {{ic|<nowiki>https://feed/url2</nowiki>}} whose title matches {{ic|text_1{{!}}text_2}}<br />
<br />
==== Ignore modes ====<br />
<br />
In contrast to filtering with query feeds, Newsboat allows you to decide what to do with articles that match an {{ic|ignore-article}} command: you can delete them or not show them.<br />
<br />
{{hc|~/.config/newsboat/config|<br />
# ignore-mode "download" # Default: Delete them.<br />
# ignore-mode "display" # Do not show them.<br />
}}<br />
<br />
==== Comparison with query feeds ====<br />
<br />
In terms of pure filtering, whatever you can do with {{ic|ignore-article}} you can also do with a [[#Filtering a specific feed|query feed]].<br />
<br />
Query feeds are defined in your {{ic|~/.config/newsboat/urls}} file while {{ic|ignore-article}} commands are placed in your {{ic|~/.config/newsboat/config}}. So if you prefer having all feed related things in one place, you might want to stick<br />
to using query feeds.<br />
<br />
However if you want to save space and prevent newsboat from downloading certain articles, then<br />
using {{ic|ignore-article}} is your only choice.<br />
<br />
== Configuration ==<br />
<br />
Several aspects of Newsboat’s behaviour can be configured via a configuration file which is located, by default, in {{ic|~/.newsboat/config}} or {{ic|~/.config/newsboat/config}}. This configuration file contains lines of the form:<br />
<br />
<config-command> <arg1> ...<br />
<br />
=== Color schemes ===<br />
<br />
The package ships with a number of schemes in {{ic|/usr/share/doc/newsboat/contrib/colorschemes/}} which can be loaded with the include command like so:<br />
<br />
include /usr/share/doc/newsboat/contrib/colorschemes/inkpot<br />
<br />
=== Additional options ===<br />
<br />
The configuration file can also contain comments, which start with the {{ic|#}} character and go as far as the end of line. To enter a configuration argument that contains spaces, use quotes {{ic|"}} around the whole argument. It is even possible to integrate the output of external commands into the configuration. The text between two backticks {{ic|`}} is evaluated as shell command, and its output is put on its place instead. This works like backtick evaluation in Bourne-compatible shells and allows users to use external information from the system within the configuration.<br />
<br />
See [https://gist.github.com/anonymous/42d2f5956e7bc8ee1ebc] and [http://moparx.com/configs/newsbeuter/] for example configurations.<br />
<br />
{{Note|To see a complete list of configuration command, consult {{man|1|newsboat|CONFIGURATION COMMANDS}}.}}<br />
<br />
== Tips and tricks ==<br />
<br />
=== Automatic feed reloads ===<br />
<br />
Newsboat can automatically reload all feeds on startup with the following configuration:<br />
<br />
auto-reload yes<br />
<br />
With this setting, Newsboat also runs periodic auto-reloads – by default, every 60 minutes. The number of minutes between automatic reloads can be configured like so:<br />
<br />
reload-time <desired number of minutes><br />
<br />
Alternatively, use [[cron]] or [[systemd]] to automatically reload feeds. Just add a line in your crontab, or create a systemd service/timer unit combo that issues the following command:<br />
<br />
/usr/bin/newsboat -x reload<br />
<br />
=== Loading of feeds in parallel for faster updates ===<br />
<br />
By default, Newsboat will attempt to update entries in {{ic|~/.newsboat/urls}} in sequence; however, the following setting will update them n at a time, in parallel. Adjust n to your liking.<br />
<br />
reload-threads 100<br />
<br />
=== Pass article URL to external command ===<br />
<br />
A clever little hack allows one to pass the URL of an article to an external command. The idea is to use a macro to set the browser that Newsboat opens the article with to the path of some other command and then change it back afterwards.<br />
<br />
For example, subscribers of a particular youtube channel can open the video with [[mpv]], by doing the following:<br />
<br />
macro y set browser "mpv %u" ; open-in-browser ; set browser "elinks %u"<br />
<br />
{{Note| First press the {{ic|,}} key, followed by the keybind to use the macro. In the example above, type {{ic|,}} + {{ic|y}} }}<br />
<br />
=== Subheadings ===<br />
<br />
There is another little hack that allows the user to add subheadings to sort feeds more effectively. This hack involves adding fake feeds to the {{ic|urls}} file like so:<br />
<br />
---Heading---<br />
<br />
{{Note|the {{ic|---}} characters are optional but having some sort of character identifying the headings is useful for styling.}}<br />
<br />
Then in {{ic|~/.config/newsboat/config}}, add the following two lines:<br />
<br />
highlight feedlist "---.*---" ''COLOR_OF_YOUR_CHOOSING'' default bold<br />
highlight feedlist ".*0/0.." default default invis<br />
<br />
Of course, replace {{ic|''COLOR_OF_YOUR_CHOOSING''}} with a [https://newsboat.org/releases/2.24/docs/newsboat.html#_configuring_colors newsboat supported color].<br />
<br />
This trick can also interact with Tags by replacing {{ic|---Heading---}} with:<br />
<br />
"query:---Heading---:tags # \"Tag\""<br />
<br />
Then tagging all the feeds below the heading with {{ic|Tag}}.<br />
<br />
== Troubleshooting ==<br />
<br />
=== Newsboat will not start ===<br />
<br />
Newsboat cannot start without any configured feeds! To add URLs, see [[#Managing feeds]]. If that is not the problem, check to see if another instance of Newsboat is running. Newsboat issues a lock on its database so that only one instance can access it at a time; thus, attempting to open a second instance will fail.<br />
<br />
== See also ==<br />
<br />
*[https://newsboat.org/ Official web site]<br />
*[https://newsboat.org/releases/2.24/docs/newsboat.html Full documentation]<br />
*[https://sanctum.geek.nz/arabesque/rss-with-newsboat/ Arabesque: RSS with Newsboat]</div>Captaincurriehttps://wiki.archlinux.org/index.php?title=Newsboat&diff=766158Newsboat2023-02-02T03:22:13Z<p>Captaincurrie: /* Ignoring articles */ formatting links</p>
<hr />
<div>[[Category:News aggregators]]<br />
[[Category:Console applications]]<br />
[[ja:Newsboat]]<br />
{{Related articles start}}<br />
{{Related|Web feed}}<br />
{{Related articles end}}<br />
<br />
[https://newsboat.org/ Newsboat] is an open source news aggregator licensed under the MIT License.<br />
<br />
From {{man|1|newsboat|DESCRIPTION}}:<br />
<br />
:Newsboat is an RSS/Atom feed reader for text terminals. RSS and Atom are a number of widely-used XML formats to transmit, publish and syndicate articles, for example news or blog articles. Newsboat is designed to be used on text terminals on Unix or Unix-like systems such as GNU/Linux, BSD or macOS. <br />
<br />
Newsboat is a [https://groups.google.com/forum/#!topic/newsbeuter/RPtlWX8CPGU fork] of abandoned Newsbeuter.<br />
<br />
== Installation ==<br />
<br />
[[Install]] the {{Pkg|newsboat}} package. For the development version, install the {{AUR|newsboat-git}} package.<br />
<br />
== Usage ==<br />
<br />
Newsboat cannot start without any configured feeds. Feeds can be configured in {{ic|~/.newsboat/urls}}. Newsboat can be started from the command line with<br />
<br />
$ newsboat<br />
<br />
Press the {{ic|?}} key to see a list of all keybindings. Keybindings can be rebound, see [[#Configuration]].<br />
<br />
== Managing feeds ==<br />
<br />
Adding, removing, and tagging feeds is done by editing the urls file. By default that is {{ic|~/.newsboat/urls}}.<br />
<br />
{{Tip|In addition to newsboat specific feeds in this section, be sure to see the [[Web feed]] article for additional options.}}<br />
<br />
=== RSS or ATOM sources ===<br />
<br />
To add URLs, open {{ic|~/.newsboat/urls}} with your favorite text editor and add the URLs, one per line:<br />
<br />
<nowiki>http://rss.cnn.com/rss/cnn_topstories.rss</nowiki><br />
<nowiki>http://newsrss.bbc.co.uk/rss/newsonline_world_edition/front_page/rss.xml</nowiki><br />
<br />
To add URLs that have restricted access via username/password, simply provide the username/password in the following way:<br />
<br />
<nowiki>http://username:password@hostname.domain.tld/feed.rss</nowiki><br />
<br />
In order to protect username and password, make sure that {{ic|~/.newsboat/urls}} has the appropriate permissions. Newsboat also makes sure that usernames and passwords within URLs aren’t displayed in its user interface. In case there is a @ in the username, type it as %40 instead so that it can be distinguished from the @ that separates the username/password part from the hostname part.<br />
<br />
To configure local files as feeds, simply prefix the local path with {{ic|file://}} and add it to the {{ic|~/.newsboat/urls}} file:<br />
<br />
file:///var/log/rss_eventlog.xml<br />
<br />
=== HTML as a source ===<br />
<br />
If HTML sources can be converted to RSS via a user supplied script, newboat can both execute this script and consume the output.<br />
<br />
This is accomplished by using the {{ic|filter:}} prefix in the configuration file. For example, write a script that can read HTML from stdin and print out an RSS or Atom feed to stdout. Save that script to {{ic|~/.newsboat/html2rss.sh}} and add the following line to the {{ic|urls}}:<br />
<br />
<nowiki>filter:~/.newsboat/html2rss.sh:https://myurl.com</nowiki><br />
<br />
* For several examples using this strategy, see [https://github.com/graysky2/newsboat_custom_stuff graysky's newsboat repo].<br />
* For more discussion, see [https://github.com/newsboat/newsboat/issues/1157 Possible to config newsboat to look at a web exposed directory and report changes #1157].<br />
<br />
=== Tagging feeds ===<br />
<br />
Every feed can be assigned 0 or more tags. This makes it easy to categorize your feeds as well as the ability to easily apply commands to multiple feeds at once.<br />
<br />
Usually, the {{ic|~/.newsboat/urls}} file contains one RSS feed URL per line. To assign a tag to an RSS feed, simply attach it as a single word, separated by blanks such as space or tab. If the tag needs to contain spaces, use quotes (") around the tag (see example below). An example may look like this:<br />
<br />
<nowiki>http://blog.fefe.de/rss.xml?html interesting conspiracy news "cool stuff"</nowiki><br />
<nowiki>http://rss.orf.at/news.xml news orf</nowiki><br />
<nowiki>http://www.heise.de/newsticker/heise.rdf news interesting</nowiki><br />
<br />
Starting Newsboat with this configuration, one can press {{ic|t}} to select a tag. Upon selecting the tag "news", one will see all three RSS feeds. Pressing {{ic|t}} again and e.g. selecting the "conspiracy" tag, will only show the {{ic|<nowiki>http://blog.fefe.de/rss.xml?html</nowiki>}} RSS feed. Pressing {{ic|Ctrl-T}} clears the current tag,<br />
and again shows all RSS feeds, regardless of their assigned tags.<br />
<br />
{{Note| If the tag name contains spaces, the tag must be bounded by {{ic|"}}}}<br />
<br />
==== Special tags ====<br />
<br />
===== Custom feed names =====<br />
<br />
The name of a feed can be defined with a special tag in your urls file. Simply '''prefix''' the tag name with the {{ic|~}} character and the tag name will become the feed name.<br />
<br />
For example:<br />
<br />
<nowiki>http://rss.cnn.com/rss/cnn_topstories.rss</nowiki> "~CNN Top stories"<br />
<br />
will define the feed with feed-name "CNN Top stories"<br />
<br />
===== Hidden feeds =====<br />
<br />
A feed can be '''hidden''' from the regular list of feeds by '''prefixing''' the tag name with an {{ic|!}}.<br />
<br />
For example:<br />
<br />
<nowiki>http://rss.orf.at/news.xml</nowiki> "!ORF News (hidden)"<br />
<br />
The content of a '''hidden''' feed can only be found through a query feed.<br />
<br />
=== Query feeds ===<br />
<br />
Custom feeds can be created from existing feeds by creating what's called a ''query feed'': A feed generated by matching articles against a query. Query feeds are defined in your {{ic|~/.config/newsboat/urls}} file like a normal feed.<br />
They have the following syntax:<br />
<br />
<nowiki>query:FEEDNAME:FILTER_EXPRESSION [TAG ...]</nowiki><br />
<br />
Like a normal feed, a query feed has a name, {{ic|FEEDNAME}}, which is displayed in the feedlist.<br />
The filter expression language for {{ic|FILTER_EXPRESSION}} is defined in the [https://newsboat.org/releases/2.13/docs/newsboat.html#_filter_language newsboat manual].<br />
Query feeds can be optionally tagged, just like a normal feed. See [[#Tagging feeds]].<br />
<br />
==== Basic examples ====<br />
<br />
{{hc|~/.config/newsboat/urls|2=<br />
"query:Example1:age > 1"<br />
"query:Example2:(tags # \"example2\") and (title =~ \"example2\")"<br />
"query:Example3:(rssurl =~ \"example3\") or (total_count > 3)"<br />
}}<br />
<br />
The first example defines a feed named {{ic|Example1}} that will contain all articles that are older than a day<br />
<br />
The second example defines a feed named {{ic|Example2}} that will contain all articles whose feed was tagged {{ic|example2}}<br />
'''and''' whose article title matches {{ic|example2}}. Here the {{ic|#}} is the "contains" operator.<br />
<br />
The third example defines a feed named {{ic|Example3}} that will contain all articles whose feed url matches the<br />
regular expression {{ic|example3}} '''or''' all articles that are apart of a feed that contain more than 3 articles.<br />
<br />
{{Note|The query feed definition must be encapsulated in double quotes. Therefore any other double quotes in its declaration must be escaped}}<br />
<br />
==== Unread articles ====<br />
<br />
To create a feed named {{ic|Unread Articles}} that contains all unread articles, define the following:<br />
<br />
{{hc|~/.config/newsboat/urls|<br />
"query:Unread Articles:unread {{=}} \"yes\""<br />
}}<br />
<br />
==== Amalgamating multiple feeds into one ====<br />
<br />
A good use of query feeds is when you're following a creator whose content is spread across multiple feeds. You can use a query feed to amalgamate all his content into one place.<br />
<br />
{{hc|~/.config/newsboat/urls|<br />
"query:Metafeed:tags # \"metafeed\""<nowiki><br />
https://feed.url/1 metafeed !<br />
https://feed.url/2 metafeed !<br />
https://feed.url/3 metafeed !<br />
</nowiki>}}<br />
<br />
The trick is to assign each individual feed a unique tag - here {{ic|metafeed}} - so that we can match against it in the filter expression. We also make use of [[#Hidden feeds]] - the {{ic|!}} at the end of each feed - so that the individual feeds do not show up in the feedlist.<br />
<br />
==== Filtering a specific feed ====<br />
<br />
If a feed contains content you do not want to see, you can filter it by using a query feed.<br />
For example, to monitor package updates you're interested in, you can use:<br />
<br />
{{hc|~/.config/newsboat/urls|<br />
"query:Package Updates:(tags # \"packageupdates\") and (title {{=}}~ \"linux [0-9]{{!}}newsboat\")"<br />
<nowiki>https://archlinux.org/feeds/packages/</nowiki> packageupdates !<br />
}}<br />
<br />
This feed will only display updates to {{Pkg|linux}} and {{Pkg|newsboat}}.<br />
<br />
=== Ignoring articles ===<br />
<br />
As with [[#Filtering a specific feed|query feeds]], another way to filter feeds is by using the {{ic|ignore-article}} command in your {{ic|~/.config/newsboat/config}}. It has the following syntax<br />
<br />
ignore-article FEEDURL FILTER_EXPRESSION<br />
<br />
==== Examples ====<br />
{{hc|~/.config/newsboat/config|<nowiki><br />
ignore-article "https://feed/url1" "content =~ \"tele(phone|communications)\"" <br />
ignore-article "https://feed/url2" "title =~ \"text_1|text_2\""<br />
</nowiki>}}<br />
<br />
The first example will ignore all articles in {{ic|<nowiki>https://feed/url1</nowiki>}} whose content matches<br />
{{ic|tele(phone{{!}}communications)}}<br />
<br />
The second example will ignore all articles in {{ic|<nowiki>https://feed/url2</nowiki>}} whose title matches {{ic|text_1{{!}}text_2}}<br />
<br />
==== Ignore modes ====<br />
<br />
In contrast to filtering with query feeds, Newsboat allows you to decide what to do with articles that match an {{ic|ignore-article}} command: you can delete them or not show them.<br />
<br />
{{hc|~/.config/newsboat/config|<br />
# ignore-mode "download" # Default: Delete them.<br />
# ignore-mode "display" # Do not show them.<br />
}}<br />
<br />
==== Comparison with query feeds ====<br />
<br />
In terms of pure filtering, whatever you can do with {{ic|ignore-article}} you can also do with a [[#Filtering a specific feed|query feed]].<br />
<br />
Query feeds are defined in your {{ic|~/.config/newsboat/urls}} file while {{ic|ignore-article}} commands are placed in your {{ic|~/.config/newsboat/config}}. So if you prefer having all feed related things in one place, you might want to stick<br />
to using query feeds.<br />
<br />
However if you want to save space and prevent newsboat from downloading certain articles, then<br />
using {{ic|ignore-article}} is your only choice.<br />
<br />
== Configuration ==<br />
<br />
Several aspects of Newsboat’s behaviour can be configured via a configuration file which is located, by default, in {{ic|~/.newsboat/config}} or {{ic|~/.config/newsboat/config}}. This configuration file contains lines of the form:<br />
<br />
<config-command> <arg1> ...<br />
<br />
=== Color schemes ===<br />
<br />
The package ships with a number of schemes in {{ic|/usr/share/doc/newsboat/contrib/colorschemes/}} which can be loaded with the include command like so:<br />
<br />
include /usr/share/doc/newsboat/contrib/colorschemes/inkpot<br />
<br />
=== Additional options ===<br />
<br />
The configuration file can also contain comments, which start with the {{ic|#}} character and go as far as the end of line. To enter a configuration argument that contains spaces, use quotes {{ic|"}} around the whole argument. It’s even possible to integrate the output of external commands into the configuration. The text between two backticks {{ic|`}} is evaluated as shell command, and its output is put on its place instead. This works like backtick evaluation in Bourne-compatible shells and allows users to use external information from the system within the configuration.<br />
<br />
See [https://gist.github.com/anonymous/42d2f5956e7bc8ee1ebc] and [http://moparx.com/configs/newsbeuter/] for example configurations.<br />
<br />
{{Note|To see a complete list of configuration command, consult {{man|1|newsboat|CONFIGURATION COMMANDS}}.}}<br />
<br />
== Tips and tricks ==<br />
<br />
=== Automatic feed reloads ===<br />
<br />
Newsboat can automatically reload all feeds on startup with the following configuration:<br />
<br />
auto-reload yes<br />
<br />
With this setting, Newsboat also runs periodic auto-reloads – by default, every 60 minutes. The number of minutes between automatic reloads can be configured like so:<br />
<br />
reload-time <desired number of minutes><br />
<br />
Alternatively, use [[cron]] or [[systemd]] to automatically reload feeds. Just add a line in your crontab, or create a systemd service/timer unit combo that issues the following command:<br />
<br />
/usr/bin/newsboat -x reload<br />
<br />
=== Loading of feeds in parallel for faster updates ===<br />
<br />
By default, Newsboat will attempt to update entries in {{ic|~/.newsboat/urls}} in sequence; however, the following setting will update them n at a time, in parallel. Adjust n to your liking.<br />
<br />
reload-threads 100<br />
<br />
=== Pass article URL to external command ===<br />
<br />
A clever little hack allows one to pass the URL of an article to an external command. The idea is to use a macro to set the browser that Newsboat opens the article with to the path of some other command and then change it back afterwards.<br />
<br />
For example, subscribers of a particular youtube channel can open the video with [[mpv]], by doing the following:<br />
<br />
macro y set browser "mpv %u" ; open-in-browser ; set browser "elinks %u"<br />
<br />
{{Note| First press the {{ic|,}} key, followed by the keybind to use the macro. In the example above, type {{ic|,}} + {{ic|y}} }}<br />
<br />
=== Subheadings ===<br />
<br />
There is another little hack that allows the user to add subheadings to sort feeds more effectively. This hack involves adding fake feeds to the {{ic|urls}} file like so:<br />
<br />
---Heading---<br />
<br />
{{Note|the {{ic|---}} characters are optional but having some sort of character identifying the headings is useful for styling.}}<br />
<br />
Then in {{ic|~/.config/newsboat/config}}, add the following two lines:<br />
<br />
highlight feedlist "---.*---" ''COLOR_OF_YOUR_CHOOSING'' default bold<br />
highlight feedlist ".*0/0.." default default invis<br />
<br />
Of course, replace {{ic|''COLOR_OF_YOUR_CHOOSING''}} with a [https://newsboat.org/releases/2.24/docs/newsboat.html#_configuring_colors newsboat supported color].<br />
<br />
This trick can also interact with Tags by replacing {{ic|---Heading---}} with:<br />
<br />
"query:---Heading---:tags # \"Tag\""<br />
<br />
Then tagging all the feeds below the heading with {{ic|Tag}}.<br />
<br />
== Troubleshooting ==<br />
<br />
=== Newsboat will not start ===<br />
<br />
Newsboat cannot start without any configured feeds! To add URLs, see [[#Managing feeds]]. If that is not the problem, check to see if another instance of Newsboat is running. Newsboat issues a lock on its database so that only one instance can access it at a time; thus, attempting to open a second instance will fail.<br />
<br />
== See also ==<br />
<br />
*[https://newsboat.org/ Official web site]<br />
*[https://newsboat.org/releases/2.24/docs/newsboat.html Full documentation]<br />
*[https://sanctum.geek.nz/arabesque/rss-with-newsboat/ Arabesque: RSS with Newsboat]</div>Captaincurriehttps://wiki.archlinux.org/index.php?title=Newsboat&diff=766157Newsboat2023-02-02T03:21:40Z<p>Captaincurrie: /* Ignoring articles */ fixed links</p>
<hr />
<div>[[Category:News aggregators]]<br />
[[Category:Console applications]]<br />
[[ja:Newsboat]]<br />
{{Related articles start}}<br />
{{Related|Web feed}}<br />
{{Related articles end}}<br />
<br />
[https://newsboat.org/ Newsboat] is an open source news aggregator licensed under the MIT License.<br />
<br />
From {{man|1|newsboat|DESCRIPTION}}:<br />
<br />
:Newsboat is an RSS/Atom feed reader for text terminals. RSS and Atom are a number of widely-used XML formats to transmit, publish and syndicate articles, for example news or blog articles. Newsboat is designed to be used on text terminals on Unix or Unix-like systems such as GNU/Linux, BSD or macOS. <br />
<br />
Newsboat is a [https://groups.google.com/forum/#!topic/newsbeuter/RPtlWX8CPGU fork] of abandoned Newsbeuter.<br />
<br />
== Installation ==<br />
<br />
[[Install]] the {{Pkg|newsboat}} package. For the development version, install the {{AUR|newsboat-git}} package.<br />
<br />
== Usage ==<br />
<br />
Newsboat cannot start without any configured feeds. Feeds can be configured in {{ic|~/.newsboat/urls}}. Newsboat can be started from the command line with<br />
<br />
$ newsboat<br />
<br />
Press the {{ic|?}} key to see a list of all keybindings. Keybindings can be rebound, see [[#Configuration]].<br />
<br />
== Managing feeds ==<br />
<br />
Adding, removing, and tagging feeds is done by editing the urls file. By default that is {{ic|~/.newsboat/urls}}.<br />
<br />
{{Tip|In addition to newsboat specific feeds in this section, be sure to see the [[Web feed]] article for additional options.}}<br />
<br />
=== RSS or ATOM sources ===<br />
<br />
To add URLs, open {{ic|~/.newsboat/urls}} with your favorite text editor and add the URLs, one per line:<br />
<br />
<nowiki>http://rss.cnn.com/rss/cnn_topstories.rss</nowiki><br />
<nowiki>http://newsrss.bbc.co.uk/rss/newsonline_world_edition/front_page/rss.xml</nowiki><br />
<br />
To add URLs that have restricted access via username/password, simply provide the username/password in the following way:<br />
<br />
<nowiki>http://username:password@hostname.domain.tld/feed.rss</nowiki><br />
<br />
In order to protect username and password, make sure that {{ic|~/.newsboat/urls}} has the appropriate permissions. Newsboat also makes sure that usernames and passwords within URLs aren’t displayed in its user interface. In case there is a @ in the username, type it as %40 instead so that it can be distinguished from the @ that separates the username/password part from the hostname part.<br />
<br />
To configure local files as feeds, simply prefix the local path with {{ic|file://}} and add it to the {{ic|~/.newsboat/urls}} file:<br />
<br />
file:///var/log/rss_eventlog.xml<br />
<br />
=== HTML as a source ===<br />
<br />
If HTML sources can be converted to RSS via a user supplied script, newboat can both execute this script and consume the output.<br />
<br />
This is accomplished by using the {{ic|filter:}} prefix in the configuration file. For example, write a script that can read HTML from stdin and print out an RSS or Atom feed to stdout. Save that script to {{ic|~/.newsboat/html2rss.sh}} and add the following line to the {{ic|urls}}:<br />
<br />
<nowiki>filter:~/.newsboat/html2rss.sh:https://myurl.com</nowiki><br />
<br />
* For several examples using this strategy, see [https://github.com/graysky2/newsboat_custom_stuff graysky's newsboat repo].<br />
* For more discussion, see [https://github.com/newsboat/newsboat/issues/1157 Possible to config newsboat to look at a web exposed directory and report changes #1157].<br />
<br />
=== Tagging feeds ===<br />
<br />
Every feed can be assigned 0 or more tags. This makes it easy to categorize your feeds as well as the ability to easily apply commands to multiple feeds at once.<br />
<br />
Usually, the {{ic|~/.newsboat/urls}} file contains one RSS feed URL per line. To assign a tag to an RSS feed, simply attach it as a single word, separated by blanks such as space or tab. If the tag needs to contain spaces, use quotes (") around the tag (see example below). An example may look like this:<br />
<br />
<nowiki>http://blog.fefe.de/rss.xml?html interesting conspiracy news "cool stuff"</nowiki><br />
<nowiki>http://rss.orf.at/news.xml news orf</nowiki><br />
<nowiki>http://www.heise.de/newsticker/heise.rdf news interesting</nowiki><br />
<br />
Starting Newsboat with this configuration, one can press {{ic|t}} to select a tag. Upon selecting the tag "news", one will see all three RSS feeds. Pressing {{ic|t}} again and e.g. selecting the "conspiracy" tag, will only show the {{ic|<nowiki>http://blog.fefe.de/rss.xml?html</nowiki>}} RSS feed. Pressing {{ic|Ctrl-T}} clears the current tag,<br />
and again shows all RSS feeds, regardless of their assigned tags.<br />
<br />
{{Note| If the tag name contains spaces, the tag must be bounded by {{ic|"}}}}<br />
<br />
==== Special tags ====<br />
<br />
===== Custom feed names =====<br />
<br />
The name of a feed can be defined with a special tag in your urls file. Simply '''prefix''' the tag name with the {{ic|~}} character and the tag name will become the feed name.<br />
<br />
For example:<br />
<br />
<nowiki>http://rss.cnn.com/rss/cnn_topstories.rss</nowiki> "~CNN Top stories"<br />
<br />
will define the feed with feed-name "CNN Top stories"<br />
<br />
===== Hidden feeds =====<br />
<br />
A feed can be '''hidden''' from the regular list of feeds by '''prefixing''' the tag name with an {{ic|!}}.<br />
<br />
For example:<br />
<br />
<nowiki>http://rss.orf.at/news.xml</nowiki> "!ORF News (hidden)"<br />
<br />
The content of a '''hidden''' feed can only be found through a query feed.<br />
<br />
=== Query feeds ===<br />
<br />
Custom feeds can be created from existing feeds by creating what's called a ''query feed'': A feed generated by matching articles against a query. Query feeds are defined in your {{ic|~/.config/newsboat/urls}} file like a normal feed.<br />
They have the following syntax:<br />
<br />
<nowiki>query:FEEDNAME:FILTER_EXPRESSION [TAG ...]</nowiki><br />
<br />
Like a normal feed, a query feed has a name, {{ic|FEEDNAME}}, which is displayed in the feedlist.<br />
The filter expression language for {{ic|FILTER_EXPRESSION}} is defined in the [https://newsboat.org/releases/2.13/docs/newsboat.html#_filter_language newsboat manual].<br />
Query feeds can be optionally tagged, just like a normal feed. See [[#Tagging feeds]].<br />
<br />
==== Basic examples ====<br />
<br />
{{hc|~/.config/newsboat/urls|2=<br />
"query:Example1:age > 1"<br />
"query:Example2:(tags # \"example2\") and (title =~ \"example2\")"<br />
"query:Example3:(rssurl =~ \"example3\") or (total_count > 3)"<br />
}}<br />
<br />
The first example defines a feed named {{ic|Example1}} that will contain all articles that are older than a day<br />
<br />
The second example defines a feed named {{ic|Example2}} that will contain all articles whose feed was tagged {{ic|example2}}<br />
'''and''' whose article title matches {{ic|example2}}. Here the {{ic|#}} is the "contains" operator.<br />
<br />
The third example defines a feed named {{ic|Example3}} that will contain all articles whose feed url matches the<br />
regular expression {{ic|example3}} '''or''' all articles that are apart of a feed that contain more than 3 articles.<br />
<br />
{{Note|The query feed definition must be encapsulated in double quotes. Therefore any other double quotes in its declaration must be escaped}}<br />
<br />
==== Unread articles ====<br />
<br />
To create a feed named {{ic|Unread Articles}} that contains all unread articles, define the following:<br />
<br />
{{hc|~/.config/newsboat/urls|<br />
"query:Unread Articles:unread {{=}} \"yes\""<br />
}}<br />
<br />
==== Amalgamating multiple feeds into one ====<br />
<br />
A good use of query feeds is when you're following a creator whose content is spread across multiple feeds. You can use a query feed to amalgamate all his content into one place.<br />
<br />
{{hc|~/.config/newsboat/urls|<br />
"query:Metafeed:tags # \"metafeed\""<nowiki><br />
https://feed.url/1 metafeed !<br />
https://feed.url/2 metafeed !<br />
https://feed.url/3 metafeed !<br />
</nowiki>}}<br />
<br />
The trick is to assign each individual feed a unique tag - here {{ic|metafeed}} - so that we can match against it in the filter expression. We also make use of [[#Hidden feeds]] - the {{ic|!}} at the end of each feed - so that the individual feeds do not show up in the feedlist.<br />
<br />
==== Filtering a specific feed ====<br />
<br />
If a feed contains content you do not want to see, you can filter it by using a query feed.<br />
For example, to monitor package updates you're interested in, you can use:<br />
<br />
{{hc|~/.config/newsboat/urls|<br />
"query:Package Updates:(tags # \"packageupdates\") and (title {{=}}~ \"linux [0-9]{{!}}newsboat\")"<br />
<nowiki>https://archlinux.org/feeds/packages/</nowiki> packageupdates !<br />
}}<br />
<br />
This feed will only display updates to {{Pkg|linux}} and {{Pkg|newsboat}}.<br />
<br />
=== Ignoring articles ===<br />
<br />
As with [[#Filtering a specific feed]], another way to filter feeds is by using the {{ic|ignore-article}} command in your {{ic|~/.config/newsboat/config}}. It has the following syntax<br />
<br />
ignore-article FEEDURL FILTER_EXPRESSION<br />
<br />
==== Examples ====<br />
{{hc|~/.config/newsboat/config|<nowiki><br />
ignore-article "https://feed/url1" "content =~ \"tele(phone|communications)\"" <br />
ignore-article "https://feed/url2" "title =~ \"text_1|text_2\""<br />
</nowiki>}}<br />
<br />
The first example will ignore all articles in {{ic|<nowiki>https://feed/url1</nowiki>}} whose content matches<br />
{{ic|tele(phone{{!}}communications)}}<br />
<br />
The second example will ignore all articles in {{ic|<nowiki>https://feed/url2</nowiki>}} whose title matches {{ic|text_1{{!}}text_2}}<br />
<br />
==== Ignore modes ====<br />
<br />
In contrast to filtering with query feeds, Newsboat allows you to decide what to do with articles that match an {{ic|ignore-article}} command: you can delete them or not show them.<br />
<br />
{{hc|~/.config/newsboat/config|<br />
# ignore-mode "download" # Default: Delete them.<br />
# ignore-mode "display" # Do not show them.<br />
}}<br />
<br />
==== Comparison with query feeds ====<br />
<br />
In terms of pure filtering, whatever you can do with {{ic|ignore-article}} you can also do with a [[#Filtering a specific feed|query feed]].<br />
<br />
Query feeds are defined in your {{ic|~/.config/newsboat/urls}} file while {{ic|ignore-article}} commands are placed in your {{ic|~/.config/newsboat/config}}. So if you prefer having all feed related things in one place, you might want to stick<br />
to using query feeds.<br />
<br />
However if you want to save space and prevent newsboat from downloading certain articles, then<br />
using {{ic|ignore-article}} is your only choice.<br />
<br />
== Configuration ==<br />
<br />
Several aspects of Newsboat’s behaviour can be configured via a configuration file which is located, by default, in {{ic|~/.newsboat/config}} or {{ic|~/.config/newsboat/config}}. This configuration file contains lines of the form:<br />
<br />
<config-command> <arg1> ...<br />
<br />
=== Color schemes ===<br />
<br />
The package ships with a number of schemes in {{ic|/usr/share/doc/newsboat/contrib/colorschemes/}} which can be loaded with the include command like so:<br />
<br />
include /usr/share/doc/newsboat/contrib/colorschemes/inkpot<br />
<br />
=== Additional options ===<br />
<br />
The configuration file can also contain comments, which start with the {{ic|#}} character and go as far as the end of line. To enter a configuration argument that contains spaces, use quotes {{ic|"}} around the whole argument. It’s even possible to integrate the output of external commands into the configuration. The text between two backticks {{ic|`}} is evaluated as shell command, and its output is put on its place instead. This works like backtick evaluation in Bourne-compatible shells and allows users to use external information from the system within the configuration.<br />
<br />
See [https://gist.github.com/anonymous/42d2f5956e7bc8ee1ebc] and [http://moparx.com/configs/newsbeuter/] for example configurations.<br />
<br />
{{Note|To see a complete list of configuration command, consult {{man|1|newsboat|CONFIGURATION COMMANDS}}.}}<br />
<br />
== Tips and tricks ==<br />
<br />
=== Automatic feed reloads ===<br />
<br />
Newsboat can automatically reload all feeds on startup with the following configuration:<br />
<br />
auto-reload yes<br />
<br />
With this setting, Newsboat also runs periodic auto-reloads – by default, every 60 minutes. The number of minutes between automatic reloads can be configured like so:<br />
<br />
reload-time <desired number of minutes><br />
<br />
Alternatively, use [[cron]] or [[systemd]] to automatically reload feeds. Just add a line in your crontab, or create a systemd service/timer unit combo that issues the following command:<br />
<br />
/usr/bin/newsboat -x reload<br />
<br />
=== Loading of feeds in parallel for faster updates ===<br />
<br />
By default, Newsboat will attempt to update entries in {{ic|~/.newsboat/urls}} in sequence; however, the following setting will update them n at a time, in parallel. Adjust n to your liking.<br />
<br />
reload-threads 100<br />
<br />
=== Pass article URL to external command ===<br />
<br />
A clever little hack allows one to pass the URL of an article to an external command. The idea is to use a macro to set the browser that Newsboat opens the article with to the path of some other command and then change it back afterwards.<br />
<br />
For example, subscribers of a particular youtube channel can open the video with [[mpv]], by doing the following:<br />
<br />
macro y set browser "mpv %u" ; open-in-browser ; set browser "elinks %u"<br />
<br />
{{Note| First press the {{ic|,}} key, followed by the keybind to use the macro. In the example above, type {{ic|,}} + {{ic|y}} }}<br />
<br />
=== Subheadings ===<br />
<br />
There is another little hack that allows the user to add subheadings to sort feeds more effectively. This hack involves adding fake feeds to the {{ic|urls}} file like so:<br />
<br />
---Heading---<br />
<br />
{{Note|the {{ic|---}} characters are optional but having some sort of character identifying the headings is useful for styling.}}<br />
<br />
Then in {{ic|~/.config/newsboat/config}}, add the following two lines:<br />
<br />
highlight feedlist "---.*---" ''COLOR_OF_YOUR_CHOOSING'' default bold<br />
highlight feedlist ".*0/0.." default default invis<br />
<br />
Of course, replace {{ic|''COLOR_OF_YOUR_CHOOSING''}} with a [https://newsboat.org/releases/2.24/docs/newsboat.html#_configuring_colors newsboat supported color].<br />
<br />
This trick can also interact with Tags by replacing {{ic|---Heading---}} with:<br />
<br />
"query:---Heading---:tags # \"Tag\""<br />
<br />
Then tagging all the feeds below the heading with {{ic|Tag}}.<br />
<br />
== Troubleshooting ==<br />
<br />
=== Newsboat will not start ===<br />
<br />
Newsboat cannot start without any configured feeds! To add URLs, see [[#Managing feeds]]. If that is not the problem, check to see if another instance of Newsboat is running. Newsboat issues a lock on its database so that only one instance can access it at a time; thus, attempting to open a second instance will fail.<br />
<br />
== See also ==<br />
<br />
*[https://newsboat.org/ Official web site]<br />
*[https://newsboat.org/releases/2.24/docs/newsboat.html Full documentation]<br />
*[https://sanctum.geek.nz/arabesque/rss-with-newsboat/ Arabesque: RSS with Newsboat]</div>Captaincurriehttps://wiki.archlinux.org/index.php?title=Newsboat&diff=766156Newsboat2023-02-02T03:20:08Z<p>Captaincurrie: /* Ignoring articles */ fixed links</p>
<hr />
<div>[[Category:News aggregators]]<br />
[[Category:Console applications]]<br />
[[ja:Newsboat]]<br />
{{Related articles start}}<br />
{{Related|Web feed}}<br />
{{Related articles end}}<br />
<br />
[https://newsboat.org/ Newsboat] is an open source news aggregator licensed under the MIT License.<br />
<br />
From {{man|1|newsboat|DESCRIPTION}}:<br />
<br />
:Newsboat is an RSS/Atom feed reader for text terminals. RSS and Atom are a number of widely-used XML formats to transmit, publish and syndicate articles, for example news or blog articles. Newsboat is designed to be used on text terminals on Unix or Unix-like systems such as GNU/Linux, BSD or macOS. <br />
<br />
Newsboat is a [https://groups.google.com/forum/#!topic/newsbeuter/RPtlWX8CPGU fork] of abandoned Newsbeuter.<br />
<br />
== Installation ==<br />
<br />
[[Install]] the {{Pkg|newsboat}} package. For the development version, install the {{AUR|newsboat-git}} package.<br />
<br />
== Usage ==<br />
<br />
Newsboat cannot start without any configured feeds. Feeds can be configured in {{ic|~/.newsboat/urls}}. Newsboat can be started from the command line with<br />
<br />
$ newsboat<br />
<br />
Press the {{ic|?}} key to see a list of all keybindings. Keybindings can be rebound, see [[#Configuration]].<br />
<br />
== Managing feeds ==<br />
<br />
Adding, removing, and tagging feeds is done by editing the urls file. By default that is {{ic|~/.newsboat/urls}}.<br />
<br />
{{Tip|In addition to newsboat specific feeds in this section, be sure to see the [[Web feed]] article for additional options.}}<br />
<br />
=== RSS or ATOM sources ===<br />
<br />
To add URLs, open {{ic|~/.newsboat/urls}} with your favorite text editor and add the URLs, one per line:<br />
<br />
<nowiki>http://rss.cnn.com/rss/cnn_topstories.rss</nowiki><br />
<nowiki>http://newsrss.bbc.co.uk/rss/newsonline_world_edition/front_page/rss.xml</nowiki><br />
<br />
To add URLs that have restricted access via username/password, simply provide the username/password in the following way:<br />
<br />
<nowiki>http://username:password@hostname.domain.tld/feed.rss</nowiki><br />
<br />
In order to protect username and password, make sure that {{ic|~/.newsboat/urls}} has the appropriate permissions. Newsboat also makes sure that usernames and passwords within URLs aren’t displayed in its user interface. In case there is a @ in the username, type it as %40 instead so that it can be distinguished from the @ that separates the username/password part from the hostname part.<br />
<br />
To configure local files as feeds, simply prefix the local path with {{ic|file://}} and add it to the {{ic|~/.newsboat/urls}} file:<br />
<br />
file:///var/log/rss_eventlog.xml<br />
<br />
=== HTML as a source ===<br />
<br />
If HTML sources can be converted to RSS via a user supplied script, newboat can both execute this script and consume the output.<br />
<br />
This is accomplished by using the {{ic|filter:}} prefix in the configuration file. For example, write a script that can read HTML from stdin and print out an RSS or Atom feed to stdout. Save that script to {{ic|~/.newsboat/html2rss.sh}} and add the following line to the {{ic|urls}}:<br />
<br />
<nowiki>filter:~/.newsboat/html2rss.sh:https://myurl.com</nowiki><br />
<br />
* For several examples using this strategy, see [https://github.com/graysky2/newsboat_custom_stuff graysky's newsboat repo].<br />
* For more discussion, see [https://github.com/newsboat/newsboat/issues/1157 Possible to config newsboat to look at a web exposed directory and report changes #1157].<br />
<br />
=== Tagging feeds ===<br />
<br />
Every feed can be assigned 0 or more tags. This makes it easy to categorize your feeds as well as the ability to easily apply commands to multiple feeds at once.<br />
<br />
Usually, the {{ic|~/.newsboat/urls}} file contains one RSS feed URL per line. To assign a tag to an RSS feed, simply attach it as a single word, separated by blanks such as space or tab. If the tag needs to contain spaces, use quotes (") around the tag (see example below). An example may look like this:<br />
<br />
<nowiki>http://blog.fefe.de/rss.xml?html interesting conspiracy news "cool stuff"</nowiki><br />
<nowiki>http://rss.orf.at/news.xml news orf</nowiki><br />
<nowiki>http://www.heise.de/newsticker/heise.rdf news interesting</nowiki><br />
<br />
Starting Newsboat with this configuration, one can press {{ic|t}} to select a tag. Upon selecting the tag "news", one will see all three RSS feeds. Pressing {{ic|t}} again and e.g. selecting the "conspiracy" tag, will only show the {{ic|<nowiki>http://blog.fefe.de/rss.xml?html</nowiki>}} RSS feed. Pressing {{ic|Ctrl-T}} clears the current tag,<br />
and again shows all RSS feeds, regardless of their assigned tags.<br />
<br />
{{Note| If the tag name contains spaces, the tag must be bounded by {{ic|"}}}}<br />
<br />
==== Special tags ====<br />
<br />
===== Custom feed names =====<br />
<br />
The name of a feed can be defined with a special tag in your urls file. Simply '''prefix''' the tag name with the {{ic|~}} character and the tag name will become the feed name.<br />
<br />
For example:<br />
<br />
<nowiki>http://rss.cnn.com/rss/cnn_topstories.rss</nowiki> "~CNN Top stories"<br />
<br />
will define the feed with feed-name "CNN Top stories"<br />
<br />
===== Hidden feeds =====<br />
<br />
A feed can be '''hidden''' from the regular list of feeds by '''prefixing''' the tag name with an {{ic|!}}.<br />
<br />
For example:<br />
<br />
<nowiki>http://rss.orf.at/news.xml</nowiki> "!ORF News (hidden)"<br />
<br />
The content of a '''hidden''' feed can only be found through a query feed.<br />
<br />
=== Query feeds ===<br />
<br />
Custom feeds can be created from existing feeds by creating what's called a ''query feed'': A feed generated by matching articles against a query. Query feeds are defined in your {{ic|~/.config/newsboat/urls}} file like a normal feed.<br />
They have the following syntax:<br />
<br />
<nowiki>query:FEEDNAME:FILTER_EXPRESSION [TAG ...]</nowiki><br />
<br />
Like a normal feed, a query feed has a name, {{ic|FEEDNAME}}, which is displayed in the feedlist.<br />
The filter expression language for {{ic|FILTER_EXPRESSION}} is defined in the [https://newsboat.org/releases/2.13/docs/newsboat.html#_filter_language newsboat manual].<br />
Query feeds can be optionally tagged, just like a normal feed. See [[#Tagging feeds]].<br />
<br />
==== Basic examples ====<br />
<br />
{{hc|~/.config/newsboat/urls|2=<br />
"query:Example1:age > 1"<br />
"query:Example2:(tags # \"example2\") and (title =~ \"example2\")"<br />
"query:Example3:(rssurl =~ \"example3\") or (total_count > 3)"<br />
}}<br />
<br />
The first example defines a feed named {{ic|Example1}} that will contain all articles that are older than a day<br />
<br />
The second example defines a feed named {{ic|Example2}} that will contain all articles whose feed was tagged {{ic|example2}}<br />
'''and''' whose article title matches {{ic|example2}}. Here the {{ic|#}} is the "contains" operator.<br />
<br />
The third example defines a feed named {{ic|Example3}} that will contain all articles whose feed url matches the<br />
regular expression {{ic|example3}} '''or''' all articles that are apart of a feed that contain more than 3 articles.<br />
<br />
{{Note|The query feed definition must be encapsulated in double quotes. Therefore any other double quotes in its declaration must be escaped}}<br />
<br />
==== Unread articles ====<br />
<br />
To create a feed named {{ic|Unread Articles}} that contains all unread articles, define the following:<br />
<br />
{{hc|~/.config/newsboat/urls|<br />
"query:Unread Articles:unread {{=}} \"yes\""<br />
}}<br />
<br />
==== Amalgamating multiple feeds into one ====<br />
<br />
A good use of query feeds is when you're following a creator whose content is spread across multiple feeds. You can use a query feed to amalgamate all his content into one place.<br />
<br />
{{hc|~/.config/newsboat/urls|<br />
"query:Metafeed:tags # \"metafeed\""<nowiki><br />
https://feed.url/1 metafeed !<br />
https://feed.url/2 metafeed !<br />
https://feed.url/3 metafeed !<br />
</nowiki>}}<br />
<br />
The trick is to assign each individual feed a unique tag - here {{ic|metafeed}} - so that we can match against it in the filter expression. We also make use of [[#Hidden feeds]] - the {{ic|!}} at the end of each feed - so that the individual feeds do not show up in the feedlist.<br />
<br />
==== Filtering a specific feed ====<br />
<br />
If a feed contains content you do not want to see, you can filter it by using a query feed.<br />
For example, to monitor package updates you're interested in, you can use:<br />
<br />
{{hc|~/.config/newsboat/urls|<br />
"query:Package Updates:(tags # \"packageupdates\") and (title {{=}}~ \"linux [0-9]{{!}}newsboat\")"<br />
<nowiki>https://archlinux.org/feeds/packages/</nowiki> packageupdates !<br />
}}<br />
<br />
This feed will only display updates to {{Pkg|linux}} and {{Pkg|newsboat}}.<br />
<br />
=== Ignoring articles ===<br />
<br />
As with [[#Filtering a specific feeds]], another way to filter feeds is by using the {{ic|ignore-article}} command in your {{ic|~/.config/newsboat/config}}. It has the following syntax<br />
<br />
ignore-article FEEDURL FILTER_EXPRESSION<br />
<br />
==== Examples ====<br />
{{hc|~/.config/newsboat/config|<nowiki><br />
ignore-article "https://feed/url1" "content =~ \"tele(phone|communications)\"" <br />
ignore-article "https://feed/url2" "title =~ \"text_1|text_2\""<br />
</nowiki>}}<br />
<br />
The first example will ignore all articles in {{ic|<nowiki>https://feed/url1</nowiki>}} whose content matches<br />
{{ic|tele(phone{{!}}communications)}}<br />
<br />
The second example will ignore all articles in {{ic|<nowiki>https://feed/url2</nowiki>}} whose title matches {{ic|text_1{{!}}text_2}}<br />
<br />
==== Ignore modes ====<br />
<br />
In contrast to filtering with query feeds, Newsboat allows you to decide what to do with articles that match an {{ic|ignore-article}} command: you can delete them or not show them.<br />
<br />
{{hc|~/.config/newsboat/config|<br />
# ignore-mode "download" # Default: Delete them.<br />
# ignore-mode "display" # Do not show them.<br />
}}<br />
<br />
==== Comparison with query feeds ====<br />
<br />
In terms of pure filtering, whatever you can do with {{ic|ignore-article}} you can also do with a [[#Filtering a specific feeds|query feed]].<br />
<br />
Query feeds are defined in your {{ic|~/.config/newsboat/urls}} file while {{ic|ignore-article}} commands are placed in your {{ic|~/.config/newsboat/config}}. So if you prefer having all feed related things in one place, you might want to stick<br />
to using query feeds.<br />
<br />
However if you want to save space and prevent newsboat from downloading certain articles, then<br />
using {{ic|ignore-article}} is your only choice.<br />
<br />
== Configuration ==<br />
<br />
Several aspects of Newsboat’s behaviour can be configured via a configuration file which is located, by default, in {{ic|~/.newsboat/config}} or {{ic|~/.config/newsboat/config}}. This configuration file contains lines of the form:<br />
<br />
<config-command> <arg1> ...<br />
<br />
=== Color schemes ===<br />
<br />
The package ships with a number of schemes in {{ic|/usr/share/doc/newsboat/contrib/colorschemes/}} which can be loaded with the include command like so:<br />
<br />
include /usr/share/doc/newsboat/contrib/colorschemes/inkpot<br />
<br />
=== Additional options ===<br />
<br />
The configuration file can also contain comments, which start with the {{ic|#}} character and go as far as the end of line. To enter a configuration argument that contains spaces, use quotes {{ic|"}} around the whole argument. It’s even possible to integrate the output of external commands into the configuration. The text between two backticks {{ic|`}} is evaluated as shell command, and its output is put on its place instead. This works like backtick evaluation in Bourne-compatible shells and allows users to use external information from the system within the configuration.<br />
<br />
See [https://gist.github.com/anonymous/42d2f5956e7bc8ee1ebc] and [http://moparx.com/configs/newsbeuter/] for example configurations.<br />
<br />
{{Note|To see a complete list of configuration command, consult {{man|1|newsboat|CONFIGURATION COMMANDS}}.}}<br />
<br />
== Tips and tricks ==<br />
<br />
=== Automatic feed reloads ===<br />
<br />
Newsboat can automatically reload all feeds on startup with the following configuration:<br />
<br />
auto-reload yes<br />
<br />
With this setting, Newsboat also runs periodic auto-reloads – by default, every 60 minutes. The number of minutes between automatic reloads can be configured like so:<br />
<br />
reload-time <desired number of minutes><br />
<br />
Alternatively, use [[cron]] or [[systemd]] to automatically reload feeds. Just add a line in your crontab, or create a systemd service/timer unit combo that issues the following command:<br />
<br />
/usr/bin/newsboat -x reload<br />
<br />
=== Loading of feeds in parallel for faster updates ===<br />
<br />
By default, Newsboat will attempt to update entries in {{ic|~/.newsboat/urls}} in sequence; however, the following setting will update them n at a time, in parallel. Adjust n to your liking.<br />
<br />
reload-threads 100<br />
<br />
=== Pass article URL to external command ===<br />
<br />
A clever little hack allows one to pass the URL of an article to an external command. The idea is to use a macro to set the browser that Newsboat opens the article with to the path of some other command and then change it back afterwards.<br />
<br />
For example, subscribers of a particular youtube channel can open the video with [[mpv]], by doing the following:<br />
<br />
macro y set browser "mpv %u" ; open-in-browser ; set browser "elinks %u"<br />
<br />
{{Note| First press the {{ic|,}} key, followed by the keybind to use the macro. In the example above, type {{ic|,}} + {{ic|y}} }}<br />
<br />
=== Subheadings ===<br />
<br />
There is another little hack that allows the user to add subheadings to sort feeds more effectively. This hack involves adding fake feeds to the {{ic|urls}} file like so:<br />
<br />
---Heading---<br />
<br />
{{Note|the {{ic|---}} characters are optional but having some sort of character identifying the headings is useful for styling.}}<br />
<br />
Then in {{ic|~/.config/newsboat/config}}, add the following two lines:<br />
<br />
highlight feedlist "---.*---" ''COLOR_OF_YOUR_CHOOSING'' default bold<br />
highlight feedlist ".*0/0.." default default invis<br />
<br />
Of course, replace {{ic|''COLOR_OF_YOUR_CHOOSING''}} with a [https://newsboat.org/releases/2.24/docs/newsboat.html#_configuring_colors newsboat supported color].<br />
<br />
This trick can also interact with Tags by replacing {{ic|---Heading---}} with:<br />
<br />
"query:---Heading---:tags # \"Tag\""<br />
<br />
Then tagging all the feeds below the heading with {{ic|Tag}}.<br />
<br />
== Troubleshooting ==<br />
<br />
=== Newsboat will not start ===<br />
<br />
Newsboat cannot start without any configured feeds! To add URLs, see [[#Managing feeds]]. If that is not the problem, check to see if another instance of Newsboat is running. Newsboat issues a lock on its database so that only one instance can access it at a time; thus, attempting to open a second instance will fail.<br />
<br />
== See also ==<br />
<br />
*[https://newsboat.org/ Official web site]<br />
*[https://newsboat.org/releases/2.24/docs/newsboat.html Full documentation]<br />
*[https://sanctum.geek.nz/arabesque/rss-with-newsboat/ Arabesque: RSS with Newsboat]</div>Captaincurriehttps://wiki.archlinux.org/index.php?title=Newsboat&diff=766155Newsboat2023-02-02T03:17:30Z<p>Captaincurrie: /* Ignoring articles */ reworked section</p>
<hr />
<div>[[Category:News aggregators]]<br />
[[Category:Console applications]]<br />
[[ja:Newsboat]]<br />
{{Related articles start}}<br />
{{Related|Web feed}}<br />
{{Related articles end}}<br />
<br />
[https://newsboat.org/ Newsboat] is an open source news aggregator licensed under the MIT License.<br />
<br />
From {{man|1|newsboat|DESCRIPTION}}:<br />
<br />
:Newsboat is an RSS/Atom feed reader for text terminals. RSS and Atom are a number of widely-used XML formats to transmit, publish and syndicate articles, for example news or blog articles. Newsboat is designed to be used on text terminals on Unix or Unix-like systems such as GNU/Linux, BSD or macOS. <br />
<br />
Newsboat is a [https://groups.google.com/forum/#!topic/newsbeuter/RPtlWX8CPGU fork] of abandoned Newsbeuter.<br />
<br />
== Installation ==<br />
<br />
[[Install]] the {{Pkg|newsboat}} package. For the development version, install the {{AUR|newsboat-git}} package.<br />
<br />
== Usage ==<br />
<br />
Newsboat cannot start without any configured feeds. Feeds can be configured in {{ic|~/.newsboat/urls}}. Newsboat can be started from the command line with<br />
<br />
$ newsboat<br />
<br />
Press the {{ic|?}} key to see a list of all keybindings. Keybindings can be rebound, see [[#Configuration]].<br />
<br />
== Managing feeds ==<br />
<br />
Adding, removing, and tagging feeds is done by editing the urls file. By default that is {{ic|~/.newsboat/urls}}.<br />
<br />
{{Tip|In addition to newsboat specific feeds in this section, be sure to see the [[Web feed]] article for additional options.}}<br />
<br />
=== RSS or ATOM sources ===<br />
<br />
To add URLs, open {{ic|~/.newsboat/urls}} with your favorite text editor and add the URLs, one per line:<br />
<br />
<nowiki>http://rss.cnn.com/rss/cnn_topstories.rss</nowiki><br />
<nowiki>http://newsrss.bbc.co.uk/rss/newsonline_world_edition/front_page/rss.xml</nowiki><br />
<br />
To add URLs that have restricted access via username/password, simply provide the username/password in the following way:<br />
<br />
<nowiki>http://username:password@hostname.domain.tld/feed.rss</nowiki><br />
<br />
In order to protect username and password, make sure that {{ic|~/.newsboat/urls}} has the appropriate permissions. Newsboat also makes sure that usernames and passwords within URLs aren’t displayed in its user interface. In case there is a @ in the username, type it as %40 instead so that it can be distinguished from the @ that separates the username/password part from the hostname part.<br />
<br />
To configure local files as feeds, simply prefix the local path with {{ic|file://}} and add it to the {{ic|~/.newsboat/urls}} file:<br />
<br />
file:///var/log/rss_eventlog.xml<br />
<br />
=== HTML as a source ===<br />
<br />
If HTML sources can be converted to RSS via a user supplied script, newboat can both execute this script and consume the output.<br />
<br />
This is accomplished by using the {{ic|filter:}} prefix in the configuration file. For example, write a script that can read HTML from stdin and print out an RSS or Atom feed to stdout. Save that script to {{ic|~/.newsboat/html2rss.sh}} and add the following line to the {{ic|urls}}:<br />
<br />
<nowiki>filter:~/.newsboat/html2rss.sh:https://myurl.com</nowiki><br />
<br />
* For several examples using this strategy, see [https://github.com/graysky2/newsboat_custom_stuff graysky's newsboat repo].<br />
* For more discussion, see [https://github.com/newsboat/newsboat/issues/1157 Possible to config newsboat to look at a web exposed directory and report changes #1157].<br />
<br />
=== Tagging feeds ===<br />
<br />
Every feed can be assigned 0 or more tags. This makes it easy to categorize your feeds as well as the ability to easily apply commands to multiple feeds at once.<br />
<br />
Usually, the {{ic|~/.newsboat/urls}} file contains one RSS feed URL per line. To assign a tag to an RSS feed, simply attach it as a single word, separated by blanks such as space or tab. If the tag needs to contain spaces, use quotes (") around the tag (see example below). An example may look like this:<br />
<br />
<nowiki>http://blog.fefe.de/rss.xml?html interesting conspiracy news "cool stuff"</nowiki><br />
<nowiki>http://rss.orf.at/news.xml news orf</nowiki><br />
<nowiki>http://www.heise.de/newsticker/heise.rdf news interesting</nowiki><br />
<br />
Starting Newsboat with this configuration, one can press {{ic|t}} to select a tag. Upon selecting the tag "news", one will see all three RSS feeds. Pressing {{ic|t}} again and e.g. selecting the "conspiracy" tag, will only show the {{ic|<nowiki>http://blog.fefe.de/rss.xml?html</nowiki>}} RSS feed. Pressing {{ic|Ctrl-T}} clears the current tag,<br />
and again shows all RSS feeds, regardless of their assigned tags.<br />
<br />
{{Note| If the tag name contains spaces, the tag must be bounded by {{ic|"}}}}<br />
<br />
==== Special tags ====<br />
<br />
===== Custom feed names =====<br />
<br />
The name of a feed can be defined with a special tag in your urls file. Simply '''prefix''' the tag name with the {{ic|~}} character and the tag name will become the feed name.<br />
<br />
For example:<br />
<br />
<nowiki>http://rss.cnn.com/rss/cnn_topstories.rss</nowiki> "~CNN Top stories"<br />
<br />
will define the feed with feed-name "CNN Top stories"<br />
<br />
===== Hidden feeds =====<br />
<br />
A feed can be '''hidden''' from the regular list of feeds by '''prefixing''' the tag name with an {{ic|!}}.<br />
<br />
For example:<br />
<br />
<nowiki>http://rss.orf.at/news.xml</nowiki> "!ORF News (hidden)"<br />
<br />
The content of a '''hidden''' feed can only be found through a query feed.<br />
<br />
=== Query feeds ===<br />
<br />
Custom feeds can be created from existing feeds by creating what's called a ''query feed'': A feed generated by matching articles against a query. Query feeds are defined in your {{ic|~/.config/newsboat/urls}} file like a normal feed.<br />
They have the following syntax:<br />
<br />
<nowiki>query:FEEDNAME:FILTER_EXPRESSION [TAG ...]</nowiki><br />
<br />
Like a normal feed, a query feed has a name, {{ic|FEEDNAME}}, which is displayed in the feedlist.<br />
The filter expression language for {{ic|FILTER_EXPRESSION}} is defined in the [https://newsboat.org/releases/2.13/docs/newsboat.html#_filter_language newsboat manual].<br />
Query feeds can be optionally tagged, just like a normal feed. See [[#Tagging feeds]].<br />
<br />
==== Basic examples ====<br />
<br />
{{hc|~/.config/newsboat/urls|2=<br />
"query:Example1:age > 1"<br />
"query:Example2:(tags # \"example2\") and (title =~ \"example2\")"<br />
"query:Example3:(rssurl =~ \"example3\") or (total_count > 3)"<br />
}}<br />
<br />
The first example defines a feed named {{ic|Example1}} that will contain all articles that are older than a day<br />
<br />
The second example defines a feed named {{ic|Example2}} that will contain all articles whose feed was tagged {{ic|example2}}<br />
'''and''' whose article title matches {{ic|example2}}. Here the {{ic|#}} is the "contains" operator.<br />
<br />
The third example defines a feed named {{ic|Example3}} that will contain all articles whose feed url matches the<br />
regular expression {{ic|example3}} '''or''' all articles that are apart of a feed that contain more than 3 articles.<br />
<br />
{{Note|The query feed definition must be encapsulated in double quotes. Therefore any other double quotes in its declaration must be escaped}}<br />
<br />
==== Unread articles ====<br />
<br />
To create a feed named {{ic|Unread Articles}} that contains all unread articles, define the following:<br />
<br />
{{hc|~/.config/newsboat/urls|<br />
"query:Unread Articles:unread {{=}} \"yes\""<br />
}}<br />
<br />
==== Amalgamating multiple feeds into one ====<br />
<br />
A good use of query feeds is when you're following a creator whose content is spread across multiple feeds. You can use a query feed to amalgamate all his content into one place.<br />
<br />
{{hc|~/.config/newsboat/urls|<br />
"query:Metafeed:tags # \"metafeed\""<nowiki><br />
https://feed.url/1 metafeed !<br />
https://feed.url/2 metafeed !<br />
https://feed.url/3 metafeed !<br />
</nowiki>}}<br />
<br />
The trick is to assign each individual feed a unique tag - here {{ic|metafeed}} - so that we can match against it in the filter expression. We also make use of [[#Hidden feeds]] - the {{ic|!}} at the end of each feed - so that the individual feeds do not show up in the feedlist.<br />
<br />
==== Filtering a specific feed ====<br />
<br />
If a feed contains content you do not want to see, you can filter it by using a query feed.<br />
For example, to monitor package updates you're interested in, you can use:<br />
<br />
{{hc|~/.config/newsboat/urls|<br />
"query:Package Updates:(tags # \"packageupdates\") and (title {{=}}~ \"linux [0-9]{{!}}newsboat\")"<br />
<nowiki>https://archlinux.org/feeds/packages/</nowiki> packageupdates !<br />
}}<br />
<br />
This feed will only display updates to {{Pkg|linux}} and {{Pkg|newsboat}}.<br />
<br />
=== Ignoring articles ===<br />
<br />
As with [[#Filtering specific feeds]], another way to filter feeds is by using the {{ic|ignore-article}} command in your {{ic|~/.config/newsboat/config}}. It has the following syntax<br />
<br />
ignore-article FEEDURL FILTER_EXPRESSION<br />
<br />
==== Examples ====<br />
{{hc|~/.config/newsboat/config|<nowiki><br />
ignore-article "https://feed/url1" "content =~ \"tele(phone|communications)\"" <br />
ignore-article "https://feed/url2" "title =~ \"text_1|text_2\""<br />
</nowiki>}}<br />
<br />
The first example will ignore all articles in {{ic|<nowiki>https://feed/url1</nowiki>}} whose content matches<br />
{{ic|tele(phone{{!}}communications)}}<br />
<br />
The second example will ignore all articles in {{ic|<nowiki>https://feed/url2</nowiki>}} whose title matches {{ic|text_1{{!}}text_2}}<br />
<br />
==== Ignore modes ====<br />
<br />
In contrast to filtering with query feeds, Newsboat allows you to decide what to do with articles that match an {{ic|ignore-article}} command: you can delete them or not show them.<br />
<br />
{{hc|~/.config/newsboat/config|<br />
# ignore-mode "download" # Default: Delete them.<br />
# ignore-mode "display" # Do not show them.<br />
}}<br />
<br />
==== Comparison with query feeds ====<br />
<br />
In terms of pure filtering, whatever you can do with {{ic|ignore-article}} you can also do with a [[#Filtering specific feeds|query feed]].<br />
<br />
Query feeds are defined in your {{ic|~/.config/newsboat/urls}} file while {{ic|ignore-article}} commands are placed in your {{ic|~/.config/newsboat/config}}. So if you prefer having all feed related things in one place, you might want to stick<br />
to using query feeds.<br />
<br />
However if you want to save space and prevent newsboat from downloading certain articles, then<br />
using {{ic|ignore-article}} is your only choice.<br />
<br />
== Configuration ==<br />
<br />
Several aspects of Newsboat’s behaviour can be configured via a configuration file which is located, by default, in {{ic|~/.newsboat/config}} or {{ic|~/.config/newsboat/config}}. This configuration file contains lines of the form:<br />
<br />
<config-command> <arg1> ...<br />
<br />
=== Color schemes ===<br />
<br />
The package ships with a number of schemes in {{ic|/usr/share/doc/newsboat/contrib/colorschemes/}} which can be loaded with the include command like so:<br />
<br />
include /usr/share/doc/newsboat/contrib/colorschemes/inkpot<br />
<br />
=== Additional options ===<br />
<br />
The configuration file can also contain comments, which start with the {{ic|#}} character and go as far as the end of line. To enter a configuration argument that contains spaces, use quotes {{ic|"}} around the whole argument. It’s even possible to integrate the output of external commands into the configuration. The text between two backticks {{ic|`}} is evaluated as shell command, and its output is put on its place instead. This works like backtick evaluation in Bourne-compatible shells and allows users to use external information from the system within the configuration.<br />
<br />
See [https://gist.github.com/anonymous/42d2f5956e7bc8ee1ebc] and [http://moparx.com/configs/newsbeuter/] for example configurations.<br />
<br />
{{Note|To see a complete list of configuration command, consult {{man|1|newsboat|CONFIGURATION COMMANDS}}.}}<br />
<br />
== Tips and tricks ==<br />
<br />
=== Automatic feed reloads ===<br />
<br />
Newsboat can automatically reload all feeds on startup with the following configuration:<br />
<br />
auto-reload yes<br />
<br />
With this setting, Newsboat also runs periodic auto-reloads – by default, every 60 minutes. The number of minutes between automatic reloads can be configured like so:<br />
<br />
reload-time <desired number of minutes><br />
<br />
Alternatively, use [[cron]] or [[systemd]] to automatically reload feeds. Just add a line in your crontab, or create a systemd service/timer unit combo that issues the following command:<br />
<br />
/usr/bin/newsboat -x reload<br />
<br />
=== Loading of feeds in parallel for faster updates ===<br />
<br />
By default, Newsboat will attempt to update entries in {{ic|~/.newsboat/urls}} in sequence; however, the following setting will update them n at a time, in parallel. Adjust n to your liking.<br />
<br />
reload-threads 100<br />
<br />
=== Pass article URL to external command ===<br />
<br />
A clever little hack allows one to pass the URL of an article to an external command. The idea is to use a macro to set the browser that Newsboat opens the article with to the path of some other command and then change it back afterwards.<br />
<br />
For example, subscribers of a particular youtube channel can open the video with [[mpv]], by doing the following:<br />
<br />
macro y set browser "mpv %u" ; open-in-browser ; set browser "elinks %u"<br />
<br />
{{Note| First press the {{ic|,}} key, followed by the keybind to use the macro. In the example above, type {{ic|,}} + {{ic|y}} }}<br />
<br />
=== Subheadings ===<br />
<br />
There is another little hack that allows the user to add subheadings to sort feeds more effectively. This hack involves adding fake feeds to the {{ic|urls}} file like so:<br />
<br />
---Heading---<br />
<br />
{{Note|the {{ic|---}} characters are optional but having some sort of character identifying the headings is useful for styling.}}<br />
<br />
Then in {{ic|~/.config/newsboat/config}}, add the following two lines:<br />
<br />
highlight feedlist "---.*---" ''COLOR_OF_YOUR_CHOOSING'' default bold<br />
highlight feedlist ".*0/0.." default default invis<br />
<br />
Of course, replace {{ic|''COLOR_OF_YOUR_CHOOSING''}} with a [https://newsboat.org/releases/2.24/docs/newsboat.html#_configuring_colors newsboat supported color].<br />
<br />
This trick can also interact with Tags by replacing {{ic|---Heading---}} with:<br />
<br />
"query:---Heading---:tags # \"Tag\""<br />
<br />
Then tagging all the feeds below the heading with {{ic|Tag}}.<br />
<br />
== Troubleshooting ==<br />
<br />
=== Newsboat will not start ===<br />
<br />
Newsboat cannot start without any configured feeds! To add URLs, see [[#Managing feeds]]. If that is not the problem, check to see if another instance of Newsboat is running. Newsboat issues a lock on its database so that only one instance can access it at a time; thus, attempting to open a second instance will fail.<br />
<br />
== See also ==<br />
<br />
*[https://newsboat.org/ Official web site]<br />
*[https://newsboat.org/releases/2.24/docs/newsboat.html Full documentation]<br />
*[https://sanctum.geek.nz/arabesque/rss-with-newsboat/ Arabesque: RSS with Newsboat]</div>Captaincurriehttps://wiki.archlinux.org/index.php?title=Newsboat&diff=766154Newsboat2023-02-02T02:31:44Z<p>Captaincurrie: /* Amalgamating multiple feeds into one */ grammer</p>
<hr />
<div>[[Category:News aggregators]]<br />
[[Category:Console applications]]<br />
[[ja:Newsboat]]<br />
{{Related articles start}}<br />
{{Related|Web feed}}<br />
{{Related articles end}}<br />
<br />
[https://newsboat.org/ Newsboat] is an open source news aggregator licensed under the MIT License.<br />
<br />
From {{man|1|newsboat|DESCRIPTION}}:<br />
<br />
:Newsboat is an RSS/Atom feed reader for text terminals. RSS and Atom are a number of widely-used XML formats to transmit, publish and syndicate articles, for example news or blog articles. Newsboat is designed to be used on text terminals on Unix or Unix-like systems such as GNU/Linux, BSD or macOS. <br />
<br />
Newsboat is a [https://groups.google.com/forum/#!topic/newsbeuter/RPtlWX8CPGU fork] of abandoned Newsbeuter.<br />
<br />
== Installation ==<br />
<br />
[[Install]] the {{Pkg|newsboat}} package. For the development version, install the {{AUR|newsboat-git}} package.<br />
<br />
== Usage ==<br />
<br />
Newsboat cannot start without any configured feeds. Feeds can be configured in {{ic|~/.newsboat/urls}}. Newsboat can be started from the command line with<br />
<br />
$ newsboat<br />
<br />
Press the {{ic|?}} key to see a list of all keybindings. Keybindings can be rebound, see [[#Configuration]].<br />
<br />
== Managing feeds ==<br />
<br />
Adding, removing, and tagging feeds is done by editing the urls file. By default that is {{ic|~/.newsboat/urls}}.<br />
<br />
{{Tip|In addition to newsboat specific feeds in this section, be sure to see the [[Web feed]] article for additional options.}}<br />
<br />
=== RSS or ATOM sources ===<br />
<br />
To add URLs, open {{ic|~/.newsboat/urls}} with your favorite text editor and add the URLs, one per line:<br />
<br />
<nowiki>http://rss.cnn.com/rss/cnn_topstories.rss</nowiki><br />
<nowiki>http://newsrss.bbc.co.uk/rss/newsonline_world_edition/front_page/rss.xml</nowiki><br />
<br />
To add URLs that have restricted access via username/password, simply provide the username/password in the following way:<br />
<br />
<nowiki>http://username:password@hostname.domain.tld/feed.rss</nowiki><br />
<br />
In order to protect username and password, make sure that {{ic|~/.newsboat/urls}} has the appropriate permissions. Newsboat also makes sure that usernames and passwords within URLs aren’t displayed in its user interface. In case there is a @ in the username, type it as %40 instead so that it can be distinguished from the @ that separates the username/password part from the hostname part.<br />
<br />
To configure local files as feeds, simply prefix the local path with {{ic|file://}} and add it to the {{ic|~/.newsboat/urls}} file:<br />
<br />
file:///var/log/rss_eventlog.xml<br />
<br />
=== HTML as a source ===<br />
<br />
If HTML sources can be converted to RSS via a user supplied script, newboat can both execute this script and consume the output.<br />
<br />
This is accomplished by using the {{ic|filter:}} prefix in the configuration file. For example, write a script that can read HTML from stdin and print out an RSS or Atom feed to stdout. Save that script to {{ic|~/.newsboat/html2rss.sh}} and add the following line to the {{ic|urls}}:<br />
<br />
<nowiki>filter:~/.newsboat/html2rss.sh:https://myurl.com</nowiki><br />
<br />
* For several examples using this strategy, see [https://github.com/graysky2/newsboat_custom_stuff graysky's newsboat repo].<br />
* For more discussion, see [https://github.com/newsboat/newsboat/issues/1157 Possible to config newsboat to look at a web exposed directory and report changes #1157].<br />
<br />
=== Tagging feeds ===<br />
<br />
Every feed can be assigned 0 or more tags. This makes it easy to categorize your feeds as well as the ability to easily apply commands to multiple feeds at once.<br />
<br />
Usually, the {{ic|~/.newsboat/urls}} file contains one RSS feed URL per line. To assign a tag to an RSS feed, simply attach it as a single word, separated by blanks such as space or tab. If the tag needs to contain spaces, use quotes (") around the tag (see example below). An example may look like this:<br />
<br />
<nowiki>http://blog.fefe.de/rss.xml?html interesting conspiracy news "cool stuff"</nowiki><br />
<nowiki>http://rss.orf.at/news.xml news orf</nowiki><br />
<nowiki>http://www.heise.de/newsticker/heise.rdf news interesting</nowiki><br />
<br />
Starting Newsboat with this configuration, one can press {{ic|t}} to select a tag. Upon selecting the tag "news", one will see all three RSS feeds. Pressing {{ic|t}} again and e.g. selecting the "conspiracy" tag, will only show the {{ic|<nowiki>http://blog.fefe.de/rss.xml?html</nowiki>}} RSS feed. Pressing {{ic|Ctrl-T}} clears the current tag,<br />
and again shows all RSS feeds, regardless of their assigned tags.<br />
<br />
{{Note| If the tag name contains spaces, the tag must be bounded by {{ic|"}}}}<br />
<br />
==== Special tags ====<br />
<br />
===== Custom feed names =====<br />
<br />
The name of a feed can be defined with a special tag in your urls file. Simply '''prefix''' the tag name with the {{ic|~}} character and the tag name will become the feed name.<br />
<br />
For example:<br />
<br />
<nowiki>http://rss.cnn.com/rss/cnn_topstories.rss</nowiki> "~CNN Top stories"<br />
<br />
will define the feed with feed-name "CNN Top stories"<br />
<br />
===== Hidden feeds =====<br />
<br />
A feed can be '''hidden''' from the regular list of feeds by '''prefixing''' the tag name with an {{ic|!}}.<br />
<br />
For example:<br />
<br />
<nowiki>http://rss.orf.at/news.xml</nowiki> "!ORF News (hidden)"<br />
<br />
The content of a '''hidden''' feed can only be found through a query feed.<br />
<br />
=== Query feeds ===<br />
<br />
Custom feeds can be created from existing feeds by creating what's called a ''query feed'': A feed generated by matching articles against a query. Query feeds are defined in your {{ic|~/.config/newsboat/urls}} file like a normal feed.<br />
They have the following syntax:<br />
<br />
<nowiki>query:FEEDNAME:FILTER_EXPRESSION [TAG ...]</nowiki><br />
<br />
Like a normal feed, a query feed has a name, {{ic|FEEDNAME}}, which is displayed in the feedlist.<br />
The filter expression language for {{ic|FILTER_EXPRESSION}} is defined in the [https://newsboat.org/releases/2.13/docs/newsboat.html#_filter_language newsboat manual].<br />
Query feeds can be optionally tagged, just like a normal feed. See [[#Tagging feeds]].<br />
<br />
==== Basic examples ====<br />
<br />
{{hc|~/.config/newsboat/urls|2=<br />
"query:Example1:age > 1"<br />
"query:Example2:(tags # \"example2\") and (title =~ \"example2\")"<br />
"query:Example3:(rssurl =~ \"example3\") or (total_count > 3)"<br />
}}<br />
<br />
The first example defines a feed named {{ic|Example1}} that will contain all articles that are older than a day<br />
<br />
The second example defines a feed named {{ic|Example2}} that will contain all articles whose feed was tagged {{ic|example2}}<br />
'''and''' whose article title matches {{ic|example2}}. Here the {{ic|#}} is the "contains" operator.<br />
<br />
The third example defines a feed named {{ic|Example3}} that will contain all articles whose feed url matches the<br />
regular expression {{ic|example3}} '''or''' all articles that are apart of a feed that contain more than 3 articles.<br />
<br />
{{Note|The query feed definition must be encapsulated in double quotes. Therefore any other double quotes in its declaration must be escaped}}<br />
<br />
==== Unread articles ====<br />
<br />
To create a feed named {{ic|Unread Articles}} that contains all unread articles, define the following:<br />
<br />
{{hc|~/.config/newsboat/urls|<br />
"query:Unread Articles:unread {{=}} \"yes\""<br />
}}<br />
<br />
==== Amalgamating multiple feeds into one ====<br />
<br />
A good use of query feeds is when you're following a creator whose content is spread across multiple feeds. You can use a query feed to amalgamate all his content into one place.<br />
<br />
{{hc|~/.config/newsboat/urls|<br />
"query:Metafeed:tags # \"metafeed\""<nowiki><br />
https://feed.url/1 metafeed !<br />
https://feed.url/2 metafeed !<br />
https://feed.url/3 metafeed !<br />
</nowiki>}}<br />
<br />
The trick is to assign each individual feed a unique tag - here {{ic|metafeed}} - so that we can match against it in the filter expression. We also make use of [[#Hidden feeds]] - the {{ic|!}} at the end of each feed - so that the individual feeds do not show up in the feedlist.<br />
<br />
==== Filtering a specific feed ====<br />
<br />
If a feed contains content you do not want to see, you can filter it by using a query feed.<br />
For example, to monitor package updates you're interested in, you can use:<br />
<br />
{{hc|~/.config/newsboat/urls|<br />
"query:Package Updates:(tags # \"packageupdates\") and (title {{=}}~ \"linux [0-9]{{!}}newsboat\")"<br />
<nowiki>https://archlinux.org/feeds/packages/</nowiki> packageupdates !<br />
}}<br />
<br />
This feed will only display updates to {{Pkg|linux}} and {{Pkg|newsboat}}.<br />
<br />
=== Ignoring articles ===<br />
<br />
There are two ways to ignore articles, delete them or not show them.<br />
<br />
{{hc|~/.newsboat/config|<br />
# ignore-mode "download" # Default: Delete them.<br />
ignore-mode "display" # Do not show them.<br />
}}<br />
<br />
The filter can be configured like so (here in POSIX extended regular expressions):<br />
<br />
{{hc|~/.newsboat/config|<nowiki><br />
ignore-article "https://feed/url" "content =~ \"tele(phone|communications)\"" <br />
ignore-article "https://feed/url" "title =~ \"text_1|text_2\""<br />
</nowiki>}}<br />
<br />
== Configuration ==<br />
<br />
Several aspects of Newsboat’s behaviour can be configured via a configuration file which is located, by default, in {{ic|~/.newsboat/config}} or {{ic|~/.config/newsboat/config}}. This configuration file contains lines of the form:<br />
<br />
<config-command> <arg1> ...<br />
<br />
=== Color schemes ===<br />
<br />
The package ships with a number of schemes in {{ic|/usr/share/doc/newsboat/contrib/colorschemes/}} which can be loaded with the include command like so:<br />
<br />
include /usr/share/doc/newsboat/contrib/colorschemes/inkpot<br />
<br />
=== Additional options ===<br />
<br />
The configuration file can also contain comments, which start with the {{ic|#}} character and go as far as the end of line. To enter a configuration argument that contains spaces, use quotes {{ic|"}} around the whole argument. It’s even possible to integrate the output of external commands into the configuration. The text between two backticks {{ic|`}} is evaluated as shell command, and its output is put on its place instead. This works like backtick evaluation in Bourne-compatible shells and allows users to use external information from the system within the configuration.<br />
<br />
See [https://gist.github.com/anonymous/42d2f5956e7bc8ee1ebc] and [http://moparx.com/configs/newsbeuter/] for example configurations.<br />
<br />
{{Note|To see a complete list of configuration command, consult {{man|1|newsboat|CONFIGURATION COMMANDS}}.}}<br />
<br />
== Tips and tricks ==<br />
<br />
=== Automatic feed reloads ===<br />
<br />
Newsboat can automatically reload all feeds on startup with the following configuration:<br />
<br />
auto-reload yes<br />
<br />
With this setting, Newsboat also runs periodic auto-reloads – by default, every 60 minutes. The number of minutes between automatic reloads can be configured like so:<br />
<br />
reload-time <desired number of minutes><br />
<br />
Alternatively, use [[cron]] or [[systemd]] to automatically reload feeds. Just add a line in your crontab, or create a systemd service/timer unit combo that issues the following command:<br />
<br />
/usr/bin/newsboat -x reload<br />
<br />
=== Loading of feeds in parallel for faster updates ===<br />
<br />
By default, Newsboat will attempt to update entries in {{ic|~/.newsboat/urls}} in sequence; however, the following setting will update them n at a time, in parallel. Adjust n to your liking.<br />
<br />
reload-threads 100<br />
<br />
=== Pass article URL to external command ===<br />
<br />
A clever little hack allows one to pass the URL of an article to an external command. The idea is to use a macro to set the browser that Newsboat opens the article with to the path of some other command and then change it back afterwards.<br />
<br />
For example, subscribers of a particular youtube channel can open the video with [[mpv]], by doing the following:<br />
<br />
macro y set browser "mpv %u" ; open-in-browser ; set browser "elinks %u"<br />
<br />
{{Note| First press the {{ic|,}} key, followed by the keybind to use the macro. In the example above, type {{ic|,}} + {{ic|y}} }}<br />
<br />
=== Subheadings ===<br />
<br />
There is another little hack that allows the user to add subheadings to sort feeds more effectively. This hack involves adding fake feeds to the {{ic|urls}} file like so:<br />
<br />
---Heading---<br />
<br />
{{Note|the {{ic|---}} characters are optional but having some sort of character identifying the headings is useful for styling.}}<br />
<br />
Then in {{ic|~/.config/newsboat/config}}, add the following two lines:<br />
<br />
highlight feedlist "---.*---" ''COLOR_OF_YOUR_CHOOSING'' default bold<br />
highlight feedlist ".*0/0.." default default invis<br />
<br />
Of course, replace {{ic|''COLOR_OF_YOUR_CHOOSING''}} with a [https://newsboat.org/releases/2.24/docs/newsboat.html#_configuring_colors newsboat supported color].<br />
<br />
This trick can also interact with Tags by replacing {{ic|---Heading---}} with:<br />
<br />
"query:---Heading---:tags # \"Tag\""<br />
<br />
Then tagging all the feeds below the heading with {{ic|Tag}}.<br />
<br />
== Troubleshooting ==<br />
<br />
=== Newsboat will not start ===<br />
<br />
Newsboat cannot start without any configured feeds! To add URLs, see [[#Managing feeds]]. If that is not the problem, check to see if another instance of Newsboat is running. Newsboat issues a lock on its database so that only one instance can access it at a time; thus, attempting to open a second instance will fail.<br />
<br />
== See also ==<br />
<br />
*[https://newsboat.org/ Official web site]<br />
*[https://newsboat.org/releases/2.24/docs/newsboat.html Full documentation]<br />
*[https://sanctum.geek.nz/arabesque/rss-with-newsboat/ Arabesque: RSS with Newsboat]</div>Captaincurriehttps://wiki.archlinux.org/index.php?title=Newsboat&diff=766153Newsboat2023-02-02T02:29:54Z<p>Captaincurrie: /* Filtering a specific feed */ added explanation of example feed</p>
<hr />
<div>[[Category:News aggregators]]<br />
[[Category:Console applications]]<br />
[[ja:Newsboat]]<br />
{{Related articles start}}<br />
{{Related|Web feed}}<br />
{{Related articles end}}<br />
<br />
[https://newsboat.org/ Newsboat] is an open source news aggregator licensed under the MIT License.<br />
<br />
From {{man|1|newsboat|DESCRIPTION}}:<br />
<br />
:Newsboat is an RSS/Atom feed reader for text terminals. RSS and Atom are a number of widely-used XML formats to transmit, publish and syndicate articles, for example news or blog articles. Newsboat is designed to be used on text terminals on Unix or Unix-like systems such as GNU/Linux, BSD or macOS. <br />
<br />
Newsboat is a [https://groups.google.com/forum/#!topic/newsbeuter/RPtlWX8CPGU fork] of abandoned Newsbeuter.<br />
<br />
== Installation ==<br />
<br />
[[Install]] the {{Pkg|newsboat}} package. For the development version, install the {{AUR|newsboat-git}} package.<br />
<br />
== Usage ==<br />
<br />
Newsboat cannot start without any configured feeds. Feeds can be configured in {{ic|~/.newsboat/urls}}. Newsboat can be started from the command line with<br />
<br />
$ newsboat<br />
<br />
Press the {{ic|?}} key to see a list of all keybindings. Keybindings can be rebound, see [[#Configuration]].<br />
<br />
== Managing feeds ==<br />
<br />
Adding, removing, and tagging feeds is done by editing the urls file. By default that is {{ic|~/.newsboat/urls}}.<br />
<br />
{{Tip|In addition to newsboat specific feeds in this section, be sure to see the [[Web feed]] article for additional options.}}<br />
<br />
=== RSS or ATOM sources ===<br />
<br />
To add URLs, open {{ic|~/.newsboat/urls}} with your favorite text editor and add the URLs, one per line:<br />
<br />
<nowiki>http://rss.cnn.com/rss/cnn_topstories.rss</nowiki><br />
<nowiki>http://newsrss.bbc.co.uk/rss/newsonline_world_edition/front_page/rss.xml</nowiki><br />
<br />
To add URLs that have restricted access via username/password, simply provide the username/password in the following way:<br />
<br />
<nowiki>http://username:password@hostname.domain.tld/feed.rss</nowiki><br />
<br />
In order to protect username and password, make sure that {{ic|~/.newsboat/urls}} has the appropriate permissions. Newsboat also makes sure that usernames and passwords within URLs aren’t displayed in its user interface. In case there is a @ in the username, type it as %40 instead so that it can be distinguished from the @ that separates the username/password part from the hostname part.<br />
<br />
To configure local files as feeds, simply prefix the local path with {{ic|file://}} and add it to the {{ic|~/.newsboat/urls}} file:<br />
<br />
file:///var/log/rss_eventlog.xml<br />
<br />
=== HTML as a source ===<br />
<br />
If HTML sources can be converted to RSS via a user supplied script, newboat can both execute this script and consume the output.<br />
<br />
This is accomplished by using the {{ic|filter:}} prefix in the configuration file. For example, write a script that can read HTML from stdin and print out an RSS or Atom feed to stdout. Save that script to {{ic|~/.newsboat/html2rss.sh}} and add the following line to the {{ic|urls}}:<br />
<br />
<nowiki>filter:~/.newsboat/html2rss.sh:https://myurl.com</nowiki><br />
<br />
* For several examples using this strategy, see [https://github.com/graysky2/newsboat_custom_stuff graysky's newsboat repo].<br />
* For more discussion, see [https://github.com/newsboat/newsboat/issues/1157 Possible to config newsboat to look at a web exposed directory and report changes #1157].<br />
<br />
=== Tagging feeds ===<br />
<br />
Every feed can be assigned 0 or more tags. This makes it easy to categorize your feeds as well as the ability to easily apply commands to multiple feeds at once.<br />
<br />
Usually, the {{ic|~/.newsboat/urls}} file contains one RSS feed URL per line. To assign a tag to an RSS feed, simply attach it as a single word, separated by blanks such as space or tab. If the tag needs to contain spaces, use quotes (") around the tag (see example below). An example may look like this:<br />
<br />
<nowiki>http://blog.fefe.de/rss.xml?html interesting conspiracy news "cool stuff"</nowiki><br />
<nowiki>http://rss.orf.at/news.xml news orf</nowiki><br />
<nowiki>http://www.heise.de/newsticker/heise.rdf news interesting</nowiki><br />
<br />
Starting Newsboat with this configuration, one can press {{ic|t}} to select a tag. Upon selecting the tag "news", one will see all three RSS feeds. Pressing {{ic|t}} again and e.g. selecting the "conspiracy" tag, will only show the {{ic|<nowiki>http://blog.fefe.de/rss.xml?html</nowiki>}} RSS feed. Pressing {{ic|Ctrl-T}} clears the current tag,<br />
and again shows all RSS feeds, regardless of their assigned tags.<br />
<br />
{{Note| If the tag name contains spaces, the tag must be bounded by {{ic|"}}}}<br />
<br />
==== Special tags ====<br />
<br />
===== Custom feed names =====<br />
<br />
The name of a feed can be defined with a special tag in your urls file. Simply '''prefix''' the tag name with the {{ic|~}} character and the tag name will become the feed name.<br />
<br />
For example:<br />
<br />
<nowiki>http://rss.cnn.com/rss/cnn_topstories.rss</nowiki> "~CNN Top stories"<br />
<br />
will define the feed with feed-name "CNN Top stories"<br />
<br />
===== Hidden feeds =====<br />
<br />
A feed can be '''hidden''' from the regular list of feeds by '''prefixing''' the tag name with an {{ic|!}}.<br />
<br />
For example:<br />
<br />
<nowiki>http://rss.orf.at/news.xml</nowiki> "!ORF News (hidden)"<br />
<br />
The content of a '''hidden''' feed can only be found through a query feed.<br />
<br />
=== Query feeds ===<br />
<br />
Custom feeds can be created from existing feeds by creating what's called a ''query feed'': A feed generated by matching articles against a query. Query feeds are defined in your {{ic|~/.config/newsboat/urls}} file like a normal feed.<br />
They have the following syntax:<br />
<br />
<nowiki>query:FEEDNAME:FILTER_EXPRESSION [TAG ...]</nowiki><br />
<br />
Like a normal feed, a query feed has a name, {{ic|FEEDNAME}}, which is displayed in the feedlist.<br />
The filter expression language for {{ic|FILTER_EXPRESSION}} is defined in the [https://newsboat.org/releases/2.13/docs/newsboat.html#_filter_language newsboat manual].<br />
Query feeds can be optionally tagged, just like a normal feed. See [[#Tagging feeds]].<br />
<br />
==== Basic examples ====<br />
<br />
{{hc|~/.config/newsboat/urls|2=<br />
"query:Example1:age > 1"<br />
"query:Example2:(tags # \"example2\") and (title =~ \"example2\")"<br />
"query:Example3:(rssurl =~ \"example3\") or (total_count > 3)"<br />
}}<br />
<br />
The first example defines a feed named {{ic|Example1}} that will contain all articles that are older than a day<br />
<br />
The second example defines a feed named {{ic|Example2}} that will contain all articles whose feed was tagged {{ic|example2}}<br />
'''and''' whose article title matches {{ic|example2}}. Here the {{ic|#}} is the "contains" operator.<br />
<br />
The third example defines a feed named {{ic|Example3}} that will contain all articles whose feed url matches the<br />
regular expression {{ic|example3}} '''or''' all articles that are apart of a feed that contain more than 3 articles.<br />
<br />
{{Note|The query feed definition must be encapsulated in double quotes. Therefore any other double quotes in its declaration must be escaped}}<br />
<br />
==== Unread articles ====<br />
<br />
To create a feed named {{ic|Unread Articles}} that contains all unread articles, define the following:<br />
<br />
{{hc|~/.config/newsboat/urls|<br />
"query:Unread Articles:unread {{=}} \"yes\""<br />
}}<br />
<br />
==== Amalgamating multiple feeds into one ====<br />
<br />
A good use of query feeds is when you're following a creator whose content is spread across multiple feeds. You can use a query feed to amalgamate all his content into one place.<br />
<br />
{{hc|~/.config/newsboat/urls|<br />
"query:Metafeed:tags # \"metafeed\""<nowiki><br />
https://feed.url/1 metafeed !<br />
https://feed.url/2 metafeed !<br />
https://feed.url/3 metafeed !<br />
</nowiki>}}<br />
<br />
The trick is to assign each individual feed a unique tag - here {{ic|metafeed}} - so that we can match against it in the filter expression. We also make use of [[#Hidden feeds]] - the {{ic|!}} at the end of each feed - so that the individual feeds do not show up in feedlist.<br />
<br />
==== Filtering a specific feed ====<br />
<br />
If a feed contains content you do not want to see, you can filter it by using a query feed.<br />
For example, to monitor package updates you're interested in, you can use:<br />
<br />
{{hc|~/.config/newsboat/urls|<br />
"query:Package Updates:(tags # \"packageupdates\") and (title {{=}}~ \"linux [0-9]{{!}}newsboat\")"<br />
<nowiki>https://archlinux.org/feeds/packages/</nowiki> packageupdates !<br />
}}<br />
<br />
This feed will only display updates to {{Pkg|linux}} and {{Pkg|newsboat}}.<br />
<br />
=== Ignoring articles ===<br />
<br />
There are two ways to ignore articles, delete them or not show them.<br />
<br />
{{hc|~/.newsboat/config|<br />
# ignore-mode "download" # Default: Delete them.<br />
ignore-mode "display" # Do not show them.<br />
}}<br />
<br />
The filter can be configured like so (here in POSIX extended regular expressions):<br />
<br />
{{hc|~/.newsboat/config|<nowiki><br />
ignore-article "https://feed/url" "content =~ \"tele(phone|communications)\"" <br />
ignore-article "https://feed/url" "title =~ \"text_1|text_2\""<br />
</nowiki>}}<br />
<br />
== Configuration ==<br />
<br />
Several aspects of Newsboat’s behaviour can be configured via a configuration file which is located, by default, in {{ic|~/.newsboat/config}} or {{ic|~/.config/newsboat/config}}. This configuration file contains lines of the form:<br />
<br />
<config-command> <arg1> ...<br />
<br />
=== Color schemes ===<br />
<br />
The package ships with a number of schemes in {{ic|/usr/share/doc/newsboat/contrib/colorschemes/}} which can be loaded with the include command like so:<br />
<br />
include /usr/share/doc/newsboat/contrib/colorschemes/inkpot<br />
<br />
=== Additional options ===<br />
<br />
The configuration file can also contain comments, which start with the {{ic|#}} character and go as far as the end of line. To enter a configuration argument that contains spaces, use quotes {{ic|"}} around the whole argument. It’s even possible to integrate the output of external commands into the configuration. The text between two backticks {{ic|`}} is evaluated as shell command, and its output is put on its place instead. This works like backtick evaluation in Bourne-compatible shells and allows users to use external information from the system within the configuration.<br />
<br />
See [https://gist.github.com/anonymous/42d2f5956e7bc8ee1ebc] and [http://moparx.com/configs/newsbeuter/] for example configurations.<br />
<br />
{{Note|To see a complete list of configuration command, consult {{man|1|newsboat|CONFIGURATION COMMANDS}}.}}<br />
<br />
== Tips and tricks ==<br />
<br />
=== Automatic feed reloads ===<br />
<br />
Newsboat can automatically reload all feeds on startup with the following configuration:<br />
<br />
auto-reload yes<br />
<br />
With this setting, Newsboat also runs periodic auto-reloads – by default, every 60 minutes. The number of minutes between automatic reloads can be configured like so:<br />
<br />
reload-time <desired number of minutes><br />
<br />
Alternatively, use [[cron]] or [[systemd]] to automatically reload feeds. Just add a line in your crontab, or create a systemd service/timer unit combo that issues the following command:<br />
<br />
/usr/bin/newsboat -x reload<br />
<br />
=== Loading of feeds in parallel for faster updates ===<br />
<br />
By default, Newsboat will attempt to update entries in {{ic|~/.newsboat/urls}} in sequence; however, the following setting will update them n at a time, in parallel. Adjust n to your liking.<br />
<br />
reload-threads 100<br />
<br />
=== Pass article URL to external command ===<br />
<br />
A clever little hack allows one to pass the URL of an article to an external command. The idea is to use a macro to set the browser that Newsboat opens the article with to the path of some other command and then change it back afterwards.<br />
<br />
For example, subscribers of a particular youtube channel can open the video with [[mpv]], by doing the following:<br />
<br />
macro y set browser "mpv %u" ; open-in-browser ; set browser "elinks %u"<br />
<br />
{{Note| First press the {{ic|,}} key, followed by the keybind to use the macro. In the example above, type {{ic|,}} + {{ic|y}} }}<br />
<br />
=== Subheadings ===<br />
<br />
There is another little hack that allows the user to add subheadings to sort feeds more effectively. This hack involves adding fake feeds to the {{ic|urls}} file like so:<br />
<br />
---Heading---<br />
<br />
{{Note|the {{ic|---}} characters are optional but having some sort of character identifying the headings is useful for styling.}}<br />
<br />
Then in {{ic|~/.config/newsboat/config}}, add the following two lines:<br />
<br />
highlight feedlist "---.*---" ''COLOR_OF_YOUR_CHOOSING'' default bold<br />
highlight feedlist ".*0/0.." default default invis<br />
<br />
Of course, replace {{ic|''COLOR_OF_YOUR_CHOOSING''}} with a [https://newsboat.org/releases/2.24/docs/newsboat.html#_configuring_colors newsboat supported color].<br />
<br />
This trick can also interact with Tags by replacing {{ic|---Heading---}} with:<br />
<br />
"query:---Heading---:tags # \"Tag\""<br />
<br />
Then tagging all the feeds below the heading with {{ic|Tag}}.<br />
<br />
== Troubleshooting ==<br />
<br />
=== Newsboat will not start ===<br />
<br />
Newsboat cannot start without any configured feeds! To add URLs, see [[#Managing feeds]]. If that is not the problem, check to see if another instance of Newsboat is running. Newsboat issues a lock on its database so that only one instance can access it at a time; thus, attempting to open a second instance will fail.<br />
<br />
== See also ==<br />
<br />
*[https://newsboat.org/ Official web site]<br />
*[https://newsboat.org/releases/2.24/docs/newsboat.html Full documentation]<br />
*[https://sanctum.geek.nz/arabesque/rss-with-newsboat/ Arabesque: RSS with Newsboat]</div>Captaincurriehttps://wiki.archlinux.org/index.php?title=Newsboat&diff=766152Newsboat2023-02-02T02:25:14Z<p>Captaincurrie: /* Filtering a specific feed */ Made the example feed more general and useful</p>
<hr />
<div>[[Category:News aggregators]]<br />
[[Category:Console applications]]<br />
[[ja:Newsboat]]<br />
{{Related articles start}}<br />
{{Related|Web feed}}<br />
{{Related articles end}}<br />
<br />
[https://newsboat.org/ Newsboat] is an open source news aggregator licensed under the MIT License.<br />
<br />
From {{man|1|newsboat|DESCRIPTION}}:<br />
<br />
:Newsboat is an RSS/Atom feed reader for text terminals. RSS and Atom are a number of widely-used XML formats to transmit, publish and syndicate articles, for example news or blog articles. Newsboat is designed to be used on text terminals on Unix or Unix-like systems such as GNU/Linux, BSD or macOS. <br />
<br />
Newsboat is a [https://groups.google.com/forum/#!topic/newsbeuter/RPtlWX8CPGU fork] of abandoned Newsbeuter.<br />
<br />
== Installation ==<br />
<br />
[[Install]] the {{Pkg|newsboat}} package. For the development version, install the {{AUR|newsboat-git}} package.<br />
<br />
== Usage ==<br />
<br />
Newsboat cannot start without any configured feeds. Feeds can be configured in {{ic|~/.newsboat/urls}}. Newsboat can be started from the command line with<br />
<br />
$ newsboat<br />
<br />
Press the {{ic|?}} key to see a list of all keybindings. Keybindings can be rebound, see [[#Configuration]].<br />
<br />
== Managing feeds ==<br />
<br />
Adding, removing, and tagging feeds is done by editing the urls file. By default that is {{ic|~/.newsboat/urls}}.<br />
<br />
{{Tip|In addition to newsboat specific feeds in this section, be sure to see the [[Web feed]] article for additional options.}}<br />
<br />
=== RSS or ATOM sources ===<br />
<br />
To add URLs, open {{ic|~/.newsboat/urls}} with your favorite text editor and add the URLs, one per line:<br />
<br />
<nowiki>http://rss.cnn.com/rss/cnn_topstories.rss</nowiki><br />
<nowiki>http://newsrss.bbc.co.uk/rss/newsonline_world_edition/front_page/rss.xml</nowiki><br />
<br />
To add URLs that have restricted access via username/password, simply provide the username/password in the following way:<br />
<br />
<nowiki>http://username:password@hostname.domain.tld/feed.rss</nowiki><br />
<br />
In order to protect username and password, make sure that {{ic|~/.newsboat/urls}} has the appropriate permissions. Newsboat also makes sure that usernames and passwords within URLs aren’t displayed in its user interface. In case there is a @ in the username, type it as %40 instead so that it can be distinguished from the @ that separates the username/password part from the hostname part.<br />
<br />
To configure local files as feeds, simply prefix the local path with {{ic|file://}} and add it to the {{ic|~/.newsboat/urls}} file:<br />
<br />
file:///var/log/rss_eventlog.xml<br />
<br />
=== HTML as a source ===<br />
<br />
If HTML sources can be converted to RSS via a user supplied script, newboat can both execute this script and consume the output.<br />
<br />
This is accomplished by using the {{ic|filter:}} prefix in the configuration file. For example, write a script that can read HTML from stdin and print out an RSS or Atom feed to stdout. Save that script to {{ic|~/.newsboat/html2rss.sh}} and add the following line to the {{ic|urls}}:<br />
<br />
<nowiki>filter:~/.newsboat/html2rss.sh:https://myurl.com</nowiki><br />
<br />
* For several examples using this strategy, see [https://github.com/graysky2/newsboat_custom_stuff graysky's newsboat repo].<br />
* For more discussion, see [https://github.com/newsboat/newsboat/issues/1157 Possible to config newsboat to look at a web exposed directory and report changes #1157].<br />
<br />
=== Tagging feeds ===<br />
<br />
Every feed can be assigned 0 or more tags. This makes it easy to categorize your feeds as well as the ability to easily apply commands to multiple feeds at once.<br />
<br />
Usually, the {{ic|~/.newsboat/urls}} file contains one RSS feed URL per line. To assign a tag to an RSS feed, simply attach it as a single word, separated by blanks such as space or tab. If the tag needs to contain spaces, use quotes (") around the tag (see example below). An example may look like this:<br />
<br />
<nowiki>http://blog.fefe.de/rss.xml?html interesting conspiracy news "cool stuff"</nowiki><br />
<nowiki>http://rss.orf.at/news.xml news orf</nowiki><br />
<nowiki>http://www.heise.de/newsticker/heise.rdf news interesting</nowiki><br />
<br />
Starting Newsboat with this configuration, one can press {{ic|t}} to select a tag. Upon selecting the tag "news", one will see all three RSS feeds. Pressing {{ic|t}} again and e.g. selecting the "conspiracy" tag, will only show the {{ic|<nowiki>http://blog.fefe.de/rss.xml?html</nowiki>}} RSS feed. Pressing {{ic|Ctrl-T}} clears the current tag,<br />
and again shows all RSS feeds, regardless of their assigned tags.<br />
<br />
{{Note| If the tag name contains spaces, the tag must be bounded by {{ic|"}}}}<br />
<br />
==== Special tags ====<br />
<br />
===== Custom feed names =====<br />
<br />
The name of a feed can be defined with a special tag in your urls file. Simply '''prefix''' the tag name with the {{ic|~}} character and the tag name will become the feed name.<br />
<br />
For example:<br />
<br />
<nowiki>http://rss.cnn.com/rss/cnn_topstories.rss</nowiki> "~CNN Top stories"<br />
<br />
will define the feed with feed-name "CNN Top stories"<br />
<br />
===== Hidden feeds =====<br />
<br />
A feed can be '''hidden''' from the regular list of feeds by '''prefixing''' the tag name with an {{ic|!}}.<br />
<br />
For example:<br />
<br />
<nowiki>http://rss.orf.at/news.xml</nowiki> "!ORF News (hidden)"<br />
<br />
The content of a '''hidden''' feed can only be found through a query feed.<br />
<br />
=== Query feeds ===<br />
<br />
Custom feeds can be created from existing feeds by creating what's called a ''query feed'': A feed generated by matching articles against a query. Query feeds are defined in your {{ic|~/.config/newsboat/urls}} file like a normal feed.<br />
They have the following syntax:<br />
<br />
<nowiki>query:FEEDNAME:FILTER_EXPRESSION [TAG ...]</nowiki><br />
<br />
Like a normal feed, a query feed has a name, {{ic|FEEDNAME}}, which is displayed in the feedlist.<br />
The filter expression language for {{ic|FILTER_EXPRESSION}} is defined in the [https://newsboat.org/releases/2.13/docs/newsboat.html#_filter_language newsboat manual].<br />
Query feeds can be optionally tagged, just like a normal feed. See [[#Tagging feeds]].<br />
<br />
==== Basic examples ====<br />
<br />
{{hc|~/.config/newsboat/urls|2=<br />
"query:Example1:age > 1"<br />
"query:Example2:(tags # \"example2\") and (title =~ \"example2\")"<br />
"query:Example3:(rssurl =~ \"example3\") or (total_count > 3)"<br />
}}<br />
<br />
The first example defines a feed named {{ic|Example1}} that will contain all articles that are older than a day<br />
<br />
The second example defines a feed named {{ic|Example2}} that will contain all articles whose feed was tagged {{ic|example2}}<br />
'''and''' whose article title matches {{ic|example2}}. Here the {{ic|#}} is the "contains" operator.<br />
<br />
The third example defines a feed named {{ic|Example3}} that will contain all articles whose feed url matches the<br />
regular expression {{ic|example3}} '''or''' all articles that are apart of a feed that contain more than 3 articles.<br />
<br />
{{Note|The query feed definition must be encapsulated in double quotes. Therefore any other double quotes in its declaration must be escaped}}<br />
<br />
==== Unread articles ====<br />
<br />
To create a feed named {{ic|Unread Articles}} that contains all unread articles, define the following:<br />
<br />
{{hc|~/.config/newsboat/urls|<br />
"query:Unread Articles:unread {{=}} \"yes\""<br />
}}<br />
<br />
==== Amalgamating multiple feeds into one ====<br />
<br />
A good use of query feeds is when you're following a creator whose content is spread across multiple feeds. You can use a query feed to amalgamate all his content into one place.<br />
<br />
{{hc|~/.config/newsboat/urls|<br />
"query:Metafeed:tags # \"metafeed\""<nowiki><br />
https://feed.url/1 metafeed !<br />
https://feed.url/2 metafeed !<br />
https://feed.url/3 metafeed !<br />
</nowiki>}}<br />
<br />
The trick is to assign each individual feed a unique tag - here {{ic|metafeed}} - so that we can match against it in the filter expression. We also make use of [[#Hidden feeds]] - the {{ic|!}} at the end of each feed - so that the individual feeds do not show up in feedlist.<br />
<br />
==== Filtering a specific feed ====<br />
<br />
If a feed contains content you do not want to see, you can filter it by using a query feed.<br />
For example, to monitor package updates you're interested in, you can use:<br />
<br />
{{hc|~/.config/newsboat/urls|<br />
"query:Package Updates:(tags # \"packageupdates\") and (title {{=}}~ \"linux [0-9]{{!}}newsboat\")"<br />
<nowiki>https://archlinux.org/feeds/packages/</nowiki> packageupdates !<br />
}}<br />
<br />
=== Ignoring articles ===<br />
<br />
There are two ways to ignore articles, delete them or not show them.<br />
<br />
{{hc|~/.newsboat/config|<br />
# ignore-mode "download" # Default: Delete them.<br />
ignore-mode "display" # Do not show them.<br />
}}<br />
<br />
The filter can be configured like so (here in POSIX extended regular expressions):<br />
<br />
{{hc|~/.newsboat/config|<nowiki><br />
ignore-article "https://feed/url" "content =~ \"tele(phone|communications)\"" <br />
ignore-article "https://feed/url" "title =~ \"text_1|text_2\""<br />
</nowiki>}}<br />
<br />
== Configuration ==<br />
<br />
Several aspects of Newsboat’s behaviour can be configured via a configuration file which is located, by default, in {{ic|~/.newsboat/config}} or {{ic|~/.config/newsboat/config}}. This configuration file contains lines of the form:<br />
<br />
<config-command> <arg1> ...<br />
<br />
=== Color schemes ===<br />
<br />
The package ships with a number of schemes in {{ic|/usr/share/doc/newsboat/contrib/colorschemes/}} which can be loaded with the include command like so:<br />
<br />
include /usr/share/doc/newsboat/contrib/colorschemes/inkpot<br />
<br />
=== Additional options ===<br />
<br />
The configuration file can also contain comments, which start with the {{ic|#}} character and go as far as the end of line. To enter a configuration argument that contains spaces, use quotes {{ic|"}} around the whole argument. It’s even possible to integrate the output of external commands into the configuration. The text between two backticks {{ic|`}} is evaluated as shell command, and its output is put on its place instead. This works like backtick evaluation in Bourne-compatible shells and allows users to use external information from the system within the configuration.<br />
<br />
See [https://gist.github.com/anonymous/42d2f5956e7bc8ee1ebc] and [http://moparx.com/configs/newsbeuter/] for example configurations.<br />
<br />
{{Note|To see a complete list of configuration command, consult {{man|1|newsboat|CONFIGURATION COMMANDS}}.}}<br />
<br />
== Tips and tricks ==<br />
<br />
=== Automatic feed reloads ===<br />
<br />
Newsboat can automatically reload all feeds on startup with the following configuration:<br />
<br />
auto-reload yes<br />
<br />
With this setting, Newsboat also runs periodic auto-reloads – by default, every 60 minutes. The number of minutes between automatic reloads can be configured like so:<br />
<br />
reload-time <desired number of minutes><br />
<br />
Alternatively, use [[cron]] or [[systemd]] to automatically reload feeds. Just add a line in your crontab, or create a systemd service/timer unit combo that issues the following command:<br />
<br />
/usr/bin/newsboat -x reload<br />
<br />
=== Loading of feeds in parallel for faster updates ===<br />
<br />
By default, Newsboat will attempt to update entries in {{ic|~/.newsboat/urls}} in sequence; however, the following setting will update them n at a time, in parallel. Adjust n to your liking.<br />
<br />
reload-threads 100<br />
<br />
=== Pass article URL to external command ===<br />
<br />
A clever little hack allows one to pass the URL of an article to an external command. The idea is to use a macro to set the browser that Newsboat opens the article with to the path of some other command and then change it back afterwards.<br />
<br />
For example, subscribers of a particular youtube channel can open the video with [[mpv]], by doing the following:<br />
<br />
macro y set browser "mpv %u" ; open-in-browser ; set browser "elinks %u"<br />
<br />
{{Note| First press the {{ic|,}} key, followed by the keybind to use the macro. In the example above, type {{ic|,}} + {{ic|y}} }}<br />
<br />
=== Subheadings ===<br />
<br />
There is another little hack that allows the user to add subheadings to sort feeds more effectively. This hack involves adding fake feeds to the {{ic|urls}} file like so:<br />
<br />
---Heading---<br />
<br />
{{Note|the {{ic|---}} characters are optional but having some sort of character identifying the headings is useful for styling.}}<br />
<br />
Then in {{ic|~/.config/newsboat/config}}, add the following two lines:<br />
<br />
highlight feedlist "---.*---" ''COLOR_OF_YOUR_CHOOSING'' default bold<br />
highlight feedlist ".*0/0.." default default invis<br />
<br />
Of course, replace {{ic|''COLOR_OF_YOUR_CHOOSING''}} with a [https://newsboat.org/releases/2.24/docs/newsboat.html#_configuring_colors newsboat supported color].<br />
<br />
This trick can also interact with Tags by replacing {{ic|---Heading---}} with:<br />
<br />
"query:---Heading---:tags # \"Tag\""<br />
<br />
Then tagging all the feeds below the heading with {{ic|Tag}}.<br />
<br />
== Troubleshooting ==<br />
<br />
=== Newsboat will not start ===<br />
<br />
Newsboat cannot start without any configured feeds! To add URLs, see [[#Managing feeds]]. If that is not the problem, check to see if another instance of Newsboat is running. Newsboat issues a lock on its database so that only one instance can access it at a time; thus, attempting to open a second instance will fail.<br />
<br />
== See also ==<br />
<br />
*[https://newsboat.org/ Official web site]<br />
*[https://newsboat.org/releases/2.24/docs/newsboat.html Full documentation]<br />
*[https://sanctum.geek.nz/arabesque/rss-with-newsboat/ Arabesque: RSS with Newsboat]</div>Captaincurriehttps://wiki.archlinux.org/index.php?title=Newsboat&diff=766151Newsboat2023-02-02T02:15:29Z<p>Captaincurrie: /* Filtering a specific feed */ fixed incorrect feed declaration</p>
<hr />
<div>[[Category:News aggregators]]<br />
[[Category:Console applications]]<br />
[[ja:Newsboat]]<br />
{{Related articles start}}<br />
{{Related|Web feed}}<br />
{{Related articles end}}<br />
<br />
[https://newsboat.org/ Newsboat] is an open source news aggregator licensed under the MIT License.<br />
<br />
From {{man|1|newsboat|DESCRIPTION}}:<br />
<br />
:Newsboat is an RSS/Atom feed reader for text terminals. RSS and Atom are a number of widely-used XML formats to transmit, publish and syndicate articles, for example news or blog articles. Newsboat is designed to be used on text terminals on Unix or Unix-like systems such as GNU/Linux, BSD or macOS. <br />
<br />
Newsboat is a [https://groups.google.com/forum/#!topic/newsbeuter/RPtlWX8CPGU fork] of abandoned Newsbeuter.<br />
<br />
== Installation ==<br />
<br />
[[Install]] the {{Pkg|newsboat}} package. For the development version, install the {{AUR|newsboat-git}} package.<br />
<br />
== Usage ==<br />
<br />
Newsboat cannot start without any configured feeds. Feeds can be configured in {{ic|~/.newsboat/urls}}. Newsboat can be started from the command line with<br />
<br />
$ newsboat<br />
<br />
Press the {{ic|?}} key to see a list of all keybindings. Keybindings can be rebound, see [[#Configuration]].<br />
<br />
== Managing feeds ==<br />
<br />
Adding, removing, and tagging feeds is done by editing the urls file. By default that is {{ic|~/.newsboat/urls}}.<br />
<br />
{{Tip|In addition to newsboat specific feeds in this section, be sure to see the [[Web feed]] article for additional options.}}<br />
<br />
=== RSS or ATOM sources ===<br />
<br />
To add URLs, open {{ic|~/.newsboat/urls}} with your favorite text editor and add the URLs, one per line:<br />
<br />
<nowiki>http://rss.cnn.com/rss/cnn_topstories.rss</nowiki><br />
<nowiki>http://newsrss.bbc.co.uk/rss/newsonline_world_edition/front_page/rss.xml</nowiki><br />
<br />
To add URLs that have restricted access via username/password, simply provide the username/password in the following way:<br />
<br />
<nowiki>http://username:password@hostname.domain.tld/feed.rss</nowiki><br />
<br />
In order to protect username and password, make sure that {{ic|~/.newsboat/urls}} has the appropriate permissions. Newsboat also makes sure that usernames and passwords within URLs aren’t displayed in its user interface. In case there is a @ in the username, type it as %40 instead so that it can be distinguished from the @ that separates the username/password part from the hostname part.<br />
<br />
To configure local files as feeds, simply prefix the local path with {{ic|file://}} and add it to the {{ic|~/.newsboat/urls}} file:<br />
<br />
file:///var/log/rss_eventlog.xml<br />
<br />
=== HTML as a source ===<br />
<br />
If HTML sources can be converted to RSS via a user supplied script, newboat can both execute this script and consume the output.<br />
<br />
This is accomplished by using the {{ic|filter:}} prefix in the configuration file. For example, write a script that can read HTML from stdin and print out an RSS or Atom feed to stdout. Save that script to {{ic|~/.newsboat/html2rss.sh}} and add the following line to the {{ic|urls}}:<br />
<br />
<nowiki>filter:~/.newsboat/html2rss.sh:https://myurl.com</nowiki><br />
<br />
* For several examples using this strategy, see [https://github.com/graysky2/newsboat_custom_stuff graysky's newsboat repo].<br />
* For more discussion, see [https://github.com/newsboat/newsboat/issues/1157 Possible to config newsboat to look at a web exposed directory and report changes #1157].<br />
<br />
=== Tagging feeds ===<br />
<br />
Every feed can be assigned 0 or more tags. This makes it easy to categorize your feeds as well as the ability to easily apply commands to multiple feeds at once.<br />
<br />
Usually, the {{ic|~/.newsboat/urls}} file contains one RSS feed URL per line. To assign a tag to an RSS feed, simply attach it as a single word, separated by blanks such as space or tab. If the tag needs to contain spaces, use quotes (") around the tag (see example below). An example may look like this:<br />
<br />
<nowiki>http://blog.fefe.de/rss.xml?html interesting conspiracy news "cool stuff"</nowiki><br />
<nowiki>http://rss.orf.at/news.xml news orf</nowiki><br />
<nowiki>http://www.heise.de/newsticker/heise.rdf news interesting</nowiki><br />
<br />
Starting Newsboat with this configuration, one can press {{ic|t}} to select a tag. Upon selecting the tag "news", one will see all three RSS feeds. Pressing {{ic|t}} again and e.g. selecting the "conspiracy" tag, will only show the {{ic|<nowiki>http://blog.fefe.de/rss.xml?html</nowiki>}} RSS feed. Pressing {{ic|Ctrl-T}} clears the current tag,<br />
and again shows all RSS feeds, regardless of their assigned tags.<br />
<br />
{{Note| If the tag name contains spaces, the tag must be bounded by {{ic|"}}}}<br />
<br />
==== Special tags ====<br />
<br />
===== Custom feed names =====<br />
<br />
The name of a feed can be defined with a special tag in your urls file. Simply '''prefix''' the tag name with the {{ic|~}} character and the tag name will become the feed name.<br />
<br />
For example:<br />
<br />
<nowiki>http://rss.cnn.com/rss/cnn_topstories.rss</nowiki> "~CNN Top stories"<br />
<br />
will define the feed with feed-name "CNN Top stories"<br />
<br />
===== Hidden feeds =====<br />
<br />
A feed can be '''hidden''' from the regular list of feeds by '''prefixing''' the tag name with an {{ic|!}}.<br />
<br />
For example:<br />
<br />
<nowiki>http://rss.orf.at/news.xml</nowiki> "!ORF News (hidden)"<br />
<br />
The content of a '''hidden''' feed can only be found through a query feed.<br />
<br />
=== Query feeds ===<br />
<br />
Custom feeds can be created from existing feeds by creating what's called a ''query feed'': A feed generated by matching articles against a query. Query feeds are defined in your {{ic|~/.config/newsboat/urls}} file like a normal feed.<br />
They have the following syntax:<br />
<br />
<nowiki>query:FEEDNAME:FILTER_EXPRESSION [TAG ...]</nowiki><br />
<br />
Like a normal feed, a query feed has a name, {{ic|FEEDNAME}}, which is displayed in the feedlist.<br />
The filter expression language for {{ic|FILTER_EXPRESSION}} is defined in the [https://newsboat.org/releases/2.13/docs/newsboat.html#_filter_language newsboat manual].<br />
Query feeds can be optionally tagged, just like a normal feed. See [[#Tagging feeds]].<br />
<br />
==== Basic examples ====<br />
<br />
{{hc|~/.config/newsboat/urls|2=<br />
"query:Example1:age > 1"<br />
"query:Example2:(tags # \"example2\") and (title =~ \"example2\")"<br />
"query:Example3:(rssurl =~ \"example3\") or (total_count > 3)"<br />
}}<br />
<br />
The first example defines a feed named {{ic|Example1}} that will contain all articles that are older than a day<br />
<br />
The second example defines a feed named {{ic|Example2}} that will contain all articles whose feed was tagged {{ic|example2}}<br />
'''and''' whose article title matches {{ic|example2}}. Here the {{ic|#}} is the "contains" operator.<br />
<br />
The third example defines a feed named {{ic|Example3}} that will contain all articles whose feed url matches the<br />
regular expression {{ic|example3}} '''or''' all articles that are apart of a feed that contain more than 3 articles.<br />
<br />
{{Note|The query feed definition must be encapsulated in double quotes. Therefore any other double quotes in its declaration must be escaped}}<br />
<br />
==== Unread articles ====<br />
<br />
To create a feed named {{ic|Unread Articles}} that contains all unread articles, define the following:<br />
<br />
{{hc|~/.config/newsboat/urls|<br />
"query:Unread Articles:unread {{=}} \"yes\""<br />
}}<br />
<br />
==== Amalgamating multiple feeds into one ====<br />
<br />
A good use of query feeds is when you're following a creator whose content is spread across multiple feeds. You can use a query feed to amalgamate all his content into one place.<br />
<br />
{{hc|~/.config/newsboat/urls|<br />
"query:Metafeed:tags # \"metafeed\""<nowiki><br />
https://feed.url/1 metafeed !<br />
https://feed.url/2 metafeed !<br />
https://feed.url/3 metafeed !<br />
</nowiki>}}<br />
<br />
The trick is to assign each individual feed a unique tag - here {{ic|metafeed}} - so that we can match against it in the filter expression. We also make use of [[#Hidden feeds]] - the {{ic|!}} at the end of each feed - so that the individual feeds do not show up in feedlist.<br />
<br />
==== Filtering a specific feed ====<br />
<br />
If a feed contains content you do not want to see, you can filter it by using a query feed.<br />
For example, to monitor updates of the arch kernel, you could use the following:<br />
<br />
{{hc|~/.config/newsboat/urls|<br />
"query:Arch Kernel:(tags # \"archkernel\") and (title {{=}}~ \"linux [0-9]\")"<br />
<nowiki>https://archlinux.org/feeds/packages/</nowiki> archkernel !<br />
}}<br />
<br />
=== Ignoring articles ===<br />
<br />
There are two ways to ignore articles, delete them or not show them.<br />
<br />
{{hc|~/.newsboat/config|<br />
# ignore-mode "download" # Default: Delete them.<br />
ignore-mode "display" # Do not show them.<br />
}}<br />
<br />
The filter can be configured like so (here in POSIX extended regular expressions):<br />
<br />
{{hc|~/.newsboat/config|<nowiki><br />
ignore-article "https://feed/url" "content =~ \"tele(phone|communications)\"" <br />
ignore-article "https://feed/url" "title =~ \"text_1|text_2\""<br />
</nowiki>}}<br />
<br />
== Configuration ==<br />
<br />
Several aspects of Newsboat’s behaviour can be configured via a configuration file which is located, by default, in {{ic|~/.newsboat/config}} or {{ic|~/.config/newsboat/config}}. This configuration file contains lines of the form:<br />
<br />
<config-command> <arg1> ...<br />
<br />
=== Color schemes ===<br />
<br />
The package ships with a number of schemes in {{ic|/usr/share/doc/newsboat/contrib/colorschemes/}} which can be loaded with the include command like so:<br />
<br />
include /usr/share/doc/newsboat/contrib/colorschemes/inkpot<br />
<br />
=== Additional options ===<br />
<br />
The configuration file can also contain comments, which start with the {{ic|#}} character and go as far as the end of line. To enter a configuration argument that contains spaces, use quotes {{ic|"}} around the whole argument. It’s even possible to integrate the output of external commands into the configuration. The text between two backticks {{ic|`}} is evaluated as shell command, and its output is put on its place instead. This works like backtick evaluation in Bourne-compatible shells and allows users to use external information from the system within the configuration.<br />
<br />
See [https://gist.github.com/anonymous/42d2f5956e7bc8ee1ebc] and [http://moparx.com/configs/newsbeuter/] for example configurations.<br />
<br />
{{Note|To see a complete list of configuration command, consult {{man|1|newsboat|CONFIGURATION COMMANDS}}.}}<br />
<br />
== Tips and tricks ==<br />
<br />
=== Automatic feed reloads ===<br />
<br />
Newsboat can automatically reload all feeds on startup with the following configuration:<br />
<br />
auto-reload yes<br />
<br />
With this setting, Newsboat also runs periodic auto-reloads – by default, every 60 minutes. The number of minutes between automatic reloads can be configured like so:<br />
<br />
reload-time <desired number of minutes><br />
<br />
Alternatively, use [[cron]] or [[systemd]] to automatically reload feeds. Just add a line in your crontab, or create a systemd service/timer unit combo that issues the following command:<br />
<br />
/usr/bin/newsboat -x reload<br />
<br />
=== Loading of feeds in parallel for faster updates ===<br />
<br />
By default, Newsboat will attempt to update entries in {{ic|~/.newsboat/urls}} in sequence; however, the following setting will update them n at a time, in parallel. Adjust n to your liking.<br />
<br />
reload-threads 100<br />
<br />
=== Pass article URL to external command ===<br />
<br />
A clever little hack allows one to pass the URL of an article to an external command. The idea is to use a macro to set the browser that Newsboat opens the article with to the path of some other command and then change it back afterwards.<br />
<br />
For example, subscribers of a particular youtube channel can open the video with [[mpv]], by doing the following:<br />
<br />
macro y set browser "mpv %u" ; open-in-browser ; set browser "elinks %u"<br />
<br />
{{Note| First press the {{ic|,}} key, followed by the keybind to use the macro. In the example above, type {{ic|,}} + {{ic|y}} }}<br />
<br />
=== Subheadings ===<br />
<br />
There is another little hack that allows the user to add subheadings to sort feeds more effectively. This hack involves adding fake feeds to the {{ic|urls}} file like so:<br />
<br />
---Heading---<br />
<br />
{{Note|the {{ic|---}} characters are optional but having some sort of character identifying the headings is useful for styling.}}<br />
<br />
Then in {{ic|~/.config/newsboat/config}}, add the following two lines:<br />
<br />
highlight feedlist "---.*---" ''COLOR_OF_YOUR_CHOOSING'' default bold<br />
highlight feedlist ".*0/0.." default default invis<br />
<br />
Of course, replace {{ic|''COLOR_OF_YOUR_CHOOSING''}} with a [https://newsboat.org/releases/2.24/docs/newsboat.html#_configuring_colors newsboat supported color].<br />
<br />
This trick can also interact with Tags by replacing {{ic|---Heading---}} with:<br />
<br />
"query:---Heading---:tags # \"Tag\""<br />
<br />
Then tagging all the feeds below the heading with {{ic|Tag}}.<br />
<br />
== Troubleshooting ==<br />
<br />
=== Newsboat will not start ===<br />
<br />
Newsboat cannot start without any configured feeds! To add URLs, see [[#Managing feeds]]. If that is not the problem, check to see if another instance of Newsboat is running. Newsboat issues a lock on its database so that only one instance can access it at a time; thus, attempting to open a second instance will fail.<br />
<br />
== See also ==<br />
<br />
*[https://newsboat.org/ Official web site]<br />
*[https://newsboat.org/releases/2.24/docs/newsboat.html Full documentation]<br />
*[https://sanctum.geek.nz/arabesque/rss-with-newsboat/ Arabesque: RSS with Newsboat]</div>Captaincurriehttps://wiki.archlinux.org/index.php?title=Newsboat&diff=766036Newsboat2023-02-01T14:16:11Z<p>Captaincurrie: /* Query feeds */ formatting</p>
<hr />
<div>[[Category:News aggregators]]<br />
[[Category:Console applications]]<br />
[[ja:Newsboat]]<br />
{{Related articles start}}<br />
{{Related|Web feed}}<br />
{{Related articles end}}<br />
<br />
[https://newsboat.org/ Newsboat] is an open source news aggregator licensed under the MIT License.<br />
<br />
From {{man|1|newsboat|DESCRIPTION}}:<br />
<br />
:Newsboat is an RSS/Atom feed reader for text terminals. RSS and Atom are a number of widely-used XML formats to transmit, publish and syndicate articles, for example news or blog articles. Newsboat is designed to be used on text terminals on Unix or Unix-like systems such as GNU/Linux, BSD or macOS. <br />
<br />
Newsboat is a [https://groups.google.com/forum/#!topic/newsbeuter/RPtlWX8CPGU fork] of abandoned Newsbeuter.<br />
<br />
== Installation ==<br />
<br />
Install the {{Pkg|newsboat}} package. For the development version, install the {{AUR|newsboat-git}} package.<br />
<br />
== Usage ==<br />
<br />
Newsboat cannot start without any configured feeds. Feeds can be configured in {{ic|~/.newsboat/urls}}. Newsboat can be started from the command line with<br />
<br />
$ newsboat<br />
<br />
Press the {{ic|?}} key to see a list of all keybindings. Keybindings can be rebound, see [[#Configuration]].<br />
<br />
== Managing feeds ==<br />
<br />
Adding, removing, and tagging feeds is done by editing the urls file. By default that is {{ic|~/.newsboat/urls}}.<br />
<br />
{{Tip|In addition to newsboat specific feeds in this section, be sure to see the [[Web feed]] article for additional options.}}<br />
<br />
=== RSS or ATOM sources ===<br />
<br />
To add URLs, open {{ic|~/.newsboat/urls}} with your favorite text editor and add the URLs, one per line:<br />
<br />
<nowiki>http://rss.cnn.com/rss/cnn_topstories.rss</nowiki><br />
<nowiki>http://newsrss.bbc.co.uk/rss/newsonline_world_edition/front_page/rss.xml</nowiki><br />
<br />
To add URLs that have restricted access via username/password, simply provide the username/password in the following way:<br />
<br />
<nowiki>http://username:password@hostname.domain.tld/feed.rss</nowiki><br />
<br />
In order to protect username and password, make sure that {{ic|~/.newsboat/urls}} has the appropriate permissions. Newsboat also makes sure that usernames and passwords within URLs aren’t displayed in its user interface. In case there is a @ in the username, type it as %40 instead so that it can be distinguished from the @ that separates the username/password part from the hostname part.<br />
<br />
To configure local files as feeds, simply prefix the local path with {{ic|file://}} and add it to the {{ic|~/.newsboat/urls}} file:<br />
<br />
file:///var/log/rss_eventlog.xml<br />
<br />
=== HTML as a source ===<br />
<br />
If HTML sources can be converted to RSS via a user supplied script, newboat can both execute this script and consume the output.<br />
<br />
This is accomplished by using the {{ic|filter:}} prefix in the configuration file. For example, write a script that can read HTML from stdin and print out an RSS or Atom feed to stdout. Save that script to {{ic|~/.newsboat/html2rss.sh}} and add the following line to the {{ic|urls}}:<br />
<br />
<nowiki>filter:~/.newsboat/html2rss.sh:https://myurl.com</nowiki><br />
<br />
* For several examples using this strategy, see [https://github.com/graysky2/newsboat_custom_stuff graysky's newsboat repo].<br />
* For more discussion, see [https://github.com/newsboat/newsboat/issues/1157 Possible to config newsboat to look at a web exposed directory and report changes #1157].<br />
<br />
=== Tagging feeds ===<br />
<br />
Every feed can be assigned 0 or more tags. This makes it easy to categorize your feeds as well as the ability to easily apply commands to multiple feeds at once.<br />
<br />
Usually, the {{ic|~/.newsboat/urls}} file contains one RSS feed URL per line. To assign a tag to an RSS feed, simply attach it as a single word, separated by blanks such as space or tab. If the tag needs to contain spaces, use quotes (") around the tag (see example below). An example may look like this:<br />
<br />
<nowiki>http://blog.fefe.de/rss.xml?html interesting conspiracy news "cool stuff"</nowiki><br />
<nowiki>http://rss.orf.at/news.xml news orf</nowiki><br />
<nowiki>http://www.heise.de/newsticker/heise.rdf news interesting</nowiki><br />
<br />
Starting Newsboat with this configuration, one can press {{ic|t}} to select a tag. Upon selecting the tag "news", one will see all three RSS feeds. Pressing {{ic|t}} again and e.g. selecting the "conspiracy" tag, will only show the {{ic|<nowiki>http://blog.fefe.de/rss.xml?html</nowiki>}} RSS feed. Pressing {{ic|Ctrl-T}} clears the current tag,<br />
and again shows all RSS feeds, regardless of their assigned tags.<br />
<br />
{{Note| If the tag name contains spaces, the tag must be bounded by {{ic|"}}}}<br />
<br />
==== Special tags ====<br />
<br />
===== Custom feed names =====<br />
<br />
The name of a feed can be defined with a special tag in your urls file. Simply '''prefix''' the tag name with the {{ic|~}} character and the tag name will become the feed name.<br />
<br />
For example:<br />
<br />
<nowiki>http://rss.cnn.com/rss/cnn_topstories.rss</nowiki> "~CNN Top stories"<br />
<br />
will define the feed with feed-name "CNN Top stories"<br />
<br />
===== Hidden feeds =====<br />
<br />
A feed can be '''hidden''' from the regular list of feeds by '''prefixing''' the tag name with an {{ic|!}}.<br />
<br />
For example:<br />
<br />
<nowiki>http://rss.orf.at/news.xml</nowiki> "!ORF News (hidden)"<br />
<br />
The content of a '''hidden''' feed can only be found through a query feed.<br />
<br />
=== Query feeds ===<br />
<br />
Custom feeds can be created from existing feeds by creating what's called a ''query feed'': A feed generated by matching articles against a query. Query feeds are defined in your {{ic|~/.config/newsboat/urls}} file like a normal feed.<br />
They have the following syntax:<br />
<br />
<nowiki>query:FEEDNAME:FILTER_EXPRESSION [TAG ...]</nowiki><br />
<br />
Like a normal feed, a query feed has a name, {{ic|FEEDNAME}}, which is displayed in the feedlist.<br />
The filter expression language for {{ic|FILTER_EXPRESSION}} is defined in the [https://newsboat.org/releases/2.13/docs/newsboat.html#_filter_language newsboat manual].<br />
Query feeds can be optionally tagged, just like a normal feed. See [[#Tagging feeds]].<br />
<br />
==== Basic Examples ====<br />
<br />
{{hc|~/.config/newsboat/urls|<br />
"query:Example1:age > 1"<br />
"query:Example2:(tags # \"example2\") and (title {{=}}~ \"example2\")"<br />
"query:Example3:(rssurl {{=}}~ \"example3\") or (total_count > 3)"<br />
}}<br />
<br />
The first example defines a feed named {{ic|Example1}} that will contain all articles that are older than a day<br />
<br />
The second example defines a feed named {{ic|Example2}} that will contain all articles whose feed was tagged {{ic|example2}}<br />
'''and''' whose article title matches {{ic|example2}}. Here the {{ic|#}} is the "contains" operator.<br />
<br />
The third example defines a feed named {{ic|Example3}} that will contain all articles whose feed url matches the<br />
regular expression {{ic|example3}} '''or''' all articles that are apart of a feed that contain more than 3 articles.<br />
<br />
{{Note|The query feed definition must be encapsulated in double quotes. Therefore any other double quotes in its declaration must be escaped}}<br />
<br />
==== Unread articles ====<br />
<br />
To create a feed named {{ic|Unread Articles}} that contains all unread articles, define the following:<br />
<br />
{{hc|~/.config/newsboat/urls|<br />
"query:Unread Articles:unread {{=}} \"yes\""<br />
}}<br />
<br />
==== Amalgamating multiple feeds into one ====<br />
<br />
A good use of query feeds is when you're following a creator whose content is spread across multiple feeds. You can use a query feed to amalgamate all his content into one place.<br />
<br />
{{hc|~/.config/newsboat/urls|<br />
"query:Metafeed:tags # \"metafeed\""<nowiki><br />
https://feed.url/1 metafeed !<br />
https://feed.url/2 metafeed !<br />
https://feed.url/3 metafeed !<br />
</nowiki>}}<br />
<br />
The trick is to assign each individual feed a unique tag - here {{ic|metafeed}} - so that we can match against it in the filter expression. We also make use of [[#Hidden feeds]] - the {{ic|!}} at the end of each feed - so that the individual feeds do not show up in feedlist.<br />
<br />
==== Filtering a specific feed ====<br />
<br />
If a feed contains content you do not want to see, you can filter it by using a query feed.<br />
For example, to monitor updates of the arch kernel, you could use the following:<br />
<br />
{{hc|~/.config/newsboat/urls|<br />
"query:Arch Kernel:(tags # \"archkernel\") and (title {{=}}~ \"linux$\")"<br />
<nowiki>https://archlinux.org/feeds/packages/</nowiki> archkernel !<br />
}}<br />
<br />
=== Ignoring articles ===<br />
<br />
There are two ways to ignore articles, delete them or not show them.<br />
<br />
{{hc|~/.newsboat/config|<br />
# ignore-mode "download" # Default: Delete them.<br />
ignore-mode "display" # Do not show them.<br />
}}<br />
<br />
The filter can be configured like so (here in POSIX extended regular expressions):<br />
<br />
{{hc|~/.newsboat/config|<nowiki><br />
ignore-article "https://feed/url" "content =~ \"tele(phone|communications)\"" <br />
ignore-article "https://feed/url" "title =~ \"text_1|text_2\""<br />
</nowiki>}}<br />
<br />
== Configuration ==<br />
<br />
Several aspects of Newsboat’s behaviour can be configured via a configuration file which is located, by default, in {{ic|~/.newsboat/config}} or {{ic|~/.config/newsboat/config}}. This configuration file contains lines of the form:<br />
<br />
<config-command> <arg1> ...<br />
<br />
=== Color schemes ===<br />
<br />
The package ships with a number of schemes in {{ic|/usr/share/doc/newsboat/contrib/colorschemes/}} which can be loaded with the include command like so:<br />
<br />
include /usr/share/doc/newsboat/contrib/colorschemes/inkpot<br />
<br />
=== Additional options ===<br />
<br />
The configuration file can also contain comments, which start with the {{ic|#}} character and go as far as the end of line. To enter a configuration argument that contains spaces, use quotes {{ic|"}} around the whole argument. It’s even possible to integrate the output of external commands into the configuration. The text between two backticks {{ic|`}} is evaluated as shell command, and its output is put on its place instead. This works like backtick evaluation in Bourne-compatible shells and allows users to use external information from the system within the configuration.<br />
<br />
See [https://gist.github.com/anonymous/42d2f5956e7bc8ee1ebc] and [http://moparx.com/configs/newsbeuter/] for example configurations.<br />
<br />
{{Note|To see a complete list of configuration command, consult {{man|1|newsboat|CONFIGURATION COMMANDS}}.}}<br />
<br />
== Tips and tricks ==<br />
<br />
=== Automatic feed reloads ===<br />
<br />
Newsboat can automatically reload all feeds on startup with the following configuration:<br />
<br />
auto-reload yes<br />
<br />
With this setting, Newsboat also runs periodic auto-reloads – by default, every 60 minutes. The number of minutes between automatic reloads can be configured like so:<br />
<br />
reload-time <desired number of minutes><br />
<br />
Alternatively, use [[cron]] or [[systemd]] to automatically reload feeds. Just add a line in your crontab, or create a systemd service/timer unit combo that issues the following command:<br />
<br />
/usr/bin/newsboat -x reload<br />
<br />
=== Loading of feeds in parallel for faster updates ===<br />
<br />
By default, Newsboat will attempt to update entries in {{ic|~/.newsboat/urls}} in sequence; however, the following setting will update them n at a time, in parallel. Adjust n to your liking.<br />
<br />
reload-threads 100<br />
<br />
=== Pass article URL to external command ===<br />
<br />
A clever little hack allows one to pass the URL of an article to an external command. The idea is to use a macro to set the browser that Newsboat opens the article with to the path of some other command and then change it back afterwards.<br />
<br />
For example, subscribers of a particular youtube channel can open the video with [[mpv]], by doing the following:<br />
<br />
macro y set browser "mpv %u" ; open-in-browser ; set browser "elinks %u"<br />
<br />
{{Note| First press the {{ic|,}} key, followed by the keybind to use the macro. In the example above, type {{ic|,}} + {{ic|y}} }}<br />
<br />
=== Subheadings ===<br />
<br />
There is another little hack that allows the user to add subheadings to sort feeds more effectively. This hack involves adding fake feeds to the {{ic|urls}} file like so:<br />
<br />
---Heading---<br />
<br />
{{Note|the {{ic|---}} characters are optional but having some sort of character identifying the headings is useful for styling.}}<br />
<br />
Then in {{ic|~/.config/newsboat/config}}, add the following two lines:<br />
<br />
highlight feedlist "---.*---" ''COLOR_OF_YOUR_CHOOSING'' default bold<br />
highlight feedlist ".*0/0.." default default invis<br />
<br />
Of course, replace {{ic|''COLOR_OF_YOUR_CHOOSING''}} with a [https://newsboat.org/releases/2.24/docs/newsboat.html#_configuring_colors newsboat supported color].<br />
<br />
This trick can also interact with Tags by replacing {{ic|---Heading---}} with:<br />
<br />
"query:---Heading---:tags # \"Tag\""<br />
<br />
Then tagging all the feeds below the heading with {{ic|Tag}}.<br />
<br />
== Troubleshooting ==<br />
<br />
=== Newsboat will not start ===<br />
<br />
Newsboat cannot start without any configured feeds! To add URLs, see [[#Managing feeds]]. If that is not the problem, check to see if another instance of Newsboat is running. Newsboat issues a lock on its database so that only one instance can access it at a time; thus, attempting to open a second instance will fail.<br />
<br />
== See also ==<br />
<br />
*[https://newsboat.org/ Official web site]<br />
*[https://newsboat.org/releases/2.24/docs/newsboat.html Full documentation]<br />
*[https://sanctum.geek.nz/arabesque/rss-with-newsboat/ Arabesque: RSS with Newsboat]</div>Captaincurriehttps://wiki.archlinux.org/index.php?title=Newsboat&diff=766031Newsboat2023-02-01T13:40:00Z<p>Captaincurrie: /* Basic Examples */ added another example</p>
<hr />
<div>[[Category:News aggregators]]<br />
[[Category:Console applications]]<br />
[[ja:Newsboat]]<br />
{{Related articles start}}<br />
{{Related|Web feed}}<br />
{{Related articles end}}<br />
<br />
[https://newsboat.org/ Newsboat] is an open source news aggregator licensed under the MIT License.<br />
<br />
From {{man|1|newsboat|DESCRIPTION}}:<br />
<br />
:Newsboat is an RSS/Atom feed reader for text terminals. RSS and Atom are a number of widely-used XML formats to transmit, publish and syndicate articles, for example news or blog articles. Newsboat is designed to be used on text terminals on Unix or Unix-like systems such as GNU/Linux, BSD or macOS. <br />
<br />
Newsboat is a [https://groups.google.com/forum/#!topic/newsbeuter/RPtlWX8CPGU fork] of abandoned Newsbeuter.<br />
<br />
== Installation ==<br />
<br />
Install the {{Pkg|newsboat}} package. For the development version, install the {{AUR|newsboat-git}} package.<br />
<br />
== Usage ==<br />
<br />
Newsboat cannot start without any configured feeds. Feeds can be configured in {{ic|~/.newsboat/urls}}. Newsboat can be started from the command line with<br />
<br />
$ newsboat<br />
<br />
Press the {{ic|?}} key to see a list of all keybindings. Keybindings can be rebound, see [[#Configuration]].<br />
<br />
== Managing feeds ==<br />
<br />
Adding, removing, and tagging feeds is done by editing the urls file. By default that is {{ic|~/.newsboat/urls}}.<br />
<br />
{{Tip|In addition to newsboat specific feeds in this section, be sure to see the [[Web feed]] article for additional options.}}<br />
<br />
=== RSS or ATOM sources ===<br />
<br />
To add URLs, open {{ic|~/.newsboat/urls}} with your favorite text editor and add the URLs, one per line:<br />
<br />
<nowiki>http://rss.cnn.com/rss/cnn_topstories.rss</nowiki><br />
<nowiki>http://newsrss.bbc.co.uk/rss/newsonline_world_edition/front_page/rss.xml</nowiki><br />
<br />
To add URLs that have restricted access via username/password, simply provide the username/password in the following way:<br />
<br />
<nowiki>http://username:password@hostname.domain.tld/feed.rss</nowiki><br />
<br />
In order to protect username and password, make sure that {{ic|~/.newsboat/urls}} has the appropriate permissions. Newsboat also makes sure that usernames and passwords within URLs aren’t displayed in its user interface. In case there is a @ in the username, type it as %40 instead so that it can be distinguished from the @ that separates the username/password part from the hostname part.<br />
<br />
To configure local files as feeds, simply prefix the local path with {{ic|file://}} and add it to the {{ic|~/.newsboat/urls}} file:<br />
<br />
file:///var/log/rss_eventlog.xml<br />
<br />
=== HTML as a source ===<br />
<br />
If HTML sources can be converted to RSS via a user supplied script, newboat can both execute this script and consume the output.<br />
<br />
This is accomplished by using the {{ic|filter:}} prefix in the configuration file. For example, write a script that can read HTML from stdin and print out an RSS or Atom feed to stdout. Save that script to {{ic|~/.newsboat/html2rss.sh}} and add the following line to the {{ic|urls}}:<br />
<br />
<nowiki>filter:~/.newsboat/html2rss.sh:https://myurl.com</nowiki><br />
<br />
* For several examples using this strategy, see [https://github.com/graysky2/newsboat_custom_stuff graysky's newsboat repo].<br />
* For more discussion, see [https://github.com/newsboat/newsboat/issues/1157 Possible to config newsboat to look at a web exposed directory and report changes #1157].<br />
<br />
=== Tagging feeds ===<br />
<br />
Every feed can be assigned 0 or more tags. This makes it easy to categorize your feeds as well as the ability to easily apply commands to multiple feeds at once.<br />
<br />
Usually, the {{ic|~/.newsboat/urls}} file contains one RSS feed URL per line. To assign a tag to an RSS feed, simply attach it as a single word, separated by blanks such as space or tab. If the tag needs to contain spaces, use quotes (") around the tag (see example below). An example may look like this:<br />
<br />
<nowiki>http://blog.fefe.de/rss.xml?html interesting conspiracy news "cool stuff"</nowiki><br />
<nowiki>http://rss.orf.at/news.xml news orf</nowiki><br />
<nowiki>http://www.heise.de/newsticker/heise.rdf news interesting</nowiki><br />
<br />
Starting Newsboat with this configuration, one can press {{ic|t}} to select a tag. Upon selecting the tag "news", one will see all three RSS feeds. Pressing {{ic|t}} again and e.g. selecting the "conspiracy" tag, will only show the {{ic|<nowiki>http://blog.fefe.de/rss.xml?html</nowiki>}} RSS feed. Pressing {{ic|Ctrl-T}} clears the current tag,<br />
and again shows all RSS feeds, regardless of their assigned tags.<br />
<br />
{{Note| If the tag name contains spaces, the tag must be bounded by {{ic|"}}}}<br />
<br />
==== Special tags ====<br />
<br />
===== Custom feed names =====<br />
<br />
The name of a feed can be defined with a special tag in your urls file. Simply '''prefix''' the tag name with the {{ic|~}} character and the tag name will become the feed name.<br />
<br />
For example:<br />
<br />
<nowiki>http://rss.cnn.com/rss/cnn_topstories.rss</nowiki> "~CNN Top stories"<br />
<br />
will define the feed with feed-name "CNN Top stories"<br />
<br />
===== Hidden feeds =====<br />
<br />
A feed can be '''hidden''' from the regular list of feeds by '''prefixing''' the tag name with an {{ic|!}}.<br />
<br />
For example:<br />
<br />
<nowiki>http://rss.orf.at/news.xml</nowiki> "!ORF News (hidden)"<br />
<br />
The content of a '''hidden''' feed can only be found through a query feed.<br />
<br />
=== Query feeds ===<br />
<br />
Custom feeds can be created from existing feeds by creating what's called a query feed: A feed generated by matching articles against a query. Query feeds are defined in your {{ic|~/.config/newsboat/urls}} file like a normal feed.<br />
They have the following syntax:<br />
<br />
<nowiki>query:FEEDNAME:FILTER_EXPRESSION [TAG ...]</nowiki><br />
<br />
Like a normal feed, a query feed has a name, {{ic|FEEDNAME}}, which is displayed in the feedlist.<br />
The filter expression language for {{ic|FILTER_EXPRESSION}} is defined in the [https://newsboat.org/releases/2.13/docs/newsboat.html#_filter_language newsboat manual].<br />
Query feeds can be optionally tagged, just like a normal feed. See [[#Tagging feeds]].<br />
<br />
==== Basic Examples ====<br />
<br />
{{hc|~/.config/newsboat/urls|<br />
"query:Example1:age > 1"<br />
"query:Example2:(tags # \"example2\") and (title {{=}}~ \"example2\")"<br />
"query:Example3:(rssurl {{=}}~ \"example3\") or (total_count > 3)"<br />
}}<br />
<br />
The first example defines a feed named {{ic|Example1}} that will contain all articles that are older than a day<br />
<br />
The second example defines a feed named {{ic|Example2}} that will contain all articles whose feed was tagged {{ic|example2}}<br />
'''and''' whose article title matches {{ic|example2}}. Here the {{ic|#}} is the "contains" operator.<br />
<br />
The third example defines a feed named {{ic|Example3}} that will contain all articles whose feed url matches the<br />
regular expression {{ic|example3}} '''or''' all articles that are apart of a feed that contain more than 3 articles.<br />
<br />
{{Note|The query feed definition must be encapsulated in double quotes. Therefore any other double quotes in its declaration must be escaped}}<br />
<br />
==== Unread articles ====<br />
<br />
To create a feed named {{ic|Unread Articles}} that contains all unread articles, define the following:<br />
<br />
{{hc|~/.config/newsboat/urls|<br />
"query:Unread Articles:unread {{=}} \"yes\""<br />
}}<br />
<br />
==== Amalgamating multiple feeds into one ====<br />
<br />
A good use of query feeds is when you're following a creator whose content is spread across multiple feeds. You can use a query feed to amalgamate all his content into one place.<br />
<br />
{{hc|~/.config/newsboat/urls|<br />
"query:Metafeed:tags # \"metafeed\""<nowiki><br />
https://feed.url/1 metafeed !<br />
https://feed.url/2 metafeed !<br />
https://feed.url/3 metafeed !<br />
</nowiki>}}<br />
<br />
The trick is to assign each individual feed a unique tag - here {{ic|metafeed}} - so that we can match against it in the filter expression. We also make use of [[#Hidden feeds]] - the {{ic|!}} at the end of each feed - so that the individual feeds do not show up in feedlist.<br />
<br />
==== Filtering a specific feed ====<br />
<br />
If a feed contains content you do not want to see, you can filter it by using a query feed.<br />
For example, to monitor updates of the arch kernel, you could use the following:<br />
<br />
{{hc|~/.config/newsboat/urls|<br />
"query:Arch Kernel:(tags # \"archkernel\") and (title {{=}}~ \"linux$\")"<br />
<nowiki>https://archlinux.org/feeds/packages/</nowiki> archkernel !<br />
}}<br />
<br />
=== Ignoring articles ===<br />
<br />
There are two ways to ignore articles, delete them or not show them.<br />
<br />
{{hc|~/.newsboat/config|<br />
# ignore-mode "download" # Default: Delete them.<br />
ignore-mode "display" # Do not show them.<br />
}}<br />
<br />
The filter can be configured like so (here in POSIX extended regular expressions):<br />
<br />
{{hc|~/.newsboat/config|<nowiki><br />
ignore-article "https://feed/url" "content =~ \"tele(phone|communications)\"" <br />
ignore-article "https://feed/url" "title =~ \"text_1|text_2\""<br />
</nowiki>}}<br />
<br />
== Configuration ==<br />
<br />
Several aspects of Newsboat’s behaviour can be configured via a configuration file which is located, by default, in {{ic|~/.newsboat/config}} or {{ic|~/.config/newsboat/config}}. This configuration file contains lines of the form:<br />
<br />
<config-command> <arg1> ...<br />
<br />
=== Color schemes ===<br />
<br />
The package ships with a number of schemes in {{ic|/usr/share/doc/newsboat/contrib/colorschemes/}} which can be loaded with the include command like so:<br />
<br />
include /usr/share/doc/newsboat/contrib/colorschemes/inkpot<br />
<br />
=== Additional options ===<br />
<br />
The configuration file can also contain comments, which start with the {{ic|#}} character and go as far as the end of line. To enter a configuration argument that contains spaces, use quotes {{ic|"}} around the whole argument. It’s even possible to integrate the output of external commands into the configuration. The text between two backticks {{ic|`}} is evaluated as shell command, and its output is put on its place instead. This works like backtick evaluation in Bourne-compatible shells and allows users to use external information from the system within the configuration.<br />
<br />
See [https://gist.github.com/anonymous/42d2f5956e7bc8ee1ebc] and [http://moparx.com/configs/newsbeuter/] for example configurations.<br />
<br />
{{Note|To see a complete list of configuration command, consult {{man|1|newsboat|CONFIGURATION COMMANDS}}.}}<br />
<br />
== Tips and tricks ==<br />
<br />
=== Automatic feed reloads ===<br />
<br />
Newsboat can automatically reload all feeds on startup with the following configuration:<br />
<br />
auto-reload yes<br />
<br />
With this setting, Newsboat also runs periodic auto-reloads – by default, every 60 minutes. The number of minutes between automatic reloads can be configured like so:<br />
<br />
reload-time <desired number of minutes><br />
<br />
Alternatively, use [[cron]] or [[systemd]] to automatically reload feeds. Just add a line in your crontab, or create a systemd service/timer unit combo that issues the following command:<br />
<br />
/usr/bin/newsboat -x reload<br />
<br />
=== Loading of feeds in parallel for faster updates ===<br />
<br />
By default, Newsboat will attempt to update entries in {{ic|~/.newsboat/urls}} in sequence; however, the following setting will update them n at a time, in parallel. Adjust n to your liking.<br />
<br />
reload-threads 100<br />
<br />
=== Pass article URL to external command ===<br />
<br />
A clever little hack allows one to pass the URL of an article to an external command. The idea is to use a macro to set the browser that Newsboat opens the article with to the path of some other command and then change it back afterwards.<br />
<br />
For example, subscribers of a particular youtube channel can open the video with [[mpv]], by doing the following:<br />
<br />
macro y set browser "mpv %u" ; open-in-browser ; set browser "elinks %u"<br />
<br />
{{Note| First press the {{ic|,}} key, followed by the keybind to use the macro. In the example above, type {{ic|,}} + {{ic|y}} }}<br />
<br />
=== Subheadings ===<br />
<br />
There is another little hack that allows the user to add subheadings to sort feeds more effectively. This hack involves adding fake feeds to the {{ic|urls}} file like so:<br />
<br />
---Heading---<br />
<br />
{{Note|the {{ic|---}} characters are optional but having some sort of character identifying the headings is useful for styling.}}<br />
<br />
Then in {{ic|~/.config/newsboat/config}}, add the following two lines:<br />
<br />
highlight feedlist "---.*---" ''COLOR_OF_YOUR_CHOOSING'' default bold<br />
highlight feedlist ".*0/0.." default default invis<br />
<br />
Of course, replace {{ic|''COLOR_OF_YOUR_CHOOSING''}} with a [https://newsboat.org/releases/2.24/docs/newsboat.html#_configuring_colors newsboat supported color].<br />
<br />
This trick can also interact with Tags by replacing {{ic|---Heading---}} with:<br />
<br />
"query:---Heading---:tags # \"Tag\""<br />
<br />
Then tagging all the feeds below the heading with {{ic|Tag}}.<br />
<br />
== Troubleshooting ==<br />
<br />
=== Newsboat will not start ===<br />
<br />
Newsboat cannot start without any configured feeds! To add URLs, see [[#Managing feeds]]. If that is not the problem, check to see if another instance of Newsboat is running. Newsboat issues a lock on its database so that only one instance can access it at a time; thus, attempting to open a second instance will fail.<br />
<br />
== See also ==<br />
<br />
*[https://newsboat.org/ Official web site]<br />
*[https://newsboat.org/releases/2.24/docs/newsboat.html Full documentation]<br />
*[https://sanctum.geek.nz/arabesque/rss-with-newsboat/ Arabesque: RSS with Newsboat]</div>Captaincurriehttps://wiki.archlinux.org/index.php?title=Newsboat&diff=766030Newsboat2023-02-01T13:35:30Z<p>Captaincurrie: /* Basic Examples */ formatting</p>
<hr />
<div>[[Category:News aggregators]]<br />
[[Category:Console applications]]<br />
[[ja:Newsboat]]<br />
{{Related articles start}}<br />
{{Related|Web feed}}<br />
{{Related articles end}}<br />
<br />
[https://newsboat.org/ Newsboat] is an open source news aggregator licensed under the MIT License.<br />
<br />
From {{man|1|newsboat|DESCRIPTION}}:<br />
<br />
:Newsboat is an RSS/Atom feed reader for text terminals. RSS and Atom are a number of widely-used XML formats to transmit, publish and syndicate articles, for example news or blog articles. Newsboat is designed to be used on text terminals on Unix or Unix-like systems such as GNU/Linux, BSD or macOS. <br />
<br />
Newsboat is a [https://groups.google.com/forum/#!topic/newsbeuter/RPtlWX8CPGU fork] of abandoned Newsbeuter.<br />
<br />
== Installation ==<br />
<br />
Install the {{Pkg|newsboat}} package. For the development version, install the {{AUR|newsboat-git}} package.<br />
<br />
== Usage ==<br />
<br />
Newsboat cannot start without any configured feeds. Feeds can be configured in {{ic|~/.newsboat/urls}}. Newsboat can be started from the command line with<br />
<br />
$ newsboat<br />
<br />
Press the {{ic|?}} key to see a list of all keybindings. Keybindings can be rebound, see [[#Configuration]].<br />
<br />
== Managing feeds ==<br />
<br />
Adding, removing, and tagging feeds is done by editing the urls file. By default that is {{ic|~/.newsboat/urls}}.<br />
<br />
{{Tip|In addition to newsboat specific feeds in this section, be sure to see the [[Web feed]] article for additional options.}}<br />
<br />
=== RSS or ATOM sources ===<br />
<br />
To add URLs, open {{ic|~/.newsboat/urls}} with your favorite text editor and add the URLs, one per line:<br />
<br />
<nowiki>http://rss.cnn.com/rss/cnn_topstories.rss</nowiki><br />
<nowiki>http://newsrss.bbc.co.uk/rss/newsonline_world_edition/front_page/rss.xml</nowiki><br />
<br />
To add URLs that have restricted access via username/password, simply provide the username/password in the following way:<br />
<br />
<nowiki>http://username:password@hostname.domain.tld/feed.rss</nowiki><br />
<br />
In order to protect username and password, make sure that {{ic|~/.newsboat/urls}} has the appropriate permissions. Newsboat also makes sure that usernames and passwords within URLs aren’t displayed in its user interface. In case there is a @ in the username, type it as %40 instead so that it can be distinguished from the @ that separates the username/password part from the hostname part.<br />
<br />
To configure local files as feeds, simply prefix the local path with {{ic|file://}} and add it to the {{ic|~/.newsboat/urls}} file:<br />
<br />
file:///var/log/rss_eventlog.xml<br />
<br />
=== HTML as a source ===<br />
<br />
If HTML sources can be converted to RSS via a user supplied script, newboat can both execute this script and consume the output.<br />
<br />
This is accomplished by using the {{ic|filter:}} prefix in the configuration file. For example, write a script that can read HTML from stdin and print out an RSS or Atom feed to stdout. Save that script to {{ic|~/.newsboat/html2rss.sh}} and add the following line to the {{ic|urls}}:<br />
<br />
<nowiki>filter:~/.newsboat/html2rss.sh:https://myurl.com</nowiki><br />
<br />
* For several examples using this strategy, see [https://github.com/graysky2/newsboat_custom_stuff graysky's newsboat repo].<br />
* For more discussion, see [https://github.com/newsboat/newsboat/issues/1157 Possible to config newsboat to look at a web exposed directory and report changes #1157].<br />
<br />
=== Tagging feeds ===<br />
<br />
Every feed can be assigned 0 or more tags. This makes it easy to categorize your feeds as well as the ability to easily apply commands to multiple feeds at once.<br />
<br />
Usually, the {{ic|~/.newsboat/urls}} file contains one RSS feed URL per line. To assign a tag to an RSS feed, simply attach it as a single word, separated by blanks such as space or tab. If the tag needs to contain spaces, use quotes (") around the tag (see example below). An example may look like this:<br />
<br />
<nowiki>http://blog.fefe.de/rss.xml?html interesting conspiracy news "cool stuff"</nowiki><br />
<nowiki>http://rss.orf.at/news.xml news orf</nowiki><br />
<nowiki>http://www.heise.de/newsticker/heise.rdf news interesting</nowiki><br />
<br />
Starting Newsboat with this configuration, one can press {{ic|t}} to select a tag. Upon selecting the tag "news", one will see all three RSS feeds. Pressing {{ic|t}} again and e.g. selecting the "conspiracy" tag, will only show the {{ic|<nowiki>http://blog.fefe.de/rss.xml?html</nowiki>}} RSS feed. Pressing {{ic|Ctrl-T}} clears the current tag,<br />
and again shows all RSS feeds, regardless of their assigned tags.<br />
<br />
{{Note| If the tag name contains spaces, the tag must be bounded by {{ic|"}}}}<br />
<br />
==== Special tags ====<br />
<br />
===== Custom feed names =====<br />
<br />
The name of a feed can be defined with a special tag in your urls file. Simply '''prefix''' the tag name with the {{ic|~}} character and the tag name will become the feed name.<br />
<br />
For example:<br />
<br />
<nowiki>http://rss.cnn.com/rss/cnn_topstories.rss</nowiki> "~CNN Top stories"<br />
<br />
will define the feed with feed-name "CNN Top stories"<br />
<br />
===== Hidden feeds =====<br />
<br />
A feed can be '''hidden''' from the regular list of feeds by '''prefixing''' the tag name with an {{ic|!}}.<br />
<br />
For example:<br />
<br />
<nowiki>http://rss.orf.at/news.xml</nowiki> "!ORF News (hidden)"<br />
<br />
The content of a '''hidden''' feed can only be found through a query feed.<br />
<br />
=== Query feeds ===<br />
<br />
Custom feeds can be created from existing feeds by creating what's called a query feed: A feed generated by matching articles against a query. Query feeds are defined in your {{ic|~/.config/newsboat/urls}} file like a normal feed.<br />
They have the following syntax:<br />
<br />
<nowiki>query:FEEDNAME:FILTER_EXPRESSION [TAG ...]</nowiki><br />
<br />
Like a normal feed, a query feed has a name, {{ic|FEEDNAME}}, which is displayed in the feedlist.<br />
The filter expression language for {{ic|FILTER_EXPRESSION}} is defined in the [https://newsboat.org/releases/2.13/docs/newsboat.html#_filter_language newsboat manual].<br />
Query feeds can be optionally tagged, just like a normal feed. See [[#Tagging feeds]].<br />
<br />
==== Basic Examples ====<br />
<br />
{{hc|~/.config/newsboat/urls|<br />
"query:Example1:(tags # \"example1\") and (title {{=}}~ \"example1\")"<br />
"query:Example2:(rssurl {{=}}~ \"example2\") or (total_count > 2)"<br />
}}<br />
<br />
The first example defines a feed named {{ic|Example1}} that will contain all articles whose feed was tagged {{ic|example1}}<br />
'''and''' whose article title matches {{ic|example1}}. Here the {{ic|#}} is the "contains" operator.<br />
<br />
The second example defines a feed named {{ic|Example2}} that will contain all articles whose feed url matches the<br />
regular expression {{ic|example2}} '''or''' all articles that are apart of a feed that contain more than 2 articles.<br />
<br />
{{Note|The query feed definition must be encapsulated in double quotes. Therefore any other double quotes in its declaration must be escaped}}<br />
<br />
==== Unread articles ====<br />
<br />
To create a feed named {{ic|Unread Articles}} that contains all unread articles, define the following:<br />
<br />
{{hc|~/.config/newsboat/urls|<br />
"query:Unread Articles:unread {{=}} \"yes\""<br />
}}<br />
<br />
==== Amalgamating multiple feeds into one ====<br />
<br />
A good use of query feeds is when you're following a creator whose content is spread across multiple feeds. You can use a query feed to amalgamate all his content into one place.<br />
<br />
{{hc|~/.config/newsboat/urls|<br />
"query:Metafeed:tags # \"metafeed\""<nowiki><br />
https://feed.url/1 metafeed !<br />
https://feed.url/2 metafeed !<br />
https://feed.url/3 metafeed !<br />
</nowiki>}}<br />
<br />
The trick is to assign each individual feed a unique tag - here {{ic|metafeed}} - so that we can match against it in the filter expression. We also make use of [[#Hidden feeds]] - the {{ic|!}} at the end of each feed - so that the individual feeds do not show up in feedlist.<br />
<br />
==== Filtering a specific feed ====<br />
<br />
If a feed contains content you do not want to see, you can filter it by using a query feed.<br />
For example, to monitor updates of the arch kernel, you could use the following:<br />
<br />
{{hc|~/.config/newsboat/urls|<br />
"query:Arch Kernel:(tags # \"archkernel\") and (title {{=}}~ \"linux$\")"<br />
<nowiki>https://archlinux.org/feeds/packages/</nowiki> archkernel !<br />
}}<br />
<br />
=== Ignoring articles ===<br />
<br />
There are two ways to ignore articles, delete them or not show them.<br />
<br />
{{hc|~/.newsboat/config|<br />
# ignore-mode "download" # Default: Delete them.<br />
ignore-mode "display" # Do not show them.<br />
}}<br />
<br />
The filter can be configured like so (here in POSIX extended regular expressions):<br />
<br />
{{hc|~/.newsboat/config|<nowiki><br />
ignore-article "https://feed/url" "content =~ \"tele(phone|communications)\"" <br />
ignore-article "https://feed/url" "title =~ \"text_1|text_2\""<br />
</nowiki>}}<br />
<br />
== Configuration ==<br />
<br />
Several aspects of Newsboat’s behaviour can be configured via a configuration file which is located, by default, in {{ic|~/.newsboat/config}} or {{ic|~/.config/newsboat/config}}. This configuration file contains lines of the form:<br />
<br />
<config-command> <arg1> ...<br />
<br />
=== Color schemes ===<br />
<br />
The package ships with a number of schemes in {{ic|/usr/share/doc/newsboat/contrib/colorschemes/}} which can be loaded with the include command like so:<br />
<br />
include /usr/share/doc/newsboat/contrib/colorschemes/inkpot<br />
<br />
=== Additional options ===<br />
<br />
The configuration file can also contain comments, which start with the {{ic|#}} character and go as far as the end of line. To enter a configuration argument that contains spaces, use quotes {{ic|"}} around the whole argument. It’s even possible to integrate the output of external commands into the configuration. The text between two backticks {{ic|`}} is evaluated as shell command, and its output is put on its place instead. This works like backtick evaluation in Bourne-compatible shells and allows users to use external information from the system within the configuration.<br />
<br />
See [https://gist.github.com/anonymous/42d2f5956e7bc8ee1ebc] and [http://moparx.com/configs/newsbeuter/] for example configurations.<br />
<br />
{{Note|To see a complete list of configuration command, consult {{man|1|newsboat|CONFIGURATION COMMANDS}}.}}<br />
<br />
== Tips and tricks ==<br />
<br />
=== Automatic feed reloads ===<br />
<br />
Newsboat can automatically reload all feeds on startup with the following configuration:<br />
<br />
auto-reload yes<br />
<br />
With this setting, Newsboat also runs periodic auto-reloads – by default, every 60 minutes. The number of minutes between automatic reloads can be configured like so:<br />
<br />
reload-time <desired number of minutes><br />
<br />
Alternatively, use [[cron]] or [[systemd]] to automatically reload feeds. Just add a line in your crontab, or create a systemd service/timer unit combo that issues the following command:<br />
<br />
/usr/bin/newsboat -x reload<br />
<br />
=== Loading of feeds in parallel for faster updates ===<br />
<br />
By default, Newsboat will attempt to update entries in {{ic|~/.newsboat/urls}} in sequence; however, the following setting will update them n at a time, in parallel. Adjust n to your liking.<br />
<br />
reload-threads 100<br />
<br />
=== Pass article URL to external command ===<br />
<br />
A clever little hack allows one to pass the URL of an article to an external command. The idea is to use a macro to set the browser that Newsboat opens the article with to the path of some other command and then change it back afterwards.<br />
<br />
For example, subscribers of a particular youtube channel can open the video with [[mpv]], by doing the following:<br />
<br />
macro y set browser "mpv %u" ; open-in-browser ; set browser "elinks %u"<br />
<br />
{{Note| First press the {{ic|,}} key, followed by the keybind to use the macro. In the example above, type {{ic|,}} + {{ic|y}} }}<br />
<br />
=== Subheadings ===<br />
<br />
There is another little hack that allows the user to add subheadings to sort feeds more effectively. This hack involves adding fake feeds to the {{ic|urls}} file like so:<br />
<br />
---Heading---<br />
<br />
{{Note|the {{ic|---}} characters are optional but having some sort of character identifying the headings is useful for styling.}}<br />
<br />
Then in {{ic|~/.config/newsboat/config}}, add the following two lines:<br />
<br />
highlight feedlist "---.*---" ''COLOR_OF_YOUR_CHOOSING'' default bold<br />
highlight feedlist ".*0/0.." default default invis<br />
<br />
Of course, replace {{ic|''COLOR_OF_YOUR_CHOOSING''}} with a [https://newsboat.org/releases/2.24/docs/newsboat.html#_configuring_colors newsboat supported color].<br />
<br />
This trick can also interact with Tags by replacing {{ic|---Heading---}} with:<br />
<br />
"query:---Heading---:tags # \"Tag\""<br />
<br />
Then tagging all the feeds below the heading with {{ic|Tag}}.<br />
<br />
== Troubleshooting ==<br />
<br />
=== Newsboat will not start ===<br />
<br />
Newsboat cannot start without any configured feeds! To add URLs, see [[#Managing feeds]]. If that is not the problem, check to see if another instance of Newsboat is running. Newsboat issues a lock on its database so that only one instance can access it at a time; thus, attempting to open a second instance will fail.<br />
<br />
== See also ==<br />
<br />
*[https://newsboat.org/ Official web site]<br />
*[https://newsboat.org/releases/2.24/docs/newsboat.html Full documentation]<br />
*[https://sanctum.geek.nz/arabesque/rss-with-newsboat/ Arabesque: RSS with Newsboat]</div>Captaincurriehttps://wiki.archlinux.org/index.php?title=Newsboat&diff=766029Newsboat2023-02-01T13:35:11Z<p>Captaincurrie: /* Basic Examples */ Reworked section</p>
<hr />
<div>[[Category:News aggregators]]<br />
[[Category:Console applications]]<br />
[[ja:Newsboat]]<br />
{{Related articles start}}<br />
{{Related|Web feed}}<br />
{{Related articles end}}<br />
<br />
[https://newsboat.org/ Newsboat] is an open source news aggregator licensed under the MIT License.<br />
<br />
From {{man|1|newsboat|DESCRIPTION}}:<br />
<br />
:Newsboat is an RSS/Atom feed reader for text terminals. RSS and Atom are a number of widely-used XML formats to transmit, publish and syndicate articles, for example news or blog articles. Newsboat is designed to be used on text terminals on Unix or Unix-like systems such as GNU/Linux, BSD or macOS. <br />
<br />
Newsboat is a [https://groups.google.com/forum/#!topic/newsbeuter/RPtlWX8CPGU fork] of abandoned Newsbeuter.<br />
<br />
== Installation ==<br />
<br />
Install the {{Pkg|newsboat}} package. For the development version, install the {{AUR|newsboat-git}} package.<br />
<br />
== Usage ==<br />
<br />
Newsboat cannot start without any configured feeds. Feeds can be configured in {{ic|~/.newsboat/urls}}. Newsboat can be started from the command line with<br />
<br />
$ newsboat<br />
<br />
Press the {{ic|?}} key to see a list of all keybindings. Keybindings can be rebound, see [[#Configuration]].<br />
<br />
== Managing feeds ==<br />
<br />
Adding, removing, and tagging feeds is done by editing the urls file. By default that is {{ic|~/.newsboat/urls}}.<br />
<br />
{{Tip|In addition to newsboat specific feeds in this section, be sure to see the [[Web feed]] article for additional options.}}<br />
<br />
=== RSS or ATOM sources ===<br />
<br />
To add URLs, open {{ic|~/.newsboat/urls}} with your favorite text editor and add the URLs, one per line:<br />
<br />
<nowiki>http://rss.cnn.com/rss/cnn_topstories.rss</nowiki><br />
<nowiki>http://newsrss.bbc.co.uk/rss/newsonline_world_edition/front_page/rss.xml</nowiki><br />
<br />
To add URLs that have restricted access via username/password, simply provide the username/password in the following way:<br />
<br />
<nowiki>http://username:password@hostname.domain.tld/feed.rss</nowiki><br />
<br />
In order to protect username and password, make sure that {{ic|~/.newsboat/urls}} has the appropriate permissions. Newsboat also makes sure that usernames and passwords within URLs aren’t displayed in its user interface. In case there is a @ in the username, type it as %40 instead so that it can be distinguished from the @ that separates the username/password part from the hostname part.<br />
<br />
To configure local files as feeds, simply prefix the local path with {{ic|file://}} and add it to the {{ic|~/.newsboat/urls}} file:<br />
<br />
file:///var/log/rss_eventlog.xml<br />
<br />
=== HTML as a source ===<br />
<br />
If HTML sources can be converted to RSS via a user supplied script, newboat can both execute this script and consume the output.<br />
<br />
This is accomplished by using the {{ic|filter:}} prefix in the configuration file. For example, write a script that can read HTML from stdin and print out an RSS or Atom feed to stdout. Save that script to {{ic|~/.newsboat/html2rss.sh}} and add the following line to the {{ic|urls}}:<br />
<br />
<nowiki>filter:~/.newsboat/html2rss.sh:https://myurl.com</nowiki><br />
<br />
* For several examples using this strategy, see [https://github.com/graysky2/newsboat_custom_stuff graysky's newsboat repo].<br />
* For more discussion, see [https://github.com/newsboat/newsboat/issues/1157 Possible to config newsboat to look at a web exposed directory and report changes #1157].<br />
<br />
=== Tagging feeds ===<br />
<br />
Every feed can be assigned 0 or more tags. This makes it easy to categorize your feeds as well as the ability to easily apply commands to multiple feeds at once.<br />
<br />
Usually, the {{ic|~/.newsboat/urls}} file contains one RSS feed URL per line. To assign a tag to an RSS feed, simply attach it as a single word, separated by blanks such as space or tab. If the tag needs to contain spaces, use quotes (") around the tag (see example below). An example may look like this:<br />
<br />
<nowiki>http://blog.fefe.de/rss.xml?html interesting conspiracy news "cool stuff"</nowiki><br />
<nowiki>http://rss.orf.at/news.xml news orf</nowiki><br />
<nowiki>http://www.heise.de/newsticker/heise.rdf news interesting</nowiki><br />
<br />
Starting Newsboat with this configuration, one can press {{ic|t}} to select a tag. Upon selecting the tag "news", one will see all three RSS feeds. Pressing {{ic|t}} again and e.g. selecting the "conspiracy" tag, will only show the {{ic|<nowiki>http://blog.fefe.de/rss.xml?html</nowiki>}} RSS feed. Pressing {{ic|Ctrl-T}} clears the current tag,<br />
and again shows all RSS feeds, regardless of their assigned tags.<br />
<br />
{{Note| If the tag name contains spaces, the tag must be bounded by {{ic|"}}}}<br />
<br />
==== Special tags ====<br />
<br />
===== Custom feed names =====<br />
<br />
The name of a feed can be defined with a special tag in your urls file. Simply '''prefix''' the tag name with the {{ic|~}} character and the tag name will become the feed name.<br />
<br />
For example:<br />
<br />
<nowiki>http://rss.cnn.com/rss/cnn_topstories.rss</nowiki> "~CNN Top stories"<br />
<br />
will define the feed with feed-name "CNN Top stories"<br />
<br />
===== Hidden feeds =====<br />
<br />
A feed can be '''hidden''' from the regular list of feeds by '''prefixing''' the tag name with an {{ic|!}}.<br />
<br />
For example:<br />
<br />
<nowiki>http://rss.orf.at/news.xml</nowiki> "!ORF News (hidden)"<br />
<br />
The content of a '''hidden''' feed can only be found through a query feed.<br />
<br />
=== Query feeds ===<br />
<br />
Custom feeds can be created from existing feeds by creating what's called a query feed: A feed generated by matching articles against a query. Query feeds are defined in your {{ic|~/.config/newsboat/urls}} file like a normal feed.<br />
They have the following syntax:<br />
<br />
<nowiki>query:FEEDNAME:FILTER_EXPRESSION [TAG ...]</nowiki><br />
<br />
Like a normal feed, a query feed has a name, {{ic|FEEDNAME}}, which is displayed in the feedlist.<br />
The filter expression language for {{ic|FILTER_EXPRESSION}} is defined in the [https://newsboat.org/releases/2.13/docs/newsboat.html#_filter_language newsboat manual].<br />
Query feeds can be optionally tagged, just like a normal feed. See [[#Tagging feeds]].<br />
<br />
==== Basic Examples ====<br />
<br />
{{hc|~/.config/newsboat/urls|<br />
<br />
"query:Example1:(tags # \"example1\") and (title {{=}}~ \"example1\")"<br />
"query:Example2:(rssurl {{=}}~ \"example2\") or (total_count > 2)"<br />
}}<br />
<br />
The first example defines a feed named {{ic|Example1}} that will contain all articles whose feed was tagged {{ic|example1}}<br />
'''and''' whose article title matches {{ic|example1}}. Here the {{ic|#}} is the "contains" operator.<br />
<br />
The second example defines a feed named {{ic|Example2}} that will contain all articles whose feed url matches the<br />
regular expression {{ic|example2}} '''or''' all articles that are apart of a feed that contain more than 2 articles.<br />
<br />
{{Note|The query feed definition must be encapsulated in double quotes. Therefore any other double quotes in its declaration must be escaped}}<br />
<br />
==== Unread articles ====<br />
<br />
To create a feed named {{ic|Unread Articles}} that contains all unread articles, define the following:<br />
<br />
{{hc|~/.config/newsboat/urls|<br />
"query:Unread Articles:unread {{=}} \"yes\""<br />
}}<br />
<br />
==== Amalgamating multiple feeds into one ====<br />
<br />
A good use of query feeds is when you're following a creator whose content is spread across multiple feeds. You can use a query feed to amalgamate all his content into one place.<br />
<br />
{{hc|~/.config/newsboat/urls|<br />
"query:Metafeed:tags # \"metafeed\""<nowiki><br />
https://feed.url/1 metafeed !<br />
https://feed.url/2 metafeed !<br />
https://feed.url/3 metafeed !<br />
</nowiki>}}<br />
<br />
The trick is to assign each individual feed a unique tag - here {{ic|metafeed}} - so that we can match against it in the filter expression. We also make use of [[#Hidden feeds]] - the {{ic|!}} at the end of each feed - so that the individual feeds do not show up in feedlist.<br />
<br />
==== Filtering a specific feed ====<br />
<br />
If a feed contains content you do not want to see, you can filter it by using a query feed.<br />
For example, to monitor updates of the arch kernel, you could use the following:<br />
<br />
{{hc|~/.config/newsboat/urls|<br />
"query:Arch Kernel:(tags # \"archkernel\") and (title {{=}}~ \"linux$\")"<br />
<nowiki>https://archlinux.org/feeds/packages/</nowiki> archkernel !<br />
}}<br />
<br />
=== Ignoring articles ===<br />
<br />
There are two ways to ignore articles, delete them or not show them.<br />
<br />
{{hc|~/.newsboat/config|<br />
# ignore-mode "download" # Default: Delete them.<br />
ignore-mode "display" # Do not show them.<br />
}}<br />
<br />
The filter can be configured like so (here in POSIX extended regular expressions):<br />
<br />
{{hc|~/.newsboat/config|<nowiki><br />
ignore-article "https://feed/url" "content =~ \"tele(phone|communications)\"" <br />
ignore-article "https://feed/url" "title =~ \"text_1|text_2\""<br />
</nowiki>}}<br />
<br />
== Configuration ==<br />
<br />
Several aspects of Newsboat’s behaviour can be configured via a configuration file which is located, by default, in {{ic|~/.newsboat/config}} or {{ic|~/.config/newsboat/config}}. This configuration file contains lines of the form:<br />
<br />
<config-command> <arg1> ...<br />
<br />
=== Color schemes ===<br />
<br />
The package ships with a number of schemes in {{ic|/usr/share/doc/newsboat/contrib/colorschemes/}} which can be loaded with the include command like so:<br />
<br />
include /usr/share/doc/newsboat/contrib/colorschemes/inkpot<br />
<br />
=== Additional options ===<br />
<br />
The configuration file can also contain comments, which start with the {{ic|#}} character and go as far as the end of line. To enter a configuration argument that contains spaces, use quotes {{ic|"}} around the whole argument. It’s even possible to integrate the output of external commands into the configuration. The text between two backticks {{ic|`}} is evaluated as shell command, and its output is put on its place instead. This works like backtick evaluation in Bourne-compatible shells and allows users to use external information from the system within the configuration.<br />
<br />
See [https://gist.github.com/anonymous/42d2f5956e7bc8ee1ebc] and [http://moparx.com/configs/newsbeuter/] for example configurations.<br />
<br />
{{Note|To see a complete list of configuration command, consult {{man|1|newsboat|CONFIGURATION COMMANDS}}.}}<br />
<br />
== Tips and tricks ==<br />
<br />
=== Automatic feed reloads ===<br />
<br />
Newsboat can automatically reload all feeds on startup with the following configuration:<br />
<br />
auto-reload yes<br />
<br />
With this setting, Newsboat also runs periodic auto-reloads – by default, every 60 minutes. The number of minutes between automatic reloads can be configured like so:<br />
<br />
reload-time <desired number of minutes><br />
<br />
Alternatively, use [[cron]] or [[systemd]] to automatically reload feeds. Just add a line in your crontab, or create a systemd service/timer unit combo that issues the following command:<br />
<br />
/usr/bin/newsboat -x reload<br />
<br />
=== Loading of feeds in parallel for faster updates ===<br />
<br />
By default, Newsboat will attempt to update entries in {{ic|~/.newsboat/urls}} in sequence; however, the following setting will update them n at a time, in parallel. Adjust n to your liking.<br />
<br />
reload-threads 100<br />
<br />
=== Pass article URL to external command ===<br />
<br />
A clever little hack allows one to pass the URL of an article to an external command. The idea is to use a macro to set the browser that Newsboat opens the article with to the path of some other command and then change it back afterwards.<br />
<br />
For example, subscribers of a particular youtube channel can open the video with [[mpv]], by doing the following:<br />
<br />
macro y set browser "mpv %u" ; open-in-browser ; set browser "elinks %u"<br />
<br />
{{Note| First press the {{ic|,}} key, followed by the keybind to use the macro. In the example above, type {{ic|,}} + {{ic|y}} }}<br />
<br />
=== Subheadings ===<br />
<br />
There is another little hack that allows the user to add subheadings to sort feeds more effectively. This hack involves adding fake feeds to the {{ic|urls}} file like so:<br />
<br />
---Heading---<br />
<br />
{{Note|the {{ic|---}} characters are optional but having some sort of character identifying the headings is useful for styling.}}<br />
<br />
Then in {{ic|~/.config/newsboat/config}}, add the following two lines:<br />
<br />
highlight feedlist "---.*---" ''COLOR_OF_YOUR_CHOOSING'' default bold<br />
highlight feedlist ".*0/0.." default default invis<br />
<br />
Of course, replace {{ic|''COLOR_OF_YOUR_CHOOSING''}} with a [https://newsboat.org/releases/2.24/docs/newsboat.html#_configuring_colors newsboat supported color].<br />
<br />
This trick can also interact with Tags by replacing {{ic|---Heading---}} with:<br />
<br />
"query:---Heading---:tags # \"Tag\""<br />
<br />
Then tagging all the feeds below the heading with {{ic|Tag}}.<br />
<br />
== Troubleshooting ==<br />
<br />
=== Newsboat will not start ===<br />
<br />
Newsboat cannot start without any configured feeds! To add URLs, see [[#Managing feeds]]. If that is not the problem, check to see if another instance of Newsboat is running. Newsboat issues a lock on its database so that only one instance can access it at a time; thus, attempting to open a second instance will fail.<br />
<br />
== See also ==<br />
<br />
*[https://newsboat.org/ Official web site]<br />
*[https://newsboat.org/releases/2.24/docs/newsboat.html Full documentation]<br />
*[https://sanctum.geek.nz/arabesque/rss-with-newsboat/ Arabesque: RSS with Newsboat]</div>Captaincurriehttps://wiki.archlinux.org/index.php?title=Newsboat&diff=766027Newsboat2023-02-01T13:22:41Z<p>Captaincurrie: /* Query feeds */ added link to another section</p>
<hr />
<div>[[Category:News aggregators]]<br />
[[Category:Console applications]]<br />
[[ja:Newsboat]]<br />
{{Related articles start}}<br />
{{Related|Web feed}}<br />
{{Related articles end}}<br />
<br />
[https://newsboat.org/ Newsboat] is an open source news aggregator licensed under the MIT License.<br />
<br />
From {{man|1|newsboat|DESCRIPTION}}:<br />
<br />
:Newsboat is an RSS/Atom feed reader for text terminals. RSS and Atom are a number of widely-used XML formats to transmit, publish and syndicate articles, for example news or blog articles. Newsboat is designed to be used on text terminals on Unix or Unix-like systems such as GNU/Linux, BSD or macOS. <br />
<br />
Newsboat is a [https://groups.google.com/forum/#!topic/newsbeuter/RPtlWX8CPGU fork] of abandoned Newsbeuter.<br />
<br />
== Installation ==<br />
<br />
Install the {{Pkg|newsboat}} package. For the development version, install the {{AUR|newsboat-git}} package.<br />
<br />
== Usage ==<br />
<br />
Newsboat cannot start without any configured feeds. Feeds can be configured in {{ic|~/.newsboat/urls}}. Newsboat can be started from the command line with<br />
<br />
$ newsboat<br />
<br />
Press the {{ic|?}} key to see a list of all keybindings. Keybindings can be rebound, see [[#Configuration]].<br />
<br />
== Managing feeds ==<br />
<br />
Adding, removing, and tagging feeds is done by editing the urls file. By default that is {{ic|~/.newsboat/urls}}.<br />
<br />
{{Tip|In addition to newsboat specific feeds in this section, be sure to see the [[Web feed]] article for additional options.}}<br />
<br />
=== RSS or ATOM sources ===<br />
<br />
To add URLs, open {{ic|~/.newsboat/urls}} with your favorite text editor and add the URLs, one per line:<br />
<br />
<nowiki>http://rss.cnn.com/rss/cnn_topstories.rss</nowiki><br />
<nowiki>http://newsrss.bbc.co.uk/rss/newsonline_world_edition/front_page/rss.xml</nowiki><br />
<br />
To add URLs that have restricted access via username/password, simply provide the username/password in the following way:<br />
<br />
<nowiki>http://username:password@hostname.domain.tld/feed.rss</nowiki><br />
<br />
In order to protect username and password, make sure that {{ic|~/.newsboat/urls}} has the appropriate permissions. Newsboat also makes sure that usernames and passwords within URLs aren’t displayed in its user interface. In case there is a @ in the username, type it as %40 instead so that it can be distinguished from the @ that separates the username/password part from the hostname part.<br />
<br />
To configure local files as feeds, simply prefix the local path with {{ic|file://}} and add it to the {{ic|~/.newsboat/urls}} file:<br />
<br />
file:///var/log/rss_eventlog.xml<br />
<br />
=== HTML as a source ===<br />
<br />
If HTML sources can be converted to RSS via a user supplied script, newboat can both execute this script and consume the output.<br />
<br />
This is accomplished by using the {{ic|filter:}} prefix in the configuration file. For example, write a script that can read HTML from stdin and print out an RSS or Atom feed to stdout. Save that script to {{ic|~/.newsboat/html2rss.sh}} and add the following line to the {{ic|urls}}:<br />
<br />
<nowiki>filter:~/.newsboat/html2rss.sh:https://myurl.com</nowiki><br />
<br />
* For several examples using this strategy, see [https://github.com/graysky2/newsboat_custom_stuff graysky's newsboat repo].<br />
* For more discussion, see [https://github.com/newsboat/newsboat/issues/1157 Possible to config newsboat to look at a web exposed directory and report changes #1157].<br />
<br />
=== Tagging feeds ===<br />
<br />
Every feed can be assigned 0 or more tags. This makes it easy to categorize your feeds as well as the ability to easily apply commands to multiple feeds at once.<br />
<br />
Usually, the {{ic|~/.newsboat/urls}} file contains one RSS feed URL per line. To assign a tag to an RSS feed, simply attach it as a single word, separated by blanks such as space or tab. If the tag needs to contain spaces, use quotes (") around the tag (see example below). An example may look like this:<br />
<br />
<nowiki>http://blog.fefe.de/rss.xml?html interesting conspiracy news "cool stuff"</nowiki><br />
<nowiki>http://rss.orf.at/news.xml news orf</nowiki><br />
<nowiki>http://www.heise.de/newsticker/heise.rdf news interesting</nowiki><br />
<br />
Starting Newsboat with this configuration, one can press {{ic|t}} to select a tag. Upon selecting the tag "news", one will see all three RSS feeds. Pressing {{ic|t}} again and e.g. selecting the "conspiracy" tag, will only show the {{ic|<nowiki>http://blog.fefe.de/rss.xml?html</nowiki>}} RSS feed. Pressing {{ic|Ctrl-T}} clears the current tag,<br />
and again shows all RSS feeds, regardless of their assigned tags.<br />
<br />
{{Note| If the tag name contains spaces, the tag must be bounded by {{ic|"}}}}<br />
<br />
==== Special tags ====<br />
<br />
===== Custom feed names =====<br />
<br />
The name of a feed can be defined with a special tag in your urls file. Simply '''prefix''' the tag name with the {{ic|~}} character and the tag name will become the feed name.<br />
<br />
For example:<br />
<br />
<nowiki>http://rss.cnn.com/rss/cnn_topstories.rss</nowiki> "~CNN Top stories"<br />
<br />
will define the feed with feed-name "CNN Top stories"<br />
<br />
===== Hidden feeds =====<br />
<br />
A feed can be '''hidden''' from the regular list of feeds by '''prefixing''' the tag name with an {{ic|!}}.<br />
<br />
For example:<br />
<br />
<nowiki>http://rss.orf.at/news.xml</nowiki> "!ORF News (hidden)"<br />
<br />
The content of a '''hidden''' feed can only be found through a query feed.<br />
<br />
=== Query feeds ===<br />
<br />
Custom feeds can be created from existing feeds by creating what's called a query feed: A feed generated by matching articles against a query. Query feeds are defined in your {{ic|~/.config/newsboat/urls}} file like a normal feed.<br />
They have the following syntax:<br />
<br />
<nowiki>query:FEEDNAME:FILTER_EXPRESSION [TAG ...]</nowiki><br />
<br />
Like a normal feed, a query feed has a name, {{ic|FEEDNAME}}, which is displayed in the feedlist.<br />
The filter expression language for {{ic|FILTER_EXPRESSION}} is defined in the [https://newsboat.org/releases/2.13/docs/newsboat.html#_filter_language newsboat manual].<br />
Query feeds can be optionally tagged, just like a normal feed. See [[#Tagging feeds]].<br />
<br />
==== Basic Examples ====<br />
<br />
{{hc|~/.config/newsboat/urls|<br />
"query:Archlinux:tags # \"archlinux\"" <br />
"query:Youtube:rssurl {{=}}~ \"youtube\""<br />
}}<br />
<br />
The first example defines a feed named {{ic|Archlinux}} that will contain all articles whose feed was tagged {{ic|archlinux}}. Here the {{ic|#}} is the "contains" operator.<br />
<br />
The second example defines a feed named {{ic|Youtube}} that will contain all articles whose feed url matches the<br />
regular expression {{ic|youtube}}. <br />
<br />
{{Note|The query feed definition must be encapsulated in double quotes. Therefore any other double quotes in its declaration must be escaped}}<br />
<br />
==== Unread articles ====<br />
<br />
To create a feed named {{ic|Unread Articles}} that contains all unread articles, define the following:<br />
<br />
{{hc|~/.config/newsboat/urls|<br />
"query:Unread Articles:unread {{=}} \"yes\""<br />
}}<br />
<br />
==== Amalgamating multiple feeds into one ====<br />
<br />
A good use of query feeds is when you're following a creator whose content is spread across multiple feeds. You can use a query feed to amalgamate all his content into one place.<br />
<br />
{{hc|~/.config/newsboat/urls|<br />
"query:Metafeed:tags # \"metafeed\""<nowiki><br />
https://feed.url/1 metafeed !<br />
https://feed.url/2 metafeed !<br />
https://feed.url/3 metafeed !<br />
</nowiki>}}<br />
<br />
The trick is to assign each individual feed a unique tag - here {{ic|metafeed}} - so that we can match against it in the filter expression. We also make use of [[#Hidden feeds]] - the {{ic|!}} at the end of each feed - so that the individual feeds do not show up in feedlist.<br />
<br />
==== Filtering a specific feed ====<br />
<br />
If a feed contains content you do not want to see, you can filter it by using a query feed.<br />
For example, to monitor updates of the arch kernel, you could use the following:<br />
<br />
{{hc|~/.config/newsboat/urls|<br />
"query:Arch Kernel:(tags # \"archkernel\") and (title {{=}}~ \"linux$\")"<br />
<nowiki>https://archlinux.org/feeds/packages/</nowiki> archkernel !<br />
}}<br />
<br />
=== Ignoring articles ===<br />
<br />
There are two ways to ignore articles, delete them or not show them.<br />
<br />
{{hc|~/.newsboat/config|<br />
# ignore-mode "download" # Default: Delete them.<br />
ignore-mode "display" # Do not show them.<br />
}}<br />
<br />
The filter can be configured like so (here in POSIX extended regular expressions):<br />
<br />
{{hc|~/.newsboat/config|<nowiki><br />
ignore-article "https://feed/url" "content =~ \"tele(phone|communications)\"" <br />
ignore-article "https://feed/url" "title =~ \"text_1|text_2\""<br />
</nowiki>}}<br />
<br />
== Configuration ==<br />
<br />
Several aspects of Newsboat’s behaviour can be configured via a configuration file which is located, by default, in {{ic|~/.newsboat/config}} or {{ic|~/.config/newsboat/config}}. This configuration file contains lines of the form:<br />
<br />
<config-command> <arg1> ...<br />
<br />
=== Color schemes ===<br />
<br />
The package ships with a number of schemes in {{ic|/usr/share/doc/newsboat/contrib/colorschemes/}} which can be loaded with the include command like so:<br />
<br />
include /usr/share/doc/newsboat/contrib/colorschemes/inkpot<br />
<br />
=== Additional options ===<br />
<br />
The configuration file can also contain comments, which start with the {{ic|#}} character and go as far as the end of line. To enter a configuration argument that contains spaces, use quotes {{ic|"}} around the whole argument. It’s even possible to integrate the output of external commands into the configuration. The text between two backticks {{ic|`}} is evaluated as shell command, and its output is put on its place instead. This works like backtick evaluation in Bourne-compatible shells and allows users to use external information from the system within the configuration.<br />
<br />
See [https://gist.github.com/anonymous/42d2f5956e7bc8ee1ebc] and [http://moparx.com/configs/newsbeuter/] for example configurations.<br />
<br />
{{Note|To see a complete list of configuration command, consult {{man|1|newsboat|CONFIGURATION COMMANDS}}.}}<br />
<br />
== Tips and tricks ==<br />
<br />
=== Automatic feed reloads ===<br />
<br />
Newsboat can automatically reload all feeds on startup with the following configuration:<br />
<br />
auto-reload yes<br />
<br />
With this setting, Newsboat also runs periodic auto-reloads – by default, every 60 minutes. The number of minutes between automatic reloads can be configured like so:<br />
<br />
reload-time <desired number of minutes><br />
<br />
Alternatively, use [[cron]] or [[systemd]] to automatically reload feeds. Just add a line in your crontab, or create a systemd service/timer unit combo that issues the following command:<br />
<br />
/usr/bin/newsboat -x reload<br />
<br />
=== Loading of feeds in parallel for faster updates ===<br />
<br />
By default, Newsboat will attempt to update entries in {{ic|~/.newsboat/urls}} in sequence; however, the following setting will update them n at a time, in parallel. Adjust n to your liking.<br />
<br />
reload-threads 100<br />
<br />
=== Pass article URL to external command ===<br />
<br />
A clever little hack allows one to pass the URL of an article to an external command. The idea is to use a macro to set the browser that Newsboat opens the article with to the path of some other command and then change it back afterwards.<br />
<br />
For example, subscribers of a particular youtube channel can open the video with [[mpv]], by doing the following:<br />
<br />
macro y set browser "mpv %u" ; open-in-browser ; set browser "elinks %u"<br />
<br />
{{Note| First press the {{ic|,}} key, followed by the keybind to use the macro. In the example above, type {{ic|,}} + {{ic|y}} }}<br />
<br />
=== Subheadings ===<br />
<br />
There is another little hack that allows the user to add subheadings to sort feeds more effectively. This hack involves adding fake feeds to the {{ic|urls}} file like so:<br />
<br />
---Heading---<br />
<br />
{{Note|the {{ic|---}} characters are optional but having some sort of character identifying the headings is useful for styling.}}<br />
<br />
Then in {{ic|~/.config/newsboat/config}}, add the following two lines:<br />
<br />
highlight feedlist "---.*---" ''COLOR_OF_YOUR_CHOOSING'' default bold<br />
highlight feedlist ".*0/0.." default default invis<br />
<br />
Of course, replace {{ic|''COLOR_OF_YOUR_CHOOSING''}} with a [https://newsboat.org/releases/2.24/docs/newsboat.html#_configuring_colors newsboat supported color].<br />
<br />
This trick can also interact with Tags by replacing {{ic|---Heading---}} with:<br />
<br />
"query:---Heading---:tags # \"Tag\""<br />
<br />
Then tagging all the feeds below the heading with {{ic|Tag}}.<br />
<br />
== Troubleshooting ==<br />
<br />
=== Newsboat will not start ===<br />
<br />
Newsboat cannot start without any configured feeds! To add URLs, see [[#Managing feeds]]. If that is not the problem, check to see if another instance of Newsboat is running. Newsboat issues a lock on its database so that only one instance can access it at a time; thus, attempting to open a second instance will fail.<br />
<br />
== See also ==<br />
<br />
*[https://newsboat.org/ Official web site]<br />
*[https://newsboat.org/releases/2.24/docs/newsboat.html Full documentation]<br />
*[https://sanctum.geek.nz/arabesque/rss-with-newsboat/ Arabesque: RSS with Newsboat]</div>Captaincurriehttps://wiki.archlinux.org/index.php?title=Newsboat&diff=766025Newsboat2023-02-01T13:19:36Z<p>Captaincurrie: /* Amalgamating multiple feeds into one */ grammer</p>
<hr />
<div>[[Category:News aggregators]]<br />
[[Category:Console applications]]<br />
[[ja:Newsboat]]<br />
{{Related articles start}}<br />
{{Related|Web feed}}<br />
{{Related articles end}}<br />
<br />
[https://newsboat.org/ Newsboat] is an open source news aggregator licensed under the MIT License.<br />
<br />
From {{man|1|newsboat|DESCRIPTION}}:<br />
<br />
:Newsboat is an RSS/Atom feed reader for text terminals. RSS and Atom are a number of widely-used XML formats to transmit, publish and syndicate articles, for example news or blog articles. Newsboat is designed to be used on text terminals on Unix or Unix-like systems such as GNU/Linux, BSD or macOS. <br />
<br />
Newsboat is a [https://groups.google.com/forum/#!topic/newsbeuter/RPtlWX8CPGU fork] of abandoned Newsbeuter.<br />
<br />
== Installation ==<br />
<br />
Install the {{Pkg|newsboat}} package. For the development version, install the {{AUR|newsboat-git}} package.<br />
<br />
== Usage ==<br />
<br />
Newsboat cannot start without any configured feeds. Feeds can be configured in {{ic|~/.newsboat/urls}}. Newsboat can be started from the command line with<br />
<br />
$ newsboat<br />
<br />
Press the {{ic|?}} key to see a list of all keybindings. Keybindings can be rebound, see [[#Configuration]].<br />
<br />
== Managing feeds ==<br />
<br />
Adding, removing, and tagging feeds is done by editing the urls file. By default that is {{ic|~/.newsboat/urls}}.<br />
<br />
{{Tip|In addition to newsboat specific feeds in this section, be sure to see the [[Web feed]] article for additional options.}}<br />
<br />
=== RSS or ATOM sources ===<br />
<br />
To add URLs, open {{ic|~/.newsboat/urls}} with your favorite text editor and add the URLs, one per line:<br />
<br />
<nowiki>http://rss.cnn.com/rss/cnn_topstories.rss</nowiki><br />
<nowiki>http://newsrss.bbc.co.uk/rss/newsonline_world_edition/front_page/rss.xml</nowiki><br />
<br />
To add URLs that have restricted access via username/password, simply provide the username/password in the following way:<br />
<br />
<nowiki>http://username:password@hostname.domain.tld/feed.rss</nowiki><br />
<br />
In order to protect username and password, make sure that {{ic|~/.newsboat/urls}} has the appropriate permissions. Newsboat also makes sure that usernames and passwords within URLs aren’t displayed in its user interface. In case there is a @ in the username, type it as %40 instead so that it can be distinguished from the @ that separates the username/password part from the hostname part.<br />
<br />
To configure local files as feeds, simply prefix the local path with {{ic|file://}} and add it to the {{ic|~/.newsboat/urls}} file:<br />
<br />
file:///var/log/rss_eventlog.xml<br />
<br />
=== HTML as a source ===<br />
<br />
If HTML sources can be converted to RSS via a user supplied script, newboat can both execute this script and consume the output.<br />
<br />
This is accomplished by using the {{ic|filter:}} prefix in the configuration file. For example, write a script that can read HTML from stdin and print out an RSS or Atom feed to stdout. Save that script to {{ic|~/.newsboat/html2rss.sh}} and add the following line to the {{ic|urls}}:<br />
<br />
<nowiki>filter:~/.newsboat/html2rss.sh:https://myurl.com</nowiki><br />
<br />
* For several examples using this strategy, see [https://github.com/graysky2/newsboat_custom_stuff graysky's newsboat repo].<br />
* For more discussion, see [https://github.com/newsboat/newsboat/issues/1157 Possible to config newsboat to look at a web exposed directory and report changes #1157].<br />
<br />
=== Tagging feeds ===<br />
<br />
Every feed can be assigned 0 or more tags. This makes it easy to categorize your feeds as well as the ability to easily apply commands to multiple feeds at once.<br />
<br />
Usually, the {{ic|~/.newsboat/urls}} file contains one RSS feed URL per line. To assign a tag to an RSS feed, simply attach it as a single word, separated by blanks such as space or tab. If the tag needs to contain spaces, use quotes (") around the tag (see example below). An example may look like this:<br />
<br />
<nowiki>http://blog.fefe.de/rss.xml?html interesting conspiracy news "cool stuff"</nowiki><br />
<nowiki>http://rss.orf.at/news.xml news orf</nowiki><br />
<nowiki>http://www.heise.de/newsticker/heise.rdf news interesting</nowiki><br />
<br />
Starting Newsboat with this configuration, one can press {{ic|t}} to select a tag. Upon selecting the tag "news", one will see all three RSS feeds. Pressing {{ic|t}} again and e.g. selecting the "conspiracy" tag, will only show the {{ic|<nowiki>http://blog.fefe.de/rss.xml?html</nowiki>}} RSS feed. Pressing {{ic|Ctrl-T}} clears the current tag,<br />
and again shows all RSS feeds, regardless of their assigned tags.<br />
<br />
{{Note| If the tag name contains spaces, the tag must be bounded by {{ic|"}}}}<br />
<br />
==== Special tags ====<br />
<br />
===== Custom feed names =====<br />
<br />
The name of a feed can be defined with a special tag in your urls file. Simply '''prefix''' the tag name with the {{ic|~}} character and the tag name will become the feed name.<br />
<br />
For example:<br />
<br />
<nowiki>http://rss.cnn.com/rss/cnn_topstories.rss</nowiki> "~CNN Top stories"<br />
<br />
will define the feed with feed-name "CNN Top stories"<br />
<br />
===== Hidden feeds =====<br />
<br />
A feed can be '''hidden''' from the regular list of feeds by '''prefixing''' the tag name with an {{ic|!}}.<br />
<br />
For example:<br />
<br />
<nowiki>http://rss.orf.at/news.xml</nowiki> "!ORF News (hidden)"<br />
<br />
The content of a '''hidden''' feed can only be found through a query feed.<br />
<br />
=== Query feeds ===<br />
<br />
Custom feeds can be created from existing feeds by creating what's called a query feed: A feed generated by matching articles against a query. Query feeds are defined in your {{ic|~/.config/newsboat/urls}} file like a normal feed.<br />
They have the following syntax:<br />
<br />
<nowiki>query:FEEDNAME:FILTER_EXPRESSION [TAG ...]</nowiki><br />
<br />
Like a normal feed, a query feed has a name, {{ic|FEEDNAME}}, which is displayed in the feedlist.<br />
The filter expression language for {{ic|FILTER_EXPRESSION}} is defined in the [https://newsboat.org/releases/2.13/docs/newsboat.html#_filter_language newsboat manual].<br />
Query feeds can be optionally tagged, just like a normal feed<br />
<br />
==== Basic Examples ====<br />
<br />
{{hc|~/.config/newsboat/urls|<br />
"query:Archlinux:tags # \"archlinux\"" <br />
"query:Youtube:rssurl {{=}}~ \"youtube\""<br />
}}<br />
<br />
The first example defines a feed named {{ic|Archlinux}} that will contain all articles whose feed was tagged {{ic|archlinux}}. Here the {{ic|#}} is the "contains" operator.<br />
<br />
The second example defines a feed named {{ic|Youtube}} that will contain all articles whose feed url matches the<br />
regular expression {{ic|youtube}}. <br />
<br />
{{Note|The query feed definition must be encapsulated in double quotes. Therefore any other double quotes in its declaration must be escaped}}<br />
<br />
==== Unread articles ====<br />
<br />
To create a feed named {{ic|Unread Articles}} that contains all unread articles, define the following:<br />
<br />
{{hc|~/.config/newsboat/urls|<br />
"query:Unread Articles:unread {{=}} \"yes\""<br />
}}<br />
<br />
==== Amalgamating multiple feeds into one ====<br />
<br />
A good use of query feeds is when you're following a creator whose content is spread across multiple feeds. You can use a query feed to amalgamate all his content into one place.<br />
<br />
{{hc|~/.config/newsboat/urls|<br />
"query:Metafeed:tags # \"metafeed\""<nowiki><br />
https://feed.url/1 metafeed !<br />
https://feed.url/2 metafeed !<br />
https://feed.url/3 metafeed !<br />
</nowiki>}}<br />
<br />
The trick is to assign each individual feed a unique tag - here {{ic|metafeed}} - so that we can match against it in the filter expression. We also make use of [[#Hidden feeds]] - the {{ic|!}} at the end of each feed - so that the individual feeds do not show up in feedlist.<br />
<br />
==== Filtering a specific feed ====<br />
<br />
If a feed contains content you do not want to see, you can filter it by using a query feed.<br />
For example, to monitor updates of the arch kernel, you could use the following:<br />
<br />
{{hc|~/.config/newsboat/urls|<br />
"query:Arch Kernel:(tags # \"archkernel\") and (title {{=}}~ \"linux$\")"<br />
<nowiki>https://archlinux.org/feeds/packages/</nowiki> archkernel !<br />
}}<br />
<br />
=== Ignoring articles ===<br />
<br />
There are two ways to ignore articles, delete them or not show them.<br />
<br />
{{hc|~/.newsboat/config|<br />
# ignore-mode "download" # Default: Delete them.<br />
ignore-mode "display" # Do not show them.<br />
}}<br />
<br />
The filter can be configured like so (here in POSIX extended regular expressions):<br />
<br />
{{hc|~/.newsboat/config|<nowiki><br />
ignore-article "https://feed/url" "content =~ \"tele(phone|communications)\"" <br />
ignore-article "https://feed/url" "title =~ \"text_1|text_2\""<br />
</nowiki>}}<br />
<br />
== Configuration ==<br />
<br />
Several aspects of Newsboat’s behaviour can be configured via a configuration file which is located, by default, in {{ic|~/.newsboat/config}} or {{ic|~/.config/newsboat/config}}. This configuration file contains lines of the form:<br />
<br />
<config-command> <arg1> ...<br />
<br />
=== Color schemes ===<br />
<br />
The package ships with a number of schemes in {{ic|/usr/share/doc/newsboat/contrib/colorschemes/}} which can be loaded with the include command like so:<br />
<br />
include /usr/share/doc/newsboat/contrib/colorschemes/inkpot<br />
<br />
=== Additional options ===<br />
<br />
The configuration file can also contain comments, which start with the {{ic|#}} character and go as far as the end of line. To enter a configuration argument that contains spaces, use quotes {{ic|"}} around the whole argument. It’s even possible to integrate the output of external commands into the configuration. The text between two backticks {{ic|`}} is evaluated as shell command, and its output is put on its place instead. This works like backtick evaluation in Bourne-compatible shells and allows users to use external information from the system within the configuration.<br />
<br />
See [https://gist.github.com/anonymous/42d2f5956e7bc8ee1ebc] and [http://moparx.com/configs/newsbeuter/] for example configurations.<br />
<br />
{{Note|To see a complete list of configuration command, consult {{man|1|newsboat|CONFIGURATION COMMANDS}}.}}<br />
<br />
== Tips and tricks ==<br />
<br />
=== Automatic feed reloads ===<br />
<br />
Newsboat can automatically reload all feeds on startup with the following configuration:<br />
<br />
auto-reload yes<br />
<br />
With this setting, Newsboat also runs periodic auto-reloads – by default, every 60 minutes. The number of minutes between automatic reloads can be configured like so:<br />
<br />
reload-time <desired number of minutes><br />
<br />
Alternatively, use [[cron]] or [[systemd]] to automatically reload feeds. Just add a line in your crontab, or create a systemd service/timer unit combo that issues the following command:<br />
<br />
/usr/bin/newsboat -x reload<br />
<br />
=== Loading of feeds in parallel for faster updates ===<br />
<br />
By default, Newsboat will attempt to update entries in {{ic|~/.newsboat/urls}} in sequence; however, the following setting will update them n at a time, in parallel. Adjust n to your liking.<br />
<br />
reload-threads 100<br />
<br />
=== Pass article URL to external command ===<br />
<br />
A clever little hack allows one to pass the URL of an article to an external command. The idea is to use a macro to set the browser that Newsboat opens the article with to the path of some other command and then change it back afterwards.<br />
<br />
For example, subscribers of a particular youtube channel can open the video with [[mpv]], by doing the following:<br />
<br />
macro y set browser "mpv %u" ; open-in-browser ; set browser "elinks %u"<br />
<br />
{{Note| First press the {{ic|,}} key, followed by the keybind to use the macro. In the example above, type {{ic|,}} + {{ic|y}} }}<br />
<br />
=== Subheadings ===<br />
<br />
There is another little hack that allows the user to add subheadings to sort feeds more effectively. This hack involves adding fake feeds to the {{ic|urls}} file like so:<br />
<br />
---Heading---<br />
<br />
{{Note|the {{ic|---}} characters are optional but having some sort of character identifying the headings is useful for styling.}}<br />
<br />
Then in {{ic|~/.config/newsboat/config}}, add the following two lines:<br />
<br />
highlight feedlist "---.*---" ''COLOR_OF_YOUR_CHOOSING'' default bold<br />
highlight feedlist ".*0/0.." default default invis<br />
<br />
Of course, replace {{ic|''COLOR_OF_YOUR_CHOOSING''}} with a [https://newsboat.org/releases/2.24/docs/newsboat.html#_configuring_colors newsboat supported color].<br />
<br />
This trick can also interact with Tags by replacing {{ic|---Heading---}} with:<br />
<br />
"query:---Heading---:tags # \"Tag\""<br />
<br />
Then tagging all the feeds below the heading with {{ic|Tag}}.<br />
<br />
== Troubleshooting ==<br />
<br />
=== Newsboat will not start ===<br />
<br />
Newsboat cannot start without any configured feeds! To add URLs, see [[#Managing feeds]]. If that is not the problem, check to see if another instance of Newsboat is running. Newsboat issues a lock on its database so that only one instance can access it at a time; thus, attempting to open a second instance will fail.<br />
<br />
== See also ==<br />
<br />
*[https://newsboat.org/ Official web site]<br />
*[https://newsboat.org/releases/2.24/docs/newsboat.html Full documentation]<br />
*[https://sanctum.geek.nz/arabesque/rss-with-newsboat/ Arabesque: RSS with Newsboat]</div>Captaincurriehttps://wiki.archlinux.org/index.php?title=Newsboat&diff=766024Newsboat2023-02-01T13:18:29Z<p>Captaincurrie: /* Query feeds */ reorganization. Added new subsection "Basic Examples". Rephrasing</p>
<hr />
<div>[[Category:News aggregators]]<br />
[[Category:Console applications]]<br />
[[ja:Newsboat]]<br />
{{Related articles start}}<br />
{{Related|Web feed}}<br />
{{Related articles end}}<br />
<br />
[https://newsboat.org/ Newsboat] is an open source news aggregator licensed under the MIT License.<br />
<br />
From {{man|1|newsboat|DESCRIPTION}}:<br />
<br />
:Newsboat is an RSS/Atom feed reader for text terminals. RSS and Atom are a number of widely-used XML formats to transmit, publish and syndicate articles, for example news or blog articles. Newsboat is designed to be used on text terminals on Unix or Unix-like systems such as GNU/Linux, BSD or macOS. <br />
<br />
Newsboat is a [https://groups.google.com/forum/#!topic/newsbeuter/RPtlWX8CPGU fork] of abandoned Newsbeuter.<br />
<br />
== Installation ==<br />
<br />
Install the {{Pkg|newsboat}} package. For the development version, install the {{AUR|newsboat-git}} package.<br />
<br />
== Usage ==<br />
<br />
Newsboat cannot start without any configured feeds. Feeds can be configured in {{ic|~/.newsboat/urls}}. Newsboat can be started from the command line with<br />
<br />
$ newsboat<br />
<br />
Press the {{ic|?}} key to see a list of all keybindings. Keybindings can be rebound, see [[#Configuration]].<br />
<br />
== Managing feeds ==<br />
<br />
Adding, removing, and tagging feeds is done by editing the urls file. By default that is {{ic|~/.newsboat/urls}}.<br />
<br />
{{Tip|In addition to newsboat specific feeds in this section, be sure to see the [[Web feed]] article for additional options.}}<br />
<br />
=== RSS or ATOM sources ===<br />
<br />
To add URLs, open {{ic|~/.newsboat/urls}} with your favorite text editor and add the URLs, one per line:<br />
<br />
<nowiki>http://rss.cnn.com/rss/cnn_topstories.rss</nowiki><br />
<nowiki>http://newsrss.bbc.co.uk/rss/newsonline_world_edition/front_page/rss.xml</nowiki><br />
<br />
To add URLs that have restricted access via username/password, simply provide the username/password in the following way:<br />
<br />
<nowiki>http://username:password@hostname.domain.tld/feed.rss</nowiki><br />
<br />
In order to protect username and password, make sure that {{ic|~/.newsboat/urls}} has the appropriate permissions. Newsboat also makes sure that usernames and passwords within URLs aren’t displayed in its user interface. In case there is a @ in the username, type it as %40 instead so that it can be distinguished from the @ that separates the username/password part from the hostname part.<br />
<br />
To configure local files as feeds, simply prefix the local path with {{ic|file://}} and add it to the {{ic|~/.newsboat/urls}} file:<br />
<br />
file:///var/log/rss_eventlog.xml<br />
<br />
=== HTML as a source ===<br />
<br />
If HTML sources can be converted to RSS via a user supplied script, newboat can both execute this script and consume the output.<br />
<br />
This is accomplished by using the {{ic|filter:}} prefix in the configuration file. For example, write a script that can read HTML from stdin and print out an RSS or Atom feed to stdout. Save that script to {{ic|~/.newsboat/html2rss.sh}} and add the following line to the {{ic|urls}}:<br />
<br />
<nowiki>filter:~/.newsboat/html2rss.sh:https://myurl.com</nowiki><br />
<br />
* For several examples using this strategy, see [https://github.com/graysky2/newsboat_custom_stuff graysky's newsboat repo].<br />
* For more discussion, see [https://github.com/newsboat/newsboat/issues/1157 Possible to config newsboat to look at a web exposed directory and report changes #1157].<br />
<br />
=== Tagging feeds ===<br />
<br />
Every feed can be assigned 0 or more tags. This makes it easy to categorize your feeds as well as the ability to easily apply commands to multiple feeds at once.<br />
<br />
Usually, the {{ic|~/.newsboat/urls}} file contains one RSS feed URL per line. To assign a tag to an RSS feed, simply attach it as a single word, separated by blanks such as space or tab. If the tag needs to contain spaces, use quotes (") around the tag (see example below). An example may look like this:<br />
<br />
<nowiki>http://blog.fefe.de/rss.xml?html interesting conspiracy news "cool stuff"</nowiki><br />
<nowiki>http://rss.orf.at/news.xml news orf</nowiki><br />
<nowiki>http://www.heise.de/newsticker/heise.rdf news interesting</nowiki><br />
<br />
Starting Newsboat with this configuration, one can press {{ic|t}} to select a tag. Upon selecting the tag "news", one will see all three RSS feeds. Pressing {{ic|t}} again and e.g. selecting the "conspiracy" tag, will only show the {{ic|<nowiki>http://blog.fefe.de/rss.xml?html</nowiki>}} RSS feed. Pressing {{ic|Ctrl-T}} clears the current tag,<br />
and again shows all RSS feeds, regardless of their assigned tags.<br />
<br />
{{Note| If the tag name contains spaces, the tag must be bounded by {{ic|"}}}}<br />
<br />
==== Special tags ====<br />
<br />
===== Custom feed names =====<br />
<br />
The name of a feed can be defined with a special tag in your urls file. Simply '''prefix''' the tag name with the {{ic|~}} character and the tag name will become the feed name.<br />
<br />
For example:<br />
<br />
<nowiki>http://rss.cnn.com/rss/cnn_topstories.rss</nowiki> "~CNN Top stories"<br />
<br />
will define the feed with feed-name "CNN Top stories"<br />
<br />
===== Hidden feeds =====<br />
<br />
A feed can be '''hidden''' from the regular list of feeds by '''prefixing''' the tag name with an {{ic|!}}.<br />
<br />
For example:<br />
<br />
<nowiki>http://rss.orf.at/news.xml</nowiki> "!ORF News (hidden)"<br />
<br />
The content of a '''hidden''' feed can only be found through a query feed.<br />
<br />
=== Query feeds ===<br />
<br />
Custom feeds can be created from existing feeds by creating what's called a query feed: A feed generated by matching articles against a query. Query feeds are defined in your {{ic|~/.config/newsboat/urls}} file like a normal feed.<br />
They have the following syntax:<br />
<br />
<nowiki>query:FEEDNAME:FILTER_EXPRESSION [TAG ...]</nowiki><br />
<br />
Like a normal feed, a query feed has a name, {{ic|FEEDNAME}}, which is displayed in the feedlist.<br />
The filter expression language for {{ic|FILTER_EXPRESSION}} is defined in the [https://newsboat.org/releases/2.13/docs/newsboat.html#_filter_language newsboat manual].<br />
Query feeds can be optionally tagged, just like a normal feed<br />
<br />
==== Basic Examples ====<br />
<br />
{{hc|~/.config/newsboat/urls|<br />
"query:Archlinux:tags # \"archlinux\"" <br />
"query:Youtube:rssurl {{=}}~ \"youtube\""<br />
}}<br />
<br />
The first example defines a feed named {{ic|Archlinux}} that will contain all articles whose feed was tagged {{ic|archlinux}}. Here the {{ic|#}} is the "contains" operator.<br />
<br />
The second example defines a feed named {{ic|Youtube}} that will contain all articles whose feed url matches the<br />
regular expression {{ic|youtube}}. <br />
<br />
{{Note|The query feed definition must be encapsulated in double quotes. Therefore any other double quotes in its declaration must be escaped}}<br />
<br />
==== Unread articles ====<br />
<br />
To create a feed named {{ic|Unread Articles}} that contains all unread articles, define the following:<br />
<br />
{{hc|~/.config/newsboat/urls|<br />
"query:Unread Articles:unread {{=}} \"yes\""<br />
}}<br />
<br />
==== Amalgamating multiple feeds into one ====<br />
<br />
A good use of query feeds is when you are following a creator whose content is spread across multiple feeds. You can use a query feed to amalgamate all his content into one place.<br />
<br />
{{hc|~/.config/newsboat/urls|<br />
"query:Metafeed:tags # \"metafeed\""<nowiki><br />
https://feed.url/1 metafeed !<br />
https://feed.url/2 metafeed !<br />
https://feed.url/3 metafeed !<br />
</nowiki>}}<br />
<br />
The trick is to assign each individual feed a unique tag - here {{ic|metafeed}} - so that we can match against it in the filter expression. We also make use of [[#Hidden feeds]] - the {{ic|!}} at the end of each feed - so that the individual feeds do not show up in feedlist.<br />
<br />
==== Filtering a specific feed ====<br />
<br />
If a feed contains content you do not want to see, you can filter it by using a query feed.<br />
For example, to monitor updates of the arch kernel, you could use the following:<br />
<br />
{{hc|~/.config/newsboat/urls|<br />
"query:Arch Kernel:(tags # \"archkernel\") and (title {{=}}~ \"linux$\")"<br />
<nowiki>https://archlinux.org/feeds/packages/</nowiki> archkernel !<br />
}}<br />
<br />
=== Ignoring articles ===<br />
<br />
There are two ways to ignore articles, delete them or not show them.<br />
<br />
{{hc|~/.newsboat/config|<br />
# ignore-mode "download" # Default: Delete them.<br />
ignore-mode "display" # Do not show them.<br />
}}<br />
<br />
The filter can be configured like so (here in POSIX extended regular expressions):<br />
<br />
{{hc|~/.newsboat/config|<nowiki><br />
ignore-article "https://feed/url" "content =~ \"tele(phone|communications)\"" <br />
ignore-article "https://feed/url" "title =~ \"text_1|text_2\""<br />
</nowiki>}}<br />
<br />
== Configuration ==<br />
<br />
Several aspects of Newsboat’s behaviour can be configured via a configuration file which is located, by default, in {{ic|~/.newsboat/config}} or {{ic|~/.config/newsboat/config}}. This configuration file contains lines of the form:<br />
<br />
<config-command> <arg1> ...<br />
<br />
=== Color schemes ===<br />
<br />
The package ships with a number of schemes in {{ic|/usr/share/doc/newsboat/contrib/colorschemes/}} which can be loaded with the include command like so:<br />
<br />
include /usr/share/doc/newsboat/contrib/colorschemes/inkpot<br />
<br />
=== Additional options ===<br />
<br />
The configuration file can also contain comments, which start with the {{ic|#}} character and go as far as the end of line. To enter a configuration argument that contains spaces, use quotes {{ic|"}} around the whole argument. It’s even possible to integrate the output of external commands into the configuration. The text between two backticks {{ic|`}} is evaluated as shell command, and its output is put on its place instead. This works like backtick evaluation in Bourne-compatible shells and allows users to use external information from the system within the configuration.<br />
<br />
See [https://gist.github.com/anonymous/42d2f5956e7bc8ee1ebc] and [http://moparx.com/configs/newsbeuter/] for example configurations.<br />
<br />
{{Note|To see a complete list of configuration command, consult {{man|1|newsboat|CONFIGURATION COMMANDS}}.}}<br />
<br />
== Tips and tricks ==<br />
<br />
=== Automatic feed reloads ===<br />
<br />
Newsboat can automatically reload all feeds on startup with the following configuration:<br />
<br />
auto-reload yes<br />
<br />
With this setting, Newsboat also runs periodic auto-reloads – by default, every 60 minutes. The number of minutes between automatic reloads can be configured like so:<br />
<br />
reload-time <desired number of minutes><br />
<br />
Alternatively, use [[cron]] or [[systemd]] to automatically reload feeds. Just add a line in your crontab, or create a systemd service/timer unit combo that issues the following command:<br />
<br />
/usr/bin/newsboat -x reload<br />
<br />
=== Loading of feeds in parallel for faster updates ===<br />
<br />
By default, Newsboat will attempt to update entries in {{ic|~/.newsboat/urls}} in sequence; however, the following setting will update them n at a time, in parallel. Adjust n to your liking.<br />
<br />
reload-threads 100<br />
<br />
=== Pass article URL to external command ===<br />
<br />
A clever little hack allows one to pass the URL of an article to an external command. The idea is to use a macro to set the browser that Newsboat opens the article with to the path of some other command and then change it back afterwards.<br />
<br />
For example, subscribers of a particular youtube channel can open the video with [[mpv]], by doing the following:<br />
<br />
macro y set browser "mpv %u" ; open-in-browser ; set browser "elinks %u"<br />
<br />
{{Note| First press the {{ic|,}} key, followed by the keybind to use the macro. In the example above, type {{ic|,}} + {{ic|y}} }}<br />
<br />
=== Subheadings ===<br />
<br />
There is another little hack that allows the user to add subheadings to sort feeds more effectively. This hack involves adding fake feeds to the {{ic|urls}} file like so:<br />
<br />
---Heading---<br />
<br />
{{Note|the {{ic|---}} characters are optional but having some sort of character identifying the headings is useful for styling.}}<br />
<br />
Then in {{ic|~/.config/newsboat/config}}, add the following two lines:<br />
<br />
highlight feedlist "---.*---" ''COLOR_OF_YOUR_CHOOSING'' default bold<br />
highlight feedlist ".*0/0.." default default invis<br />
<br />
Of course, replace {{ic|''COLOR_OF_YOUR_CHOOSING''}} with a [https://newsboat.org/releases/2.24/docs/newsboat.html#_configuring_colors newsboat supported color].<br />
<br />
This trick can also interact with Tags by replacing {{ic|---Heading---}} with:<br />
<br />
"query:---Heading---:tags # \"Tag\""<br />
<br />
Then tagging all the feeds below the heading with {{ic|Tag}}.<br />
<br />
== Troubleshooting ==<br />
<br />
=== Newsboat will not start ===<br />
<br />
Newsboat cannot start without any configured feeds! To add URLs, see [[#Managing feeds]]. If that is not the problem, check to see if another instance of Newsboat is running. Newsboat issues a lock on its database so that only one instance can access it at a time; thus, attempting to open a second instance will fail.<br />
<br />
== See also ==<br />
<br />
*[https://newsboat.org/ Official web site]<br />
*[https://newsboat.org/releases/2.24/docs/newsboat.html Full documentation]<br />
*[https://sanctum.geek.nz/arabesque/rss-with-newsboat/ Arabesque: RSS with Newsboat]</div>Captaincurriehttps://wiki.archlinux.org/index.php?title=Newsboat&diff=765990Newsboat2023-02-01T01:15:09Z<p>Captaincurrie: formatting</p>
<hr />
<div>[[Category:News aggregators]]<br />
[[Category:Console applications]]<br />
[[ja:Newsboat]]<br />
{{Related articles start}}<br />
{{Related|Web feed}}<br />
{{Related articles end}}<br />
<br />
[https://newsboat.org/ Newsboat] is an open source news aggregator licensed under the MIT License.<br />
<br />
From {{man|1|newsboat|DESCRIPTION}}:<br />
<br />
:Newsboat is an RSS/Atom feed reader for text terminals. RSS and Atom are a number of widely-used XML formats to transmit, publish and syndicate articles, for example news or blog articles. Newsboat is designed to be used on text terminals on Unix or Unix-like systems such as GNU/Linux, BSD or macOS. <br />
<br />
Newsboat is a [https://groups.google.com/forum/#!topic/newsbeuter/RPtlWX8CPGU fork] of abandoned Newsbeuter.<br />
<br />
== Installation ==<br />
<br />
Install the {{Pkg|newsboat}} package. For the development version, install the {{AUR|newsboat-git}} package.<br />
<br />
== Usage ==<br />
<br />
Newsboat cannot start without any configured feeds. Feeds can be configured in {{ic|~/.newsboat/urls}}. Newsboat can be started from the command line with<br />
<br />
$ newsboat<br />
<br />
Press the {{ic|?}} key to see a list of all keybindings. Keybindings can be rebound, see [[#Configuration]].<br />
<br />
== Managing feeds ==<br />
<br />
Adding, removing, and tagging feeds is done by editing the urls file. By default that is {{ic|~/.newsboat/urls}}.<br />
{{Tip|In addition to newsboat specific feeds in this section, be sure to see the [[Web feed]] article for additional options.}}<br />
<br />
=== RSS or ATOM sources ===<br />
<br />
To add URLs, open {{ic|~/.newsboat/urls}} with your favorite text editor and add the URLs, one per line:<br />
<br />
<nowiki>http://rss.cnn.com/rss/cnn_topstories.rss</nowiki><br />
<nowiki>http://newsrss.bbc.co.uk/rss/newsonline_world_edition/front_page/rss.xml</nowiki><br />
<br />
To add URLs that have restricted access via username/password, simply provide the username/password in the following way:<br />
<br />
<nowiki>http://username:password@hostname.domain.tld/feed.rss</nowiki><br />
<br />
In order to protect username and password, make sure that {{ic|~/.newsboat/urls}} has the appropriate permissions. Newsboat also makes sure that usernames and passwords within URLs aren’t displayed in its user interface. In case there is a @ in the username, type it as %40 instead so that it can be distinguished from the @ that separates the username/password part from the hostname part.<br />
<br />
To configure local files as feeds, simply prefix the local path with {{ic|file://}} and add it to the {{ic|~/.newsboat/urls}} file:<br />
file:///var/log/rss_eventlog.xml<br />
<br />
=== HTML as a source ===<br />
<br />
If HTML sources can be converted to RSS via a user supplied script, newboat can both execute this script and consume the output.<br />
<br />
This is accomplished by using the {{ic|filter:}} prefix in the configuration file. For example, write a script that can read HTML from stdin and print out an RSS or Atom feed to stdout. Save that script to {{ic|~/.newsboat/html2rss.sh}} and add the following line to the {{ic|urls}}:<br />
<nowiki>filter:~/.newsboat/html2rss.sh:https://myurl.com</nowiki><br />
<br />
* For several examples using this strategy, see [https://github.com/graysky2/newsboat_custom_stuff graysky's newsboat repo].<br />
* For more discussion, see [https://github.com/newsboat/newsboat/issues/1157 Possible to config newsboat to look at a web exposed directory and report changes #1157].<br />
<br />
=== Tagging feeds ===<br />
<br />
Every feed can be assigned 0 or more tags. This makes it easy to categorize your feeds as well as the ability to easily apply commands to multiple feeds at once.<br />
<br />
Usually, the {{ic|~/.newsboat/urls}} file contains one RSS feed URL per line. To assign a tag to an RSS feed, simply attach it as a single word, separated by blanks such as space or tab. If the tag needs to contain spaces, use quotes (") around the tag (see example below). An example may look like this:<br />
<nowiki>http://blog.fefe.de/rss.xml?html interesting conspiracy news "cool stuff"</nowiki><br />
<nowiki>http://rss.orf.at/news.xml news orf</nowiki><br />
<nowiki>http://www.heise.de/newsticker/heise.rdf news interesting</nowiki><br />
<br />
Starting Newsboat with this configuration, one can press {{ic|t}} to select a tag. Upon selecting the tag "news", one will see all three RSS feeds. Pressing {{ic|t}} again and e.g. selecting the "conspiracy" tag, will only show the {{ic|<nowiki>http://blog.fefe.de/rss.xml?html</nowiki>}} RSS feed. Pressing {{ic|Ctrl-T}} clears the current tag,<br />
and again shows all RSS feeds, regardless of their assigned tags.<br />
<br />
{{Note| If the tag name contains spaces, the tag must be bounded by {{ic|"}}}}<br />
<br />
==== Special tags ====<br />
<br />
===== Custom feed names =====<br />
<br />
The name of a feed can be defined with a special tag in your urls file. Simply '''prefix''' the tag name with the {{ic|~}} character and the tag name will become the feed name.<br />
<br />
For example:<br />
<br />
<nowiki>http://rss.cnn.com/rss/cnn_topstories.rss</nowiki> "~CNN Top stories"<br />
<br />
will define the feed with feed-name "CNN Top stories"<br />
<br />
===== Hidden feeds =====<br />
<br />
A feed can be '''hidden''' from the regular list of feeds by '''prefixing''' the tag name with an {{ic|!}}.<br />
<br />
For example:<br />
<nowiki>http://rss.orf.at/news.xml</nowiki> "!ORF News (hidden)"<br />
<br />
The content of a '''hidden''' feed can only be found through a query feed.<br />
<br />
=== Query feeds ===<br />
<br />
Custom feeds can be created from existing feeds by creating what's called a query feed: A feed generated by matching articles against a query. Query feeds are defined in your {{ic|~/.config/newsboat/urls}} file like a normal feed.<br />
They have the following syntax:<br />
<br />
<nowiki>query:FEEDNAME:FILTER_EXPRESSION [TAG ...]</nowiki><br />
<br />
Like a normal feed, a query feed has a name, {{ic|FEEDNAME}}, which is displayed in the feedlist.<br />
The filter expression language for {{ic|FILTER_EXPRESSION}} is defined in the [https://newsboat.org/releases/2.13/docs/newsboat.html#_filter_language newsboat manual].<br />
Also like any normal feed, query feeds can be optionally tagged.<br />
<br />
Here are some examples:<br />
<br />
{{hc|~/.config/newsboat/urls|<br />
"query:Archlinux:tags # \"archlinux\""<br />
"query:Youtube:rssurl {{=}}~ \"youtube\""<br />
}}<br />
<br />
{{Note|The query feed must be encapsulated in double quotes. Therefore any other double quotes in its declaration must be escaped}}<br />
<br />
==== Unread articles ====<br />
<br />
To create a feed named {{ic|Unread Articles}} that contains all unread articles, define the following:<br />
<br />
{{hc|~/.config/newsboat/urls|<br />
"query:Unread Articles:unread {{=}} \"yes\""<br />
}}<br />
<br />
==== Amalgamating multiple feeds into one ====<br />
<br />
A good use of query feeds is when you're following a creator whose content is spread across multiple feeds. You can use a query feed to amalgamate all his content into one place.<br />
<br />
{{hc|~/.config/newsboat/urls|<br />
"query:Metafeed:tags # \"metafeed\""<nowiki><br />
https://feed.url/1 metafeed !<br />
https://feed.url/2 metafeed !<br />
https://feed.url/3 metafeed !<br />
</nowiki>}}<br />
<br />
The trick is to assign each feed a unique tag - here {{ic|metafeed}} - so that we can match against it in the filter expression. We also make use of [[#Hidden feeds]] - the {{ic|!}} at the end of each feed - so that the individual feeds don't show up in feedlist.<br />
<br />
==== Filtering a specific feed ====<br />
<br />
If a feed contains content you don't want to see, you can filter it by using a query feed.<br />
For example, to monitor updates of the arch kernel, you could use the following:<br />
<br />
{{hc|~/.config/newsboat/urls|<br />
"query:Arch Kernel:(tags # \"archkernel\") and (title {{=}}~ \"linux$\")"<br />
<nowiki>https://archlinux.org/feeds/packages/</nowiki> archkernel !<br />
}}<br />
<br />
=== Ignoring articles ===<br />
<br />
There are two ways to ignore articles, delete them or not show them.<br />
{{hc|~/.newsboat/config|<br />
# ignore-mode "download" # Default: Delete them.<br />
ignore-mode "display" # Do not show them.<br />
}}<br />
The filter can be configured like so (here in POSIX extended regular expressions):<br />
{{hc|~/.newsboat/config|<nowiki><br />
ignore-article "https://feed/url" "content =~ \"tele(phone|communications)\"" <br />
ignore-article "https://feed/url" "title =~ \"text_1|text_2\""<br />
</nowiki>}}<br />
<br />
== Configuration ==<br />
<br />
Several aspects of Newsboat’s behaviour can be configured via a configuration file which is located, by default, in {{ic|~/.newsboat/config}} or {{ic|~/.config/newsboat/config}}. This configuration file contains lines of the form:<br />
<br />
<config-command> <arg1> ...<br />
<br />
=== Color schemes ===<br />
<br />
The package ships with a number of schemes in {{ic|/usr/share/doc/newsboat/contrib/colorschemes/}} which can be loaded with the include command like so:<br />
include /usr/share/doc/newsboat/contrib/colorschemes/inkpot<br />
<br />
=== Additional options ===<br />
<br />
The configuration file can also contain comments, which start with the {{ic|#}} character and go as far as the end of line. To enter a configuration argument that contains spaces, use quotes {{ic|"}} around the whole argument. It’s even possible to integrate the output of external commands into the configuration. The text between two backticks {{ic|`}} is evaluated as shell command, and its output is put on its place instead. This works like backtick evaluation in Bourne-compatible shells and allows users to use external information from the system within the configuration.<br />
<br />
See [https://gist.github.com/anonymous/42d2f5956e7bc8ee1ebc] and [http://moparx.com/configs/newsbeuter/] for example configurations.<br />
<br />
{{Note|To see a complete list of configuration command, consult {{man|1|newsboat|CONFIGURATION COMMANDS}}.}}<br />
<br />
== Tips ==<br />
<br />
=== Automatic feed reloads ===<br />
<br />
Newsboat can automatically reload all feeds on startup with the following configuration:<br />
<br />
auto-reload yes<br />
<br />
With this setting, Newsboat also runs periodic auto-reloads – by default, every 60 minutes. The number of minutes between automatic reloads can be configured like so:<br />
<br />
reload-time <desired number of minutes><br />
<br />
Alternatively, use [[cron]] or [[systemd]] to automatically reload feeds. Just add a line in your crontab, or create a systemd service/timer unit combo that issues the following command:<br />
<br />
/usr/bin/newsboat -x reload<br />
<br />
=== Loading of feeds in parallel for faster updates ===<br />
<br />
By default, Newsboat will attempt to update entries in {{ic|~/.newsboat/urls}} in sequence; however, the following setting will update them n at a time, in parallel. Adjust n to your liking.<br />
<br />
reload-threads 100<br />
<br />
=== Pass article URL to external command ===<br />
<br />
A clever little hack allows one to pass the URL of an article to an external command. The idea is to use a macro to set the browser that Newsboat opens the article with to the path of some other command and then change it back afterwards.<br />
<br />
For example, subscribers of a particular youtube channel can open the video with [[mpv]], by doing the following:<br />
<br />
macro y set browser "mpv %u" ; open-in-browser ; set browser "elinks %u"<br />
<br />
{{Note| First press the {{ic|,}} key, followed by the keybind to use the macro. In the example above, type {{ic|,}} + {{ic|y}} }}<br />
<br />
=== Subheadings ===<br />
<br />
There is another little hack that allows the user to add subheadings to sort feeds more effectively. This hack involves adding fake feeds to the {{ic|urls}} file like so:<br />
<br />
---Heading---<br />
<br />
{{Note|the {{ic|---}} characters are optional but having some sort of character identifying the headings is useful for styling.}}<br />
<br />
Then in {{ic|~/.config/newsboat/config}}, add the following two lines:<br />
<br />
highlight feedlist "---.*---" ''COLOR_OF_YOUR_CHOOSING'' default bold<br />
highlight feedlist ".*0/0.." default default invis<br />
<br />
Of course, replace {{ic|''COLOR_OF_YOUR_CHOOSING''}} with a [https://newsboat.org/releases/2.24/docs/newsboat.html#_configuring_colors newsboat supported color].<br />
<br />
This trick can also interact with Tags by replacing {{ic|---Heading---}} with:<br />
<br />
"query:---Heading---:tags # \"Tag\""<br />
<br />
Then tagging all the feeds below the heading with {{ic|Tag}}.<br />
<br />
== Troubleshooting ==<br />
<br />
=== Newsboat will not start ===<br />
<br />
Newsboat cannot start without any configured feeds! To add URLs, see [[#Managing feeds]]. If that is not the problem, check to see if another instance of Newsboat is running. Newsboat issues a lock on its database so that only one instance can access it at a time; thus, attempting to open a second instance will fail.<br />
<br />
== See Also ==<br />
<br />
*[https://newsboat.org/ Official web site]<br />
*[https://newsboat.org/releases/2.24/docs/newsboat.html Full documentation]<br />
*[https://sanctum.geek.nz/arabesque/rss-with-newsboat/ Arabesque: RSS with Newsboat]</div>Captaincurriehttps://wiki.archlinux.org/index.php?title=Newsboat&diff=765989Newsboat2023-02-01T01:14:21Z<p>Captaincurrie: formatting</p>
<hr />
<div>[[Category:News aggregators]]<br />
[[Category:Console applications]]<br />
[[ja:Newsboat]]<br />
{{Related articles start}}<br />
{{Related|Web feed}}<br />
{{Related articles end}}<br />
<br />
[https://newsboat.org/ Newsboat] is an open source news aggregator licensed under the MIT License.<br />
<br />
From {{man|1|newsboat|DESCRIPTION}}:<br />
<br />
:Newsboat is an RSS/Atom feed reader for text terminals. RSS and Atom are a number of widely-used XML formats to transmit, publish and syndicate articles, for example news or blog articles. Newsboat is designed to be used on text terminals on Unix or Unix-like systems such as GNU/Linux, BSD or macOS. <br />
<br />
Newsboat is a [https://groups.google.com/forum/#!topic/newsbeuter/RPtlWX8CPGU fork] of abandoned Newsbeuter.<br />
<br />
== Installation ==<br />
<br />
Install the {{Pkg|newsboat}} package. For the development version, install the {{AUR|newsboat-git}} package.<br />
<br />
== Usage ==<br />
<br />
Newsboat cannot start without any configured feeds. Feeds can be configured in {{ic|~/.newsboat/urls}}. Newsboat can be started from the command line with<br />
<br />
$ newsboat<br />
<br />
Press the {{ic|?}} key to see a list of all keybindings. Keybindings can be rebound, see [[#Configuration]].<br />
<br />
== Managing feeds ==<br />
<br />
Adding, removing, and tagging feeds is done by editing the urls file. By default that is {{ic|~/.newsboat/urls}}.<br />
{{Tip|In addition to newsboat specific feeds in this section, be sure to see the [[Web feed]] article for additional options.}}<br />
<br />
=== RSS or ATOM sources ===<br />
<br />
To add URLs, open {{ic|~/.newsboat/urls}} with your favorite text editor and add the URLs, one per line:<br />
<br />
<nowiki>http://rss.cnn.com/rss/cnn_topstories.rss</nowiki><br />
<nowiki>http://newsrss.bbc.co.uk/rss/newsonline_world_edition/front_page/rss.xml</nowiki><br />
<br />
To add URLs that have restricted access via username/password, simply provide the username/password in the following way:<br />
<br />
<nowiki>http://username:password@hostname.domain.tld/feed.rss</nowiki><br />
<br />
In order to protect username and password, make sure that {{ic|~/.newsboat/urls}} has the appropriate permissions. Newsboat also makes sure that usernames and passwords within URLs aren’t displayed in its user interface. In case there is a @ in the username, type it as %40 instead so that it can be distinguished from the @ that separates the username/password part from the hostname part.<br />
<br />
To configure local files as feeds, simply prefix the local path with {{ic|file://}} and add it to the {{ic|~/.newsboat/urls}} file:<br />
file:///var/log/rss_eventlog.xml<br />
<br />
=== HTML as a source ===<br />
<br />
If HTML sources can be converted to RSS via a user supplied script, newboat can both execute this script and consume the output.<br />
<br />
This is accomplished by using the {{ic|filter:}} prefix in the configuration file. For example, write a script that can read HTML from stdin and print out an RSS or Atom feed to stdout. Save that script to {{ic|~/.newsboat/html2rss.sh}} and add the following line to the {{ic|urls}}:<br />
<nowiki>filter:~/.newsboat/html2rss.sh:https://myurl.com</nowiki><br />
<br />
* For several examples using this strategy, see [https://github.com/graysky2/newsboat_custom_stuff graysky's newsboat repo].<br />
* For more discussion, see [https://github.com/newsboat/newsboat/issues/1157 Possible to config newsboat to look at a web exposed directory and report changes #1157].<br />
<br />
=== Tagging feeds ===<br />
<br />
Every feed can be assigned 0 or more tags. This makes it easy to categorize your feeds as well as the ability to easily apply commands to multiple feeds at once.<br />
<br />
Usually, the {{ic|~/.newsboat/urls}} file contains one RSS feed URL per line. To assign a tag to an RSS feed, simply attach it as a single word, separated by blanks such as space or tab. If the tag needs to contain spaces, use quotes (") around the tag (see example below). An example may look like this:<br />
<nowiki>http://blog.fefe.de/rss.xml?html interesting conspiracy news "cool stuff"</nowiki><br />
<nowiki>http://rss.orf.at/news.xml news orf</nowiki><br />
<nowiki>http://www.heise.de/newsticker/heise.rdf news interesting</nowiki><br />
<br />
Starting Newsboat with this configuration, one can press {{ic|t}} to select a tag. Upon selecting the tag "news", one will see all three RSS feeds. Pressing {{ic|t}} again and e.g. selecting the "conspiracy" tag, will only show the {{ic|<nowiki>http://blog.fefe.de/rss.xml?html</nowiki>}} RSS feed. Pressing {{ic|Ctrl-T}} clears the current tag,<br />
and again shows all RSS feeds, regardless of their assigned tags.<br />
<br />
{{Note| If the tag name contains spaces, the tag must be bounded by {{ic|"}}}}<br />
<br />
==== Special tags ====<br />
<br />
===== Custom feed names =====<br />
<br />
The name of a feed can be defined with a special tag in your urls file. Simply '''prefix''' the tag name with the {{ic|~}} character and the tag name will become the feed name.<br />
<br />
For example:<br />
<br />
<nowiki>http://rss.cnn.com/rss/cnn_topstories.rss</nowiki> "~CNN Top stories"<br />
<br />
will define the feed with feed-name "CNN Top stories"<br />
<br />
===== Hidden feeds =====<br />
<br />
A feed can be '''hidden''' from the regular list of feeds by '''prefixing''' the tag name with an {{ic|!}}.<br />
<br />
For example:<br />
<nowiki>http://rss.orf.at/news.xml</nowiki> "!ORF News (hidden)"<br />
<br />
The content of a '''hidden''' feed can only be found through a query feed.<br />
<br />
=== Query feeds ===<br />
<br />
Custom feeds can be created from existing feeds by creating what's called a query feed: A feed generated by matching articles against a query. Query feeds are defined in your {{ic|~/.config/newsboat/urls}} file like a normal feed.<br />
They have the following syntax:<br />
<br />
<nowiki>query:FEEDNAME:FILTER_EXPRESSION [TAG ...]</nowiki><br />
<br />
Like a normal feed, a query feed has a name, {{ic|FEEDNAME}}, which is displayed in the feedlist.<br />
The filter expression language for {{ic|FILTER_EXPRESSION}} is defined in the [https://newsboat.org/releases/2.13/docs/newsboat.html#_filter_language newsboat manual].<br />
Also like any normal feed, query feeds can be optionally tagged.<br />
<br />
Here are some examples:<br />
<br />
{{hc|~/.config/newsboat/urls|<br />
"query:Archlinux:tags # \"archlinux\""<br />
"query:Youtube:rssurl {{=}}~ \"youtube\""<br />
}}<br />
<br />
{{Note|The query feed must be encapsulated in double quotes. Therefore any other double quotes in its declaration must be escaped}}<br />
<br />
==== Unread articles ====<br />
<br />
To create a feed named {{ic|Unread Articles}} that contains all unread articles, define the following:<br />
<br />
{{hc|~/.config/newsboat/urls|<br />
"query:Unread Articles:unread {{=}} \"yes\""<br />
}}<br />
<br />
==== Amalgamating multiple feeds into one ====<br />
<br />
A good use of query feeds is when you're following a creator whose content is spread across multiple feeds. You can use a query feed to amalgamate all his content into one place.<br />
<br />
{{hc|~/.config/newsboat/urls|<br />
"query:Metafeed:tags # \"metafeed\""<nowiki><br />
https://feed.url/1 metafeed !<br />
https://feed.url/2 metafeed !<br />
https://feed.url/3 metafeed !<br />
</nowiki>}}<br />
<br />
The trick is to assign each feed a unique tag - here {{ic|metafeed}} - so that we can match against it in the filter expression. We also make use of [[#Hidden feeds]] - the {{ic|!}} at the end of each feed - so that the individual feeds don't show up in feedlist.<br />
<br />
==== Filtering a specific feed ====<br />
<br />
If a feed contains content you don't want to see, you can filter it by using a query feed.<br />
For example, to monitor updates of the arch kernel, you could use the following:<br />
<br />
{{hc|~/.config/newsboat/urls|<br />
"query:Kernel:(tags # \"archkernel\") and (title {{=}}~ \"linux$\")"<br />
<nowiki>https://archlinux.org/feeds/packages/</nowiki> archkernel !<br />
}}<br />
<br />
=== Ignoring articles ===<br />
<br />
There are two ways to ignore articles, delete them or not show them.<br />
{{hc|~/.newsboat/config|<br />
# ignore-mode "download" # Default: Delete them.<br />
ignore-mode "display" # Do not show them.<br />
}}<br />
The filter can be configured like so (here in POSIX extended regular expressions):<br />
{{hc|~/.newsboat/config|<nowiki><br />
ignore-article "https://feed/url" "content =~ \"tele(phone|communications)\"" <br />
ignore-article "https://feed/url" "title =~ \"text_1|text_2\""<br />
</nowiki>}}<br />
<br />
== Configuration ==<br />
<br />
Several aspects of Newsboat’s behaviour can be configured via a configuration file which is located, by default, in {{ic|~/.newsboat/config}} or {{ic|~/.config/newsboat/config}}. This configuration file contains lines of the form:<br />
<br />
<config-command> <arg1> ...<br />
<br />
=== Color schemes ===<br />
<br />
The package ships with a number of schemes in {{ic|/usr/share/doc/newsboat/contrib/colorschemes/}} which can be loaded with the include command like so:<br />
include /usr/share/doc/newsboat/contrib/colorschemes/inkpot<br />
<br />
=== Additional options ===<br />
<br />
The configuration file can also contain comments, which start with the {{ic|#}} character and go as far as the end of line. To enter a configuration argument that contains spaces, use quotes {{ic|"}} around the whole argument. It’s even possible to integrate the output of external commands into the configuration. The text between two backticks {{ic|`}} is evaluated as shell command, and its output is put on its place instead. This works like backtick evaluation in Bourne-compatible shells and allows users to use external information from the system within the configuration.<br />
<br />
See [https://gist.github.com/anonymous/42d2f5956e7bc8ee1ebc] and [http://moparx.com/configs/newsbeuter/] for example configurations.<br />
<br />
{{Note|To see a complete list of configuration command, consult {{man|1|newsboat|CONFIGURATION COMMANDS}}.}}<br />
<br />
== Tips ==<br />
<br />
=== Automatic feed reloads ===<br />
<br />
Newsboat can automatically reload all feeds on startup with the following configuration:<br />
<br />
auto-reload yes<br />
<br />
With this setting, Newsboat also runs periodic auto-reloads – by default, every 60 minutes. The number of minutes between automatic reloads can be configured like so:<br />
<br />
reload-time <desired number of minutes><br />
<br />
Alternatively, use [[cron]] or [[systemd]] to automatically reload feeds. Just add a line in your crontab, or create a systemd service/timer unit combo that issues the following command:<br />
<br />
/usr/bin/newsboat -x reload<br />
<br />
=== Loading of feeds in parallel for faster updates ===<br />
<br />
By default, Newsboat will attempt to update entries in {{ic|~/.newsboat/urls}} in sequence; however, the following setting will update them n at a time, in parallel. Adjust n to your liking.<br />
<br />
reload-threads 100<br />
<br />
=== Pass article URL to external command ===<br />
<br />
A clever little hack allows one to pass the URL of an article to an external command. The idea is to use a macro to set the browser that Newsboat opens the article with to the path of some other command and then change it back afterwards.<br />
<br />
For example, subscribers of a particular youtube channel can open the video with [[mpv]], by doing the following:<br />
<br />
macro y set browser "mpv %u" ; open-in-browser ; set browser "elinks %u"<br />
<br />
{{Note| First press the {{ic|,}} key, followed by the keybind to use the macro. In the example above, type {{ic|,}} + {{ic|y}} }}<br />
<br />
=== Subheadings ===<br />
<br />
There is another little hack that allows the user to add subheadings to sort feeds more effectively. This hack involves adding fake feeds to the {{ic|urls}} file like so:<br />
<br />
---Heading---<br />
<br />
{{Note|the {{ic|---}} characters are optional but having some sort of character identifying the headings is useful for styling.}}<br />
<br />
Then in {{ic|~/.config/newsboat/config}}, add the following two lines:<br />
<br />
highlight feedlist "---.*---" ''COLOR_OF_YOUR_CHOOSING'' default bold<br />
highlight feedlist ".*0/0.." default default invis<br />
<br />
Of course, replace {{ic|''COLOR_OF_YOUR_CHOOSING''}} with a [https://newsboat.org/releases/2.24/docs/newsboat.html#_configuring_colors newsboat supported color].<br />
<br />
This trick can also interact with Tags by replacing {{ic|---Heading---}} with:<br />
<br />
"query:---Heading---:tags # \"Tag\""<br />
<br />
Then tagging all the feeds below the heading with {{ic|Tag}}.<br />
<br />
== Troubleshooting ==<br />
<br />
=== Newsboat will not start ===<br />
<br />
Newsboat cannot start without any configured feeds! To add URLs, see [[#Managing feeds]]. If that is not the problem, check to see if another instance of Newsboat is running. Newsboat issues a lock on its database so that only one instance can access it at a time; thus, attempting to open a second instance will fail.<br />
<br />
== See Also ==<br />
<br />
*[https://newsboat.org/ Official web site]<br />
*[https://newsboat.org/releases/2.24/docs/newsboat.html Full documentation]<br />
*[https://sanctum.geek.nz/arabesque/rss-with-newsboat/ Arabesque: RSS with Newsboat]</div>Captaincurriehttps://wiki.archlinux.org/index.php?title=Newsboat&diff=765988Newsboat2023-02-01T01:13:28Z<p>Captaincurrie: formatting</p>
<hr />
<div>[[Category:News aggregators]]<br />
[[Category:Console applications]]<br />
[[ja:Newsboat]]<br />
{{Related articles start}}<br />
{{Related|Web feed}}<br />
{{Related articles end}}<br />
<br />
[https://newsboat.org/ Newsboat] is an open source news aggregator licensed under the MIT License.<br />
<br />
From {{man|1|newsboat|DESCRIPTION}}:<br />
<br />
:Newsboat is an RSS/Atom feed reader for text terminals. RSS and Atom are a number of widely-used XML formats to transmit, publish and syndicate articles, for example news or blog articles. Newsboat is designed to be used on text terminals on Unix or Unix-like systems such as GNU/Linux, BSD or macOS. <br />
<br />
Newsboat is a [https://groups.google.com/forum/#!topic/newsbeuter/RPtlWX8CPGU fork] of abandoned Newsbeuter.<br />
<br />
== Installation ==<br />
<br />
Install the {{Pkg|newsboat}} package. For the development version, install the {{AUR|newsboat-git}} package.<br />
<br />
== Usage ==<br />
<br />
Newsboat cannot start without any configured feeds. Feeds can be configured in {{ic|~/.newsboat/urls}}. Newsboat can be started from the command line with<br />
<br />
$ newsboat<br />
<br />
Press the {{ic|?}} key to see a list of all keybindings. Keybindings can be rebound, see [[#Configuration]].<br />
<br />
== Managing feeds ==<br />
<br />
Adding, removing, and tagging feeds is done by editing the urls file. By default that is {{ic|~/.newsboat/urls}}.<br />
{{Tip|In addition to newsboat specific feeds in this section, be sure to see the [[Web feed]] article for additional options.}}<br />
<br />
=== RSS or ATOM sources ===<br />
<br />
To add URLs, open {{ic|~/.newsboat/urls}} with your favorite text editor and add the URLs, one per line:<br />
<br />
<nowiki>http://rss.cnn.com/rss/cnn_topstories.rss</nowiki><br />
<nowiki>http://newsrss.bbc.co.uk/rss/newsonline_world_edition/front_page/rss.xml</nowiki><br />
<br />
To add URLs that have restricted access via username/password, simply provide the username/password in the following way:<br />
<br />
<nowiki>http://username:password@hostname.domain.tld/feed.rss</nowiki><br />
<br />
In order to protect username and password, make sure that {{ic|~/.newsboat/urls}} has the appropriate permissions. Newsboat also makes sure that usernames and passwords within URLs aren’t displayed in its user interface. In case there is a @ in the username, type it as %40 instead so that it can be distinguished from the @ that separates the username/password part from the hostname part.<br />
<br />
To configure local files as feeds, simply prefix the local path with {{ic|file://}} and add it to the {{ic|~/.newsboat/urls}} file:<br />
file:///var/log/rss_eventlog.xml<br />
<br />
=== HTML as a source ===<br />
<br />
If HTML sources can be converted to RSS via a user supplied script, newboat can both execute this script and consume the output.<br />
<br />
This is accomplished by using the {{ic|filter:}} prefix in the configuration file. For example, write a script that can read HTML from stdin and print out an RSS or Atom feed to stdout. Save that script to {{ic|~/.newsboat/html2rss.sh}} and add the following line to the {{ic|urls}}:<br />
<nowiki>filter:~/.newsboat/html2rss.sh:https://myurl.com</nowiki><br />
<br />
* For several examples using this strategy, see [https://github.com/graysky2/newsboat_custom_stuff graysky's newsboat repo].<br />
* For more discussion, see [https://github.com/newsboat/newsboat/issues/1157 Possible to config newsboat to look at a web exposed directory and report changes #1157].<br />
<br />
=== Tagging feeds ===<br />
<br />
Every feed can be assigned 0 or more tags. This makes it easy to categorize your feeds as well as the ability to easily apply commands to multiple feeds at once.<br />
<br />
Usually, the {{ic|~/.newsboat/urls}} file contains one RSS feed URL per line. To assign a tag to an RSS feed, simply attach it as a single word, separated by blanks such as space or tab. If the tag needs to contain spaces, use quotes (") around the tag (see example below). An example may look like this:<br />
<nowiki>http://blog.fefe.de/rss.xml?html interesting conspiracy news "cool stuff"</nowiki><br />
<nowiki>http://rss.orf.at/news.xml news orf</nowiki><br />
<nowiki>http://www.heise.de/newsticker/heise.rdf news interesting</nowiki><br />
<br />
Starting Newsboat with this configuration, one can press {{ic|t}} to select a tag. Upon selecting the tag "news", one will see all three RSS feeds. Pressing {{ic|t}} again and e.g. selecting the "conspiracy" tag, will only show the {{ic|<nowiki>http://blog.fefe.de/rss.xml?html</nowiki>}} RSS feed. Pressing {{ic|Ctrl-T}} clears the current tag,<br />
and again shows all RSS feeds, regardless of their assigned tags.<br />
<br />
{{Note| If the tag name contains spaces, the tag must be bounded by {{ic|"}}}}<br />
<br />
==== Special tags ====<br />
<br />
===== Custom feed names =====<br />
<br />
The name of a feed can be defined with a special tag in your urls file. Simply '''prefix''' the tag name with the {{ic|~}} character and the tag name will become the feed name.<br />
<br />
For example:<br />
<br />
<nowiki>http://rss.cnn.com/rss/cnn_topstories.rss</nowiki> "~CNN Top stories"<br />
<br />
will define the feed with feed-name "CNN Top stories"<br />
<br />
===== Hidden feeds =====<br />
<br />
A feed can be '''hidden''' from the regular list of feeds by '''prefixing''' the tag name with an {{ic|!}}.<br />
<br />
For example:<br />
<nowiki>http://rss.orf.at/news.xml</nowiki> "!ORF News (hidden)"<br />
<br />
The content of a '''hidden''' feed can only be found through a query feed.<br />
<br />
=== Query feeds ===<br />
<br />
Custom feeds can be created from existing feeds by creating what's called a query feed: A feed generated by matching articles against a query. Query feeds are defined in your {{ic|~/.config/newsboat/urls}} file like a normal feed.<br />
They have the following syntax:<br />
<br />
<nowiki>query:FEEDNAME:FILTER_EXPRESSION [TAG ...]</nowiki><br />
<br />
Like a normal feed, a query feed has a name, {{ic|FEEDNAME}}, which is displayed in the feedlist.<br />
The filter expression language for {{ic|FILTER_EXPRESSION}} is defined in the [https://newsboat.org/releases/2.13/docs/newsboat.html#_filter_language newsboat manual].<br />
Also like any normal feed, query feeds can be optionally tagged.<br />
<br />
Here are some examples:<br />
<br />
{{hc|~/.config/newsboat/urls|<br />
"query:Archlinux:tags # \"archlinux\""<br />
"query:Youtube:rssurl {{=}}~ \"youtube\""<br />
}}<br />
<br />
{{Note|The query feed must be encapsulated in double quotes. Therefore any other double quotes in its declaration must be escaped}}<br />
<br />
==== Unread articles ====<br />
<br />
To create a feed named {{ic|Unread Articles}} that contains all unread articles, define the following:<br />
<br />
{{hc|~/.config/newsboat/urls|<br />
"query:Unread Articles:unread {{=}} \"yes\""<br />
}}<br />
<br />
==== Amalgamating multiple feeds into one ====<br />
<br />
A good use of query feeds is when you're following a creator whose content is spread across multiple feeds. You can use a query feed to amalgamate all his content into one place.<br />
<br />
{{hc|~/.config/newsboat/urls|<br />
"query:Metafeed:tags # \"metafeed\""<nowiki><br />
https://feed.url/1 metafeed !<br />
https://feed.url/2 metafeed !<br />
https://feed.url/3 metafeed !<br />
</nowiki>}}<br />
<br />
The trick is to assign each feed a unique tag - here {{ic|metafeed}} - so that we can match against it in the filter expression. We also make use of [[#Hidden feeds]] - the {{ic|!}} at the end of each feed - so that the individual feeds don't show up in feedlist.<br />
<br />
==== Filtering a specific feed ====<br />
<br />
If a feed contains content you don't want to see, you can filter it out by using a query feed.<br />
For example, to monitor updates to the arch kernel, you could use the following:<br />
<br />
{{hc|~/.config/newsboat/urls|<br />
"query:Kernel:(tags # \"archkernel\") and (title {{=}}~ \"linux$\")"<br />
<nowiki>https://archlinux.org/feeds/packages/</nowiki> archkernel !<br />
}}<br />
<br />
=== Ignoring articles ===<br />
<br />
There are two ways to ignore articles, delete them or not show them.<br />
{{hc|~/.newsboat/config|<br />
# ignore-mode "download" # Default: Delete them.<br />
ignore-mode "display" # Do not show them.<br />
}}<br />
The filter can be configured like so (here in POSIX extended regular expressions):<br />
{{hc|~/.newsboat/config|<nowiki><br />
ignore-article "https://feed/url" "content =~ \"tele(phone|communications)\"" <br />
ignore-article "https://feed/url" "title =~ \"text_1|text_2\""<br />
</nowiki>}}<br />
<br />
== Configuration ==<br />
<br />
Several aspects of Newsboat’s behaviour can be configured via a configuration file which is located, by default, in {{ic|~/.newsboat/config}} or {{ic|~/.config/newsboat/config}}. This configuration file contains lines of the form:<br />
<br />
<config-command> <arg1> ...<br />
<br />
=== Color schemes ===<br />
<br />
The package ships with a number of schemes in {{ic|/usr/share/doc/newsboat/contrib/colorschemes/}} which can be loaded with the include command like so:<br />
include /usr/share/doc/newsboat/contrib/colorschemes/inkpot<br />
<br />
=== Additional options ===<br />
<br />
The configuration file can also contain comments, which start with the {{ic|#}} character and go as far as the end of line. To enter a configuration argument that contains spaces, use quotes {{ic|"}} around the whole argument. It’s even possible to integrate the output of external commands into the configuration. The text between two backticks {{ic|`}} is evaluated as shell command, and its output is put on its place instead. This works like backtick evaluation in Bourne-compatible shells and allows users to use external information from the system within the configuration.<br />
<br />
See [https://gist.github.com/anonymous/42d2f5956e7bc8ee1ebc] and [http://moparx.com/configs/newsbeuter/] for example configurations.<br />
<br />
{{Note|To see a complete list of configuration command, consult {{man|1|newsboat|CONFIGURATION COMMANDS}}.}}<br />
<br />
== Tips ==<br />
<br />
=== Automatic feed reloads ===<br />
<br />
Newsboat can automatically reload all feeds on startup with the following configuration:<br />
<br />
auto-reload yes<br />
<br />
With this setting, Newsboat also runs periodic auto-reloads – by default, every 60 minutes. The number of minutes between automatic reloads can be configured like so:<br />
<br />
reload-time <desired number of minutes><br />
<br />
Alternatively, use [[cron]] or [[systemd]] to automatically reload feeds. Just add a line in your crontab, or create a systemd service/timer unit combo that issues the following command:<br />
<br />
/usr/bin/newsboat -x reload<br />
<br />
=== Loading of feeds in parallel for faster updates ===<br />
<br />
By default, Newsboat will attempt to update entries in {{ic|~/.newsboat/urls}} in sequence; however, the following setting will update them n at a time, in parallel. Adjust n to your liking.<br />
<br />
reload-threads 100<br />
<br />
=== Pass article URL to external command ===<br />
<br />
A clever little hack allows one to pass the URL of an article to an external command. The idea is to use a macro to set the browser that Newsboat opens the article with to the path of some other command and then change it back afterwards.<br />
<br />
For example, subscribers of a particular youtube channel can open the video with [[mpv]], by doing the following:<br />
<br />
macro y set browser "mpv %u" ; open-in-browser ; set browser "elinks %u"<br />
<br />
{{Note| First press the {{ic|,}} key, followed by the keybind to use the macro. In the example above, type {{ic|,}} + {{ic|y}} }}<br />
<br />
=== Subheadings ===<br />
<br />
There is another little hack that allows the user to add subheadings to sort feeds more effectively. This hack involves adding fake feeds to the {{ic|urls}} file like so:<br />
<br />
---Heading---<br />
<br />
{{Note|the {{ic|---}} characters are optional but having some sort of character identifying the headings is useful for styling.}}<br />
<br />
Then in {{ic|~/.config/newsboat/config}}, add the following two lines:<br />
<br />
highlight feedlist "---.*---" ''COLOR_OF_YOUR_CHOOSING'' default bold<br />
highlight feedlist ".*0/0.." default default invis<br />
<br />
Of course, replace {{ic|''COLOR_OF_YOUR_CHOOSING''}} with a [https://newsboat.org/releases/2.24/docs/newsboat.html#_configuring_colors newsboat supported color].<br />
<br />
This trick can also interact with Tags by replacing {{ic|---Heading---}} with:<br />
<br />
"query:---Heading---:tags # \"Tag\""<br />
<br />
Then tagging all the feeds below the heading with {{ic|Tag}}.<br />
<br />
== Troubleshooting ==<br />
<br />
=== Newsboat will not start ===<br />
<br />
Newsboat cannot start without any configured feeds! To add URLs, see [[#Managing feeds]]. If that is not the problem, check to see if another instance of Newsboat is running. Newsboat issues a lock on its database so that only one instance can access it at a time; thus, attempting to open a second instance will fail.<br />
<br />
== See Also ==<br />
<br />
*[https://newsboat.org/ Official web site]<br />
*[https://newsboat.org/releases/2.24/docs/newsboat.html Full documentation]<br />
*[https://sanctum.geek.nz/arabesque/rss-with-newsboat/ Arabesque: RSS with Newsboat]</div>Captaincurriehttps://wiki.archlinux.org/index.php?title=Newsboat&diff=765987Newsboat2023-02-01T01:12:48Z<p>Captaincurrie: Added a section to query feeds about using them to filter existing feeds</p>
<hr />
<div>[[Category:News aggregators]]<br />
[[Category:Console applications]]<br />
[[ja:Newsboat]]<br />
{{Related articles start}}<br />
{{Related|Web feed}}<br />
{{Related articles end}}<br />
<br />
[https://newsboat.org/ Newsboat] is an open source news aggregator licensed under the MIT License.<br />
<br />
From {{man|1|newsboat|DESCRIPTION}}:<br />
<br />
:Newsboat is an RSS/Atom feed reader for text terminals. RSS and Atom are a number of widely-used XML formats to transmit, publish and syndicate articles, for example news or blog articles. Newsboat is designed to be used on text terminals on Unix or Unix-like systems such as GNU/Linux, BSD or macOS. <br />
<br />
Newsboat is a [https://groups.google.com/forum/#!topic/newsbeuter/RPtlWX8CPGU fork] of abandoned Newsbeuter.<br />
<br />
== Installation ==<br />
<br />
Install the {{Pkg|newsboat}} package. For the development version, install the {{AUR|newsboat-git}} package.<br />
<br />
== Usage ==<br />
<br />
Newsboat cannot start without any configured feeds. Feeds can be configured in {{ic|~/.newsboat/urls}}. Newsboat can be started from the command line with<br />
<br />
$ newsboat<br />
<br />
Press the {{ic|?}} key to see a list of all keybindings. Keybindings can be rebound, see [[#Configuration]].<br />
<br />
== Managing feeds ==<br />
<br />
Adding, removing, and tagging feeds is done by editing the urls file. By default that is {{ic|~/.newsboat/urls}}.<br />
{{Tip|In addition to newsboat specific feeds in this section, be sure to see the [[Web feed]] article for additional options.}}<br />
<br />
=== RSS or ATOM sources ===<br />
<br />
To add URLs, open {{ic|~/.newsboat/urls}} with your favorite text editor and add the URLs, one per line:<br />
<br />
<nowiki>http://rss.cnn.com/rss/cnn_topstories.rss</nowiki><br />
<nowiki>http://newsrss.bbc.co.uk/rss/newsonline_world_edition/front_page/rss.xml</nowiki><br />
<br />
To add URLs that have restricted access via username/password, simply provide the username/password in the following way:<br />
<br />
<nowiki>http://username:password@hostname.domain.tld/feed.rss</nowiki><br />
<br />
In order to protect username and password, make sure that {{ic|~/.newsboat/urls}} has the appropriate permissions. Newsboat also makes sure that usernames and passwords within URLs aren’t displayed in its user interface. In case there is a @ in the username, type it as %40 instead so that it can be distinguished from the @ that separates the username/password part from the hostname part.<br />
<br />
To configure local files as feeds, simply prefix the local path with {{ic|file://}} and add it to the {{ic|~/.newsboat/urls}} file:<br />
file:///var/log/rss_eventlog.xml<br />
<br />
=== HTML as a source ===<br />
<br />
If HTML sources can be converted to RSS via a user supplied script, newboat can both execute this script and consume the output.<br />
<br />
This is accomplished by using the {{ic|filter:}} prefix in the configuration file. For example, write a script that can read HTML from stdin and print out an RSS or Atom feed to stdout. Save that script to {{ic|~/.newsboat/html2rss.sh}} and add the following line to the {{ic|urls}}:<br />
<nowiki>filter:~/.newsboat/html2rss.sh:https://myurl.com</nowiki><br />
<br />
* For several examples using this strategy, see [https://github.com/graysky2/newsboat_custom_stuff graysky's newsboat repo].<br />
* For more discussion, see [https://github.com/newsboat/newsboat/issues/1157 Possible to config newsboat to look at a web exposed directory and report changes #1157].<br />
<br />
=== Tagging feeds ===<br />
<br />
Every feed can be assigned 0 or more tags. This makes it easy to categorize your feeds as well as the ability to easily apply commands to multiple feeds at once.<br />
<br />
Usually, the {{ic|~/.newsboat/urls}} file contains one RSS feed URL per line. To assign a tag to an RSS feed, simply attach it as a single word, separated by blanks such as space or tab. If the tag needs to contain spaces, use quotes (") around the tag (see example below). An example may look like this:<br />
<nowiki>http://blog.fefe.de/rss.xml?html interesting conspiracy news "cool stuff"</nowiki><br />
<nowiki>http://rss.orf.at/news.xml news orf</nowiki><br />
<nowiki>http://www.heise.de/newsticker/heise.rdf news interesting</nowiki><br />
<br />
Starting Newsboat with this configuration, one can press {{ic|t}} to select a tag. Upon selecting the tag "news", one will see all three RSS feeds. Pressing {{ic|t}} again and e.g. selecting the "conspiracy" tag, will only show the {{ic|<nowiki>http://blog.fefe.de/rss.xml?html</nowiki>}} RSS feed. Pressing {{ic|Ctrl-T}} clears the current tag,<br />
and again shows all RSS feeds, regardless of their assigned tags.<br />
<br />
{{Note| If the tag name contains spaces, the tag must be bounded by {{ic|"}}}}<br />
<br />
==== Special tags ====<br />
<br />
===== Custom feed names =====<br />
<br />
The name of a feed can be defined with a special tag in your urls file. Simply '''prefix''' the tag name with the {{ic|~}} character and the tag name will become the feed name.<br />
<br />
For example:<br />
<br />
<nowiki>http://rss.cnn.com/rss/cnn_topstories.rss</nowiki> "~CNN Top stories"<br />
<br />
will define the feed with feed-name "CNN Top stories"<br />
<br />
===== Hidden feeds =====<br />
<br />
A feed can be '''hidden''' from the regular list of feeds by '''prefixing''' the tag name with an {{ic|!}}.<br />
<br />
For example:<br />
<nowiki>http://rss.orf.at/news.xml</nowiki> "!ORF News (hidden)"<br />
<br />
The content of a '''hidden''' feed can only be found through a query feed.<br />
<br />
=== Query feeds ===<br />
<br />
Custom feeds can be created from existing feeds by creating what's called a query feed: A feed generated by matching articles against a query. Query feeds are defined in your {{ic|~/.config/newsboat/urls}} file like a normal feed.<br />
They have the following syntax:<br />
<br />
<nowiki>query:FEEDNAME:FILTER_EXPRESSION [TAG ...]</nowiki><br />
<br />
Like a normal feed, a query feed has a name, {{ic|FEEDNAME}}, which is displayed in the feedlist.<br />
The filter expression language for {{ic|FILTER_EXPRESSION}} is defined in the [https://newsboat.org/releases/2.13/docs/newsboat.html#_filter_language newsboat manual].<br />
Also like any normal feed, query feeds can be optionally tagged.<br />
<br />
Here are some examples:<br />
<br />
{{hc|~/.config/newsboat/urls|<br />
"query:Archlinux:tags # \"archlinux\""<br />
"query:Youtube:rssurl {{=}}~ \"youtube\""<br />
}}<br />
<br />
{{Note|The query feed must be encapsulated in double quotes. Therefore any other double quotes in its declaration must be escaped}}<br />
<br />
==== Unread articles ====<br />
<br />
To create a feed named {{ic|Unread Articles}} that contains all unread articles, define the following:<br />
<br />
{{hc|~/.config/newsboat/urls|<br />
"query:Unread Articles:unread {{=}} \"yes\""<br />
}}<br />
<br />
==== Amalgamating multiple feeds into one ====<br />
<br />
A good use of query feeds is when you're following a creator whose content is spread across multiple feeds. You can use a query feed to amalgamate all his content into one place.<br />
<br />
{{hc|~/.config/newsboat/urls|<br />
"query:Metafeed:tags # \"metafeed\""<nowiki><br />
https://feed.url/1 metafeed !<br />
https://feed.url/2 metafeed !<br />
https://feed.url/3 metafeed !<br />
</nowiki>}}<br />
<br />
The trick is to assign each feed a unique tag - here {{ic|metafeed}} - so that we can match against it in the filter expression. We also make use of [[#Hidden feeds]] - the {{ic|!}} at the end of each feed - so that the individual feeds don't show up in feedlist.<br />
<br />
==== Filtering a specific feed ====<br />
<br />
If a feed contains content you don't want to see, you can filter it out by using a query feed.<br />
For example, to monitor updates to the arch kernel, you could use the following:<br />
<br />
{{hc|~/.config/newsboat/urls|<br />
"query:Kernel:(tags # \"archkernel\") and (title {{=}}~ \"linux$\")"<br />
https://archlinux.org/feeds/packages/ archkernel !<br />
}}<br />
<br />
=== Ignoring articles ===<br />
<br />
There are two ways to ignore articles, delete them or not show them.<br />
{{hc|~/.newsboat/config|<br />
# ignore-mode "download" # Default: Delete them.<br />
ignore-mode "display" # Do not show them.<br />
}}<br />
The filter can be configured like so (here in POSIX extended regular expressions):<br />
{{hc|~/.newsboat/config|<nowiki><br />
ignore-article "https://feed/url" "content =~ \"tele(phone|communications)\"" <br />
ignore-article "https://feed/url" "title =~ \"text_1|text_2\""<br />
</nowiki>}}<br />
<br />
== Configuration ==<br />
<br />
Several aspects of Newsboat’s behaviour can be configured via a configuration file which is located, by default, in {{ic|~/.newsboat/config}} or {{ic|~/.config/newsboat/config}}. This configuration file contains lines of the form:<br />
<br />
<config-command> <arg1> ...<br />
<br />
=== Color schemes ===<br />
<br />
The package ships with a number of schemes in {{ic|/usr/share/doc/newsboat/contrib/colorschemes/}} which can be loaded with the include command like so:<br />
include /usr/share/doc/newsboat/contrib/colorschemes/inkpot<br />
<br />
=== Additional options ===<br />
<br />
The configuration file can also contain comments, which start with the {{ic|#}} character and go as far as the end of line. To enter a configuration argument that contains spaces, use quotes {{ic|"}} around the whole argument. It’s even possible to integrate the output of external commands into the configuration. The text between two backticks {{ic|`}} is evaluated as shell command, and its output is put on its place instead. This works like backtick evaluation in Bourne-compatible shells and allows users to use external information from the system within the configuration.<br />
<br />
See [https://gist.github.com/anonymous/42d2f5956e7bc8ee1ebc] and [http://moparx.com/configs/newsbeuter/] for example configurations.<br />
<br />
{{Note|To see a complete list of configuration command, consult {{man|1|newsboat|CONFIGURATION COMMANDS}}.}}<br />
<br />
== Tips ==<br />
<br />
=== Automatic feed reloads ===<br />
<br />
Newsboat can automatically reload all feeds on startup with the following configuration:<br />
<br />
auto-reload yes<br />
<br />
With this setting, Newsboat also runs periodic auto-reloads – by default, every 60 minutes. The number of minutes between automatic reloads can be configured like so:<br />
<br />
reload-time <desired number of minutes><br />
<br />
Alternatively, use [[cron]] or [[systemd]] to automatically reload feeds. Just add a line in your crontab, or create a systemd service/timer unit combo that issues the following command:<br />
<br />
/usr/bin/newsboat -x reload<br />
<br />
=== Loading of feeds in parallel for faster updates ===<br />
<br />
By default, Newsboat will attempt to update entries in {{ic|~/.newsboat/urls}} in sequence; however, the following setting will update them n at a time, in parallel. Adjust n to your liking.<br />
<br />
reload-threads 100<br />
<br />
=== Pass article URL to external command ===<br />
<br />
A clever little hack allows one to pass the URL of an article to an external command. The idea is to use a macro to set the browser that Newsboat opens the article with to the path of some other command and then change it back afterwards.<br />
<br />
For example, subscribers of a particular youtube channel can open the video with [[mpv]], by doing the following:<br />
<br />
macro y set browser "mpv %u" ; open-in-browser ; set browser "elinks %u"<br />
<br />
{{Note| First press the {{ic|,}} key, followed by the keybind to use the macro. In the example above, type {{ic|,}} + {{ic|y}} }}<br />
<br />
=== Subheadings ===<br />
<br />
There is another little hack that allows the user to add subheadings to sort feeds more effectively. This hack involves adding fake feeds to the {{ic|urls}} file like so:<br />
<br />
---Heading---<br />
<br />
{{Note|the {{ic|---}} characters are optional but having some sort of character identifying the headings is useful for styling.}}<br />
<br />
Then in {{ic|~/.config/newsboat/config}}, add the following two lines:<br />
<br />
highlight feedlist "---.*---" ''COLOR_OF_YOUR_CHOOSING'' default bold<br />
highlight feedlist ".*0/0.." default default invis<br />
<br />
Of course, replace {{ic|''COLOR_OF_YOUR_CHOOSING''}} with a [https://newsboat.org/releases/2.24/docs/newsboat.html#_configuring_colors newsboat supported color].<br />
<br />
This trick can also interact with Tags by replacing {{ic|---Heading---}} with:<br />
<br />
"query:---Heading---:tags # \"Tag\""<br />
<br />
Then tagging all the feeds below the heading with {{ic|Tag}}.<br />
<br />
== Troubleshooting ==<br />
<br />
=== Newsboat will not start ===<br />
<br />
Newsboat cannot start without any configured feeds! To add URLs, see [[#Managing feeds]]. If that is not the problem, check to see if another instance of Newsboat is running. Newsboat issues a lock on its database so that only one instance can access it at a time; thus, attempting to open a second instance will fail.<br />
<br />
== See Also ==<br />
<br />
*[https://newsboat.org/ Official web site]<br />
*[https://newsboat.org/releases/2.24/docs/newsboat.html Full documentation]<br />
*[https://sanctum.geek.nz/arabesque/rss-with-newsboat/ Arabesque: RSS with Newsboat]</div>Captaincurriehttps://wiki.archlinux.org/index.php?title=Newsboat&diff=765986Newsboat2023-02-01T00:57:17Z<p>Captaincurrie: formatting</p>
<hr />
<div>[[Category:News aggregators]]<br />
[[Category:Console applications]]<br />
[[ja:Newsboat]]<br />
{{Related articles start}}<br />
{{Related|Web feed}}<br />
{{Related articles end}}<br />
<br />
[https://newsboat.org/ Newsboat] is an open source news aggregator licensed under the MIT License.<br />
<br />
From {{man|1|newsboat|DESCRIPTION}}:<br />
<br />
:Newsboat is an RSS/Atom feed reader for text terminals. RSS and Atom are a number of widely-used XML formats to transmit, publish and syndicate articles, for example news or blog articles. Newsboat is designed to be used on text terminals on Unix or Unix-like systems such as GNU/Linux, BSD or macOS. <br />
<br />
Newsboat is a [https://groups.google.com/forum/#!topic/newsbeuter/RPtlWX8CPGU fork] of abandoned Newsbeuter.<br />
<br />
== Installation ==<br />
<br />
Install the {{Pkg|newsboat}} package. For the development version, install the {{AUR|newsboat-git}} package.<br />
<br />
== Usage ==<br />
<br />
Newsboat cannot start without any configured feeds. Feeds can be configured in {{ic|~/.newsboat/urls}}. Newsboat can be started from the command line with<br />
<br />
$ newsboat<br />
<br />
Press the {{ic|?}} key to see a list of all keybindings. Keybindings can be rebound, see [[#Configuration]].<br />
<br />
== Managing feeds ==<br />
<br />
Adding, removing, and tagging feeds is done by editing the urls file. By default that is {{ic|~/.newsboat/urls}}.<br />
{{Tip|In addition to newsboat specific feeds in this section, be sure to see the [[Web feed]] article for additional options.}}<br />
<br />
=== RSS or ATOM sources ===<br />
<br />
To add URLs, open {{ic|~/.newsboat/urls}} with your favorite text editor and add the URLs, one per line:<br />
<br />
<nowiki>http://rss.cnn.com/rss/cnn_topstories.rss</nowiki><br />
<nowiki>http://newsrss.bbc.co.uk/rss/newsonline_world_edition/front_page/rss.xml</nowiki><br />
<br />
To add URLs that have restricted access via username/password, simply provide the username/password in the following way:<br />
<br />
<nowiki>http://username:password@hostname.domain.tld/feed.rss</nowiki><br />
<br />
In order to protect username and password, make sure that {{ic|~/.newsboat/urls}} has the appropriate permissions. Newsboat also makes sure that usernames and passwords within URLs aren’t displayed in its user interface. In case there is a @ in the username, type it as %40 instead so that it can be distinguished from the @ that separates the username/password part from the hostname part.<br />
<br />
To configure local files as feeds, simply prefix the local path with {{ic|file://}} and add it to the {{ic|~/.newsboat/urls}} file:<br />
file:///var/log/rss_eventlog.xml<br />
<br />
=== HTML as a source ===<br />
<br />
If HTML sources can be converted to RSS via a user supplied script, newboat can both execute this script and consume the output.<br />
<br />
This is accomplished by using the {{ic|filter:}} prefix in the configuration file. For example, write a script that can read HTML from stdin and print out an RSS or Atom feed to stdout. Save that script to {{ic|~/.newsboat/html2rss.sh}} and add the following line to the {{ic|urls}}:<br />
<nowiki>filter:~/.newsboat/html2rss.sh:https://myurl.com</nowiki><br />
<br />
* For several examples using this strategy, see [https://github.com/graysky2/newsboat_custom_stuff graysky's newsboat repo].<br />
* For more discussion, see [https://github.com/newsboat/newsboat/issues/1157 Possible to config newsboat to look at a web exposed directory and report changes #1157].<br />
<br />
=== Tagging feeds ===<br />
<br />
Every feed can be assigned 0 or more tags. This makes it easy to categorize your feeds as well as the ability to easily apply commands to multiple feeds at once.<br />
<br />
Usually, the {{ic|~/.newsboat/urls}} file contains one RSS feed URL per line. To assign a tag to an RSS feed, simply attach it as a single word, separated by blanks such as space or tab. If the tag needs to contain spaces, use quotes (") around the tag (see example below). An example may look like this:<br />
<nowiki>http://blog.fefe.de/rss.xml?html interesting conspiracy news "cool stuff"</nowiki><br />
<nowiki>http://rss.orf.at/news.xml news orf</nowiki><br />
<nowiki>http://www.heise.de/newsticker/heise.rdf news interesting</nowiki><br />
<br />
Starting Newsboat with this configuration, one can press {{ic|t}} to select a tag. Upon selecting the tag "news", one will see all three RSS feeds. Pressing {{ic|t}} again and e.g. selecting the "conspiracy" tag, will only show the {{ic|<nowiki>http://blog.fefe.de/rss.xml?html</nowiki>}} RSS feed. Pressing {{ic|Ctrl-T}} clears the current tag,<br />
and again shows all RSS feeds, regardless of their assigned tags.<br />
<br />
{{Note| If the tag name contains spaces, the tag must be bounded by {{ic|"}}}}<br />
<br />
==== Special tags ====<br />
<br />
===== Custom feed names =====<br />
<br />
The name of a feed can be defined with a special tag in your urls file. Simply '''prefix''' the tag name with the {{ic|~}} character and the tag name will become the feed name.<br />
<br />
For example:<br />
<br />
<nowiki>http://rss.cnn.com/rss/cnn_topstories.rss</nowiki> "~CNN Top stories"<br />
<br />
will define the feed with feed-name "CNN Top stories"<br />
<br />
===== Hidden feeds =====<br />
<br />
A feed can be '''hidden''' from the regular list of feeds by '''prefixing''' the tag name with an {{ic|!}}.<br />
<br />
For example:<br />
<nowiki>http://rss.orf.at/news.xml</nowiki> "!ORF News (hidden)"<br />
<br />
The content of a '''hidden''' feed can only be found through a query feed.<br />
<br />
=== Query feeds ===<br />
<br />
Custom feeds can be created from existing feeds by creating what's called a query feed: A feed generated by matching articles against a query. Query feeds are defined in your {{ic|~/.config/newsboat/urls}} file like a normal feed.<br />
They have the following syntax:<br />
<br />
<nowiki>query:FEEDNAME:FILTER_EXPRESSION [TAG ...]</nowiki><br />
<br />
Like a normal feed, a query feed has a name, {{ic|FEEDNAME}}, which is displayed in the feedlist.<br />
The filter expression language for {{ic|FILTER_EXPRESSION}} is defined in the [https://newsboat.org/releases/2.13/docs/newsboat.html#_filter_language newsboat manual].<br />
Also like any normal feed, query feeds can be optionally tagged.<br />
<br />
Here are some examples:<br />
<br />
{{hc|~/.config/newsboat/urls|<br />
"query:Archlinux:tags # \"archlinux\""<br />
"query:Youtube:rssurl {{=}}~ \"youtube\""<br />
}}<br />
<br />
{{Note|The query feed must be encapsulated in double quotes. Therefore any other double quotes in its declaration must be escaped}}<br />
<br />
==== Unread articles ====<br />
<br />
To create a feed named {{ic|Unread Articles}} that contains all unread articles, define the following:<br />
<br />
{{hc|~/.config/newsboat/urls|<br />
"query:Unread Articles:unread {{=}} \"yes\""<br />
}}<br />
<br />
==== Amalgamating multiple feeds into one ====<br />
<br />
A good use of query feeds is when you're following a creator whose content is spread across multiple feeds. You can use a query feed to amalgamate all his content into one place.<br />
<br />
{{hc|~/.config/newsboat/urls|<br />
"query:Metafeed:tags # \"metafeed\""<nowiki><br />
https://feed.url/1 metafeed !<br />
https://feed.url/2 metafeed !<br />
https://feed.url/3 metafeed !<br />
</nowiki>}}<br />
<br />
The trick is to assign each feed a unique tag - here {{ic|metafeed}} - so that we can match against it in the filter expression. We also make use of [[#Hidden feeds]] - the {{ic|!}} at the end of each feed - so that the individual feeds don't show up in feedlist.<br />
<br />
=== Ignoring articles ===<br />
<br />
There are two ways to ignore articles, delete them or not show them.<br />
{{hc|~/.newsboat/config|<br />
# ignore-mode "download" # Default: Delete them.<br />
ignore-mode "display" # Do not show them.<br />
}}<br />
The filter can be configured like so (here in POSIX extended regular expressions):<br />
{{hc|~/.newsboat/config|<nowiki><br />
ignore-article "https://feed/url" "content =~ \"tele(phone|communications)\"" <br />
ignore-article "https://feed/url" "title =~ \"text_1|text_2\""<br />
</nowiki>}}<br />
<br />
== Configuration ==<br />
<br />
Several aspects of Newsboat’s behaviour can be configured via a configuration file which is located, by default, in {{ic|~/.newsboat/config}} or {{ic|~/.config/newsboat/config}}. This configuration file contains lines of the form:<br />
<br />
<config-command> <arg1> ...<br />
<br />
=== Color schemes ===<br />
<br />
The package ships with a number of schemes in {{ic|/usr/share/doc/newsboat/contrib/colorschemes/}} which can be loaded with the include command like so:<br />
include /usr/share/doc/newsboat/contrib/colorschemes/inkpot<br />
<br />
=== Additional options ===<br />
<br />
The configuration file can also contain comments, which start with the {{ic|#}} character and go as far as the end of line. To enter a configuration argument that contains spaces, use quotes {{ic|"}} around the whole argument. It’s even possible to integrate the output of external commands into the configuration. The text between two backticks {{ic|`}} is evaluated as shell command, and its output is put on its place instead. This works like backtick evaluation in Bourne-compatible shells and allows users to use external information from the system within the configuration.<br />
<br />
See [https://gist.github.com/anonymous/42d2f5956e7bc8ee1ebc] and [http://moparx.com/configs/newsbeuter/] for example configurations.<br />
<br />
{{Note|To see a complete list of configuration command, consult {{man|1|newsboat|CONFIGURATION COMMANDS}}.}}<br />
<br />
== Tips ==<br />
<br />
=== Automatic feed reloads ===<br />
<br />
Newsboat can automatically reload all feeds on startup with the following configuration:<br />
<br />
auto-reload yes<br />
<br />
With this setting, Newsboat also runs periodic auto-reloads – by default, every 60 minutes. The number of minutes between automatic reloads can be configured like so:<br />
<br />
reload-time <desired number of minutes><br />
<br />
Alternatively, use [[cron]] or [[systemd]] to automatically reload feeds. Just add a line in your crontab, or create a systemd service/timer unit combo that issues the following command:<br />
<br />
/usr/bin/newsboat -x reload<br />
<br />
=== Loading of feeds in parallel for faster updates ===<br />
<br />
By default, Newsboat will attempt to update entries in {{ic|~/.newsboat/urls}} in sequence; however, the following setting will update them n at a time, in parallel. Adjust n to your liking.<br />
<br />
reload-threads 100<br />
<br />
=== Pass article URL to external command ===<br />
<br />
A clever little hack allows one to pass the URL of an article to an external command. The idea is to use a macro to set the browser that Newsboat opens the article with to the path of some other command and then change it back afterwards.<br />
<br />
For example, subscribers of a particular youtube channel can open the video with [[mpv]], by doing the following:<br />
<br />
macro y set browser "mpv %u" ; open-in-browser ; set browser "elinks %u"<br />
<br />
{{Note| First press the {{ic|,}} key, followed by the keybind to use the macro. In the example above, type {{ic|,}} + {{ic|y}} }}<br />
<br />
=== Subheadings ===<br />
<br />
There is another little hack that allows the user to add subheadings to sort feeds more effectively. This hack involves adding fake feeds to the {{ic|urls}} file like so:<br />
<br />
---Heading---<br />
<br />
{{Note|the {{ic|---}} characters are optional but having some sort of character identifying the headings is useful for styling.}}<br />
<br />
Then in {{ic|~/.config/newsboat/config}}, add the following two lines:<br />
<br />
highlight feedlist "---.*---" ''COLOR_OF_YOUR_CHOOSING'' default bold<br />
highlight feedlist ".*0/0.." default default invis<br />
<br />
Of course, replace {{ic|''COLOR_OF_YOUR_CHOOSING''}} with a [https://newsboat.org/releases/2.24/docs/newsboat.html#_configuring_colors newsboat supported color].<br />
<br />
This trick can also interact with Tags by replacing {{ic|---Heading---}} with:<br />
<br />
"query:---Heading---:tags # \"Tag\""<br />
<br />
Then tagging all the feeds below the heading with {{ic|Tag}}.<br />
<br />
== Troubleshooting ==<br />
<br />
=== Newsboat will not start ===<br />
<br />
Newsboat cannot start without any configured feeds! To add URLs, see [[#Managing feeds]]. If that is not the problem, check to see if another instance of Newsboat is running. Newsboat issues a lock on its database so that only one instance can access it at a time; thus, attempting to open a second instance will fail.<br />
<br />
== See Also ==<br />
<br />
*[https://newsboat.org/ Official web site]<br />
*[https://newsboat.org/releases/2.24/docs/newsboat.html Full documentation]<br />
*[https://sanctum.geek.nz/arabesque/rss-with-newsboat/ Arabesque: RSS with Newsboat]</div>Captaincurriehttps://wiki.archlinux.org/index.php?title=Newsboat&diff=765985Newsboat2023-02-01T00:56:02Z<p>Captaincurrie: moved the query feed section after the tagging feeds section</p>
<hr />
<div>[[Category:News aggregators]]<br />
[[Category:Console applications]]<br />
[[ja:Newsboat]]<br />
{{Related articles start}}<br />
{{Related|Web feed}}<br />
{{Related articles end}}<br />
<br />
[https://newsboat.org/ Newsboat] is an open source news aggregator licensed under the MIT License.<br />
<br />
From {{man|1|newsboat|DESCRIPTION}}:<br />
<br />
:Newsboat is an RSS/Atom feed reader for text terminals. RSS and Atom are a number of widely-used XML formats to transmit, publish and syndicate articles, for example news or blog articles. Newsboat is designed to be used on text terminals on Unix or Unix-like systems such as GNU/Linux, BSD or macOS. <br />
<br />
Newsboat is a [https://groups.google.com/forum/#!topic/newsbeuter/RPtlWX8CPGU fork] of abandoned Newsbeuter.<br />
<br />
== Installation ==<br />
<br />
Install the {{Pkg|newsboat}} package. For the development version, install the {{AUR|newsboat-git}} package.<br />
<br />
== Usage ==<br />
<br />
Newsboat cannot start without any configured feeds. Feeds can be configured in {{ic|~/.newsboat/urls}}. Newsboat can be started from the command line with<br />
<br />
$ newsboat<br />
<br />
Press the {{ic|?}} key to see a list of all keybindings. Keybindings can be rebound, see [[#Configuration]].<br />
<br />
== Managing feeds ==<br />
<br />
Adding, removing, and tagging feeds is done by editing the urls file. By default that is {{ic|~/.newsboat/urls}}.<br />
{{Tip|In addition to newsboat specific feeds in this section, be sure to see the [[Web feed]] article for additional options.}}<br />
<br />
=== RSS or ATOM sources ===<br />
<br />
To add URLs, open {{ic|~/.newsboat/urls}} with your favorite text editor and add the URLs, one per line:<br />
<br />
<nowiki>http://rss.cnn.com/rss/cnn_topstories.rss</nowiki><br />
<nowiki>http://newsrss.bbc.co.uk/rss/newsonline_world_edition/front_page/rss.xml</nowiki><br />
<br />
To add URLs that have restricted access via username/password, simply provide the username/password in the following way:<br />
<br />
<nowiki>http://username:password@hostname.domain.tld/feed.rss</nowiki><br />
<br />
In order to protect username and password, make sure that {{ic|~/.newsboat/urls}} has the appropriate permissions. Newsboat also makes sure that usernames and passwords within URLs aren’t displayed in its user interface. In case there is a @ in the username, type it as %40 instead so that it can be distinguished from the @ that separates the username/password part from the hostname part.<br />
<br />
To configure local files as feeds, simply prefix the local path with {{ic|file://}} and add it to the {{ic|~/.newsboat/urls}} file:<br />
file:///var/log/rss_eventlog.xml<br />
<br />
=== HTML as a source ===<br />
<br />
If HTML sources can be converted to RSS via a user supplied script, newboat can both execute this script and consume the output.<br />
<br />
This is accomplished by using the {{ic|filter:}} prefix in the configuration file. For example, write a script that can read HTML from stdin and print out an RSS or Atom feed to stdout. Save that script to {{ic|~/.newsboat/html2rss.sh}} and add the following line to the {{ic|urls}}:<br />
<nowiki>filter:~/.newsboat/html2rss.sh:https://myurl.com</nowiki><br />
<br />
* For several examples using this strategy, see [https://github.com/graysky2/newsboat_custom_stuff graysky's newsboat repo].<br />
* For more discussion, see [https://github.com/newsboat/newsboat/issues/1157 Possible to config newsboat to look at a web exposed directory and report changes #1157].<br />
<br />
=== Tagging feeds ===<br />
<br />
Every feed can be assigned 0 or more tags. This makes it easy to categorize your feeds as well as the ability to easily apply commands to multiple feeds at once.<br />
<br />
Usually, the {{ic|~/.newsboat/urls}} file contains one RSS feed URL per line. To assign a tag to an RSS feed, simply attach it as a single word, separated by blanks such as space or tab. If the tag needs to contain spaces, use quotes (") around the tag (see example below). An example may look like this:<br />
<nowiki>http://blog.fefe.de/rss.xml?html interesting conspiracy news "cool stuff"</nowiki><br />
<nowiki>http://rss.orf.at/news.xml news orf</nowiki><br />
<nowiki>http://www.heise.de/newsticker/heise.rdf news interesting</nowiki><br />
<br />
Starting Newsboat with this configuration, one can press {{ic|t}} to select a tag. Upon selecting the tag "news", one will see all three RSS feeds. Pressing {{ic|t}} again and e.g. selecting the "conspiracy" tag, will only show the {{ic|<nowiki>http://blog.fefe.de/rss.xml?html</nowiki>}} RSS feed. Pressing {{ic|Ctrl-T}} clears the current tag,<br />
and again shows all RSS feeds, regardless of their assigned tags.<br />
<br />
{{Note| If the tag name contains spaces, the tag must be bounded by {{ic|"}}}}<br />
<br />
==== Special tags ====<br />
<br />
===== Custom feed names =====<br />
<br />
The name of a feed can be defined with a special tag in your urls file. Simply '''prefix''' the tag name with the {{ic|~}} character and the tag name will become the feed name.<br />
<br />
For example:<br />
<br />
<nowiki>http://rss.cnn.com/rss/cnn_topstories.rss</nowiki> "~CNN Top stories"<br />
<br />
will define the feed with feed-name "CNN Top stories"<br />
<br />
===== Hidden feeds =====<br />
<br />
A feed can be '''hidden''' from the regular list of feeds by '''prefixing''' the tag name with an {{ic|!}}.<br />
<br />
For example:<br />
<nowiki>http://rss.orf.at/news.xml</nowiki> "!ORF News (hidden)"<br />
<br />
The content of a '''hidden''' feed can only be found through a query feed.<br />
<br />
=== Query feeds ===<br />
<br />
Custom feeds can be created from existing feeds by creating what's called a query feed: A feed generated by matching articles against a query. Query feeds are defined in your {{ic|~/.config/newsboat/urls}} file like a normal feed.<br />
They have the following syntax:<br />
<br />
<nowiki>query:FEEDNAME:FILTER_EXPRESSION [TAG ...]</nowiki><br />
<br />
Like a normal feed, a query feed has a name, {{ic|FEEDNAME}}, which is displayed in the feedlist.<br />
The filter expression language for {{ic|FILTER_EXPRESSION}} is defined in the [https://newsboat.org/releases/2.13/docs/newsboat.html#_filter_language newsboat manual].<br />
Also like any normal feed, query feeds can be optionally tagged.<br />
<br />
Here are some examples:<br />
<br />
{{hc|~/.config/newsboat/urls|<br />
"query:Archlinux:tags # \"archlinux\""<br />
"query:Youtube:rssurl {{=}}~ \"youtube\""<br />
}}<br />
<br />
{{Note|The query feed must be encapsulated in double quotes. Therefore any other double quotes in its declaration must be escaped}}<br />
<br />
==== Unread articles ====<br />
<br />
To create a feed named {{ic|Unread Articles}} that contains all unread articles, define the following:<br />
<br />
{{hc|~/.config/newsboat/urls|<br />
"query:Unread Articles:unread {{=}} \"yes\""<br />
}}<br />
<br />
==== Amalgamating multiple feeds into one ====<br />
<br />
A good use of query feeds is when you're following a creator whose content is spread across multiple feeds. You can use a query feed to amalgamate all his content into one place.<br />
<br />
{{hc|~/.config/newsboat/urls|<br />
"query:Metafeed:tags # \"metafeed\""<br />
https://feed.url/1 metafeed !<br />
https://feed.url/2 metafeed !<br />
https://feed.url/3 metafeed !<br />
}}<br />
<br />
The trick is to assign each feed a unique tag - here {{ic|metafeed}} - so that we can match against it in the filter expression. We also make use of [[#Hidden feeds]] - the {{ic|!}} at the end of each feed - so that the individual feeds don't show up in feedlist.<br />
<br />
=== Ignoring articles ===<br />
<br />
There are two ways to ignore articles, delete them or not show them.<br />
{{hc|~/.newsboat/config|<br />
# ignore-mode "download" # Default: Delete them.<br />
ignore-mode "display" # Do not show them.<br />
}}<br />
The filter can be configured like so (here in POSIX extended regular expressions):<br />
{{hc|~/.newsboat/config|<nowiki><br />
ignore-article "https://feed/url" "content =~ \"tele(phone|communications)\"" <br />
ignore-article "https://feed/url" "title =~ \"text_1|text_2\""<br />
</nowiki>}}<br />
<br />
== Configuration ==<br />
<br />
Several aspects of Newsboat’s behaviour can be configured via a configuration file which is located, by default, in {{ic|~/.newsboat/config}} or {{ic|~/.config/newsboat/config}}. This configuration file contains lines of the form:<br />
<br />
<config-command> <arg1> ...<br />
<br />
=== Color schemes ===<br />
<br />
The package ships with a number of schemes in {{ic|/usr/share/doc/newsboat/contrib/colorschemes/}} which can be loaded with the include command like so:<br />
include /usr/share/doc/newsboat/contrib/colorschemes/inkpot<br />
<br />
=== Additional options ===<br />
<br />
The configuration file can also contain comments, which start with the {{ic|#}} character and go as far as the end of line. To enter a configuration argument that contains spaces, use quotes {{ic|"}} around the whole argument. It’s even possible to integrate the output of external commands into the configuration. The text between two backticks {{ic|`}} is evaluated as shell command, and its output is put on its place instead. This works like backtick evaluation in Bourne-compatible shells and allows users to use external information from the system within the configuration.<br />
<br />
See [https://gist.github.com/anonymous/42d2f5956e7bc8ee1ebc] and [http://moparx.com/configs/newsbeuter/] for example configurations.<br />
<br />
{{Note|To see a complete list of configuration command, consult {{man|1|newsboat|CONFIGURATION COMMANDS}}.}}<br />
<br />
== Tips ==<br />
<br />
=== Automatic feed reloads ===<br />
<br />
Newsboat can automatically reload all feeds on startup with the following configuration:<br />
<br />
auto-reload yes<br />
<br />
With this setting, Newsboat also runs periodic auto-reloads – by default, every 60 minutes. The number of minutes between automatic reloads can be configured like so:<br />
<br />
reload-time <desired number of minutes><br />
<br />
Alternatively, use [[cron]] or [[systemd]] to automatically reload feeds. Just add a line in your crontab, or create a systemd service/timer unit combo that issues the following command:<br />
<br />
/usr/bin/newsboat -x reload<br />
<br />
=== Loading of feeds in parallel for faster updates ===<br />
<br />
By default, Newsboat will attempt to update entries in {{ic|~/.newsboat/urls}} in sequence; however, the following setting will update them n at a time, in parallel. Adjust n to your liking.<br />
<br />
reload-threads 100<br />
<br />
=== Pass article URL to external command ===<br />
<br />
A clever little hack allows one to pass the URL of an article to an external command. The idea is to use a macro to set the browser that Newsboat opens the article with to the path of some other command and then change it back afterwards.<br />
<br />
For example, subscribers of a particular youtube channel can open the video with [[mpv]], by doing the following:<br />
<br />
macro y set browser "mpv %u" ; open-in-browser ; set browser "elinks %u"<br />
<br />
{{Note| First press the {{ic|,}} key, followed by the keybind to use the macro. In the example above, type {{ic|,}} + {{ic|y}} }}<br />
<br />
=== Subheadings ===<br />
<br />
There is another little hack that allows the user to add subheadings to sort feeds more effectively. This hack involves adding fake feeds to the {{ic|urls}} file like so:<br />
<br />
---Heading---<br />
<br />
{{Note|the {{ic|---}} characters are optional but having some sort of character identifying the headings is useful for styling.}}<br />
<br />
Then in {{ic|~/.config/newsboat/config}}, add the following two lines:<br />
<br />
highlight feedlist "---.*---" ''COLOR_OF_YOUR_CHOOSING'' default bold<br />
highlight feedlist ".*0/0.." default default invis<br />
<br />
Of course, replace {{ic|''COLOR_OF_YOUR_CHOOSING''}} with a [https://newsboat.org/releases/2.24/docs/newsboat.html#_configuring_colors newsboat supported color].<br />
<br />
This trick can also interact with Tags by replacing {{ic|---Heading---}} with:<br />
<br />
"query:---Heading---:tags # \"Tag\""<br />
<br />
Then tagging all the feeds below the heading with {{ic|Tag}}.<br />
<br />
== Troubleshooting ==<br />
<br />
=== Newsboat will not start ===<br />
<br />
Newsboat cannot start without any configured feeds! To add URLs, see [[#Managing feeds]]. If that is not the problem, check to see if another instance of Newsboat is running. Newsboat issues a lock on its database so that only one instance can access it at a time; thus, attempting to open a second instance will fail.<br />
<br />
== See Also ==<br />
<br />
*[https://newsboat.org/ Official web site]<br />
*[https://newsboat.org/releases/2.24/docs/newsboat.html Full documentation]<br />
*[https://sanctum.geek.nz/arabesque/rss-with-newsboat/ Arabesque: RSS with Newsboat]</div>Captaincurriehttps://wiki.archlinux.org/index.php?title=Newsboat&diff=765984Newsboat2023-02-01T00:53:42Z<p>Captaincurrie: added a section describing query feeds</p>
<hr />
<div>[[Category:News aggregators]]<br />
[[Category:Console applications]]<br />
[[ja:Newsboat]]<br />
{{Related articles start}}<br />
{{Related|Web feed}}<br />
{{Related articles end}}<br />
<br />
[https://newsboat.org/ Newsboat] is an open source news aggregator licensed under the MIT License.<br />
<br />
From {{man|1|newsboat|DESCRIPTION}}:<br />
<br />
:Newsboat is an RSS/Atom feed reader for text terminals. RSS and Atom are a number of widely-used XML formats to transmit, publish and syndicate articles, for example news or blog articles. Newsboat is designed to be used on text terminals on Unix or Unix-like systems such as GNU/Linux, BSD or macOS. <br />
<br />
Newsboat is a [https://groups.google.com/forum/#!topic/newsbeuter/RPtlWX8CPGU fork] of abandoned Newsbeuter.<br />
<br />
== Installation ==<br />
<br />
Install the {{Pkg|newsboat}} package. For the development version, install the {{AUR|newsboat-git}} package.<br />
<br />
== Usage ==<br />
<br />
Newsboat cannot start without any configured feeds. Feeds can be configured in {{ic|~/.newsboat/urls}}. Newsboat can be started from the command line with<br />
<br />
$ newsboat<br />
<br />
Press the {{ic|?}} key to see a list of all keybindings. Keybindings can be rebound, see [[#Configuration]].<br />
<br />
== Managing feeds ==<br />
<br />
Adding, removing, and tagging feeds is done by editing the urls file. By default that is {{ic|~/.newsboat/urls}}.<br />
{{Tip|In addition to newsboat specific feeds in this section, be sure to see the [[Web feed]] article for additional options.}}<br />
<br />
=== RSS or ATOM sources ===<br />
<br />
To add URLs, open {{ic|~/.newsboat/urls}} with your favorite text editor and add the URLs, one per line:<br />
<br />
<nowiki>http://rss.cnn.com/rss/cnn_topstories.rss</nowiki><br />
<nowiki>http://newsrss.bbc.co.uk/rss/newsonline_world_edition/front_page/rss.xml</nowiki><br />
<br />
To add URLs that have restricted access via username/password, simply provide the username/password in the following way:<br />
<br />
<nowiki>http://username:password@hostname.domain.tld/feed.rss</nowiki><br />
<br />
In order to protect username and password, make sure that {{ic|~/.newsboat/urls}} has the appropriate permissions. Newsboat also makes sure that usernames and passwords within URLs aren’t displayed in its user interface. In case there is a @ in the username, type it as %40 instead so that it can be distinguished from the @ that separates the username/password part from the hostname part.<br />
<br />
To configure local files as feeds, simply prefix the local path with {{ic|file://}} and add it to the {{ic|~/.newsboat/urls}} file:<br />
file:///var/log/rss_eventlog.xml<br />
<br />
=== HTML as a source ===<br />
<br />
If HTML sources can be converted to RSS via a user supplied script, newboat can both execute this script and consume the output.<br />
<br />
This is accomplished by using the {{ic|filter:}} prefix in the configuration file. For example, write a script that can read HTML from stdin and print out an RSS or Atom feed to stdout. Save that script to {{ic|~/.newsboat/html2rss.sh}} and add the following line to the {{ic|urls}}:<br />
<nowiki>filter:~/.newsboat/html2rss.sh:https://myurl.com</nowiki><br />
<br />
* For several examples using this strategy, see [https://github.com/graysky2/newsboat_custom_stuff graysky's newsboat repo].<br />
* For more discussion, see [https://github.com/newsboat/newsboat/issues/1157 Possible to config newsboat to look at a web exposed directory and report changes #1157].<br />
<br />
=== Query feeds ===<br />
<br />
Custom feeds can be created from existing feeds by creating what's called a query feed: A feed generated by matching articles against a query. Query feeds are defined in your {{ic|~/.config/newsboat/urls}} file like a normal feed.<br />
They have the following syntax:<br />
<br />
<nowiki>query:FEEDNAME:FILTER_EXPRESSION [TAG ...]</nowiki><br />
<br />
Like a normal feed, a query feed has a name, {{ic|FEEDNAME}}, which is displayed in the feedlist.<br />
The filter expression language for {{ic|FILTER_EXPRESSION}} is defined in the [https://newsboat.org/releases/2.13/docs/newsboat.html#_filter_language newsboat manual].<br />
Also like any normal feed, query feeds can be optionally tagged.<br />
<br />
Here are some examples:<br />
<br />
{{hc|~/.config/newsboat/urls|<br />
"query:Archlinux:tags # \"archlinux\""<br />
"query:Youtube:rssurl {{=}}~ \"youtube\""<br />
}}<br />
<br />
{{Note|The query feed must be encapsulated in double quotes. Therefore any other double quotes in its declaration must be escaped}}<br />
<br />
==== Unread articles ====<br />
<br />
To create a feed named {{ic|Unread Articles}} that contains all unread articles, define the following:<br />
<br />
{{hc|~/.config/newsboat/urls|<br />
"query:Unread Articles:unread {{=}} \"yes\""<br />
}}<br />
<br />
==== Amalgamating multiple feeds into one ====<br />
<br />
A good use of query feeds is when you're following a creator whose content is spread across multiple feeds. You can use a query feed to amalgamate all his content into one place.<br />
<br />
{{hc|~/.config/newsboat/urls|<br />
"query:Metafeed:tags # \"metafeed\""<br />
https://feed.url/1 metafeed !<br />
https://feed.url/2 metafeed !<br />
https://feed.url/3 metafeed !<br />
}}<br />
<br />
The trick is to assign each feed a unique tag - here {{ic|metafeed}} - so that we can match against it in the filter expression. We also make use of [[#Hidden feeds]] - the {{ic|!}} at the end of each feed - so that the individual feeds don't show up in feedlist.<br />
<br />
=== Tagging feeds ===<br />
<br />
Every feed can be assigned 0 or more tags. This makes it easy to categorize your feeds as well as the ability to easily apply commands to multiple feeds at once.<br />
<br />
Usually, the {{ic|~/.newsboat/urls}} file contains one RSS feed URL per line. To assign a tag to an RSS feed, simply attach it as a single word, separated by blanks such as space or tab. If the tag needs to contain spaces, use quotes (") around the tag (see example below). An example may look like this:<br />
<nowiki>http://blog.fefe.de/rss.xml?html interesting conspiracy news "cool stuff"</nowiki><br />
<nowiki>http://rss.orf.at/news.xml news orf</nowiki><br />
<nowiki>http://www.heise.de/newsticker/heise.rdf news interesting</nowiki><br />
<br />
Starting Newsboat with this configuration, one can press {{ic|t}} to select a tag. Upon selecting the tag "news", one will see all three RSS feeds. Pressing {{ic|t}} again and e.g. selecting the "conspiracy" tag, will only show the {{ic|<nowiki>http://blog.fefe.de/rss.xml?html</nowiki>}} RSS feed. Pressing {{ic|Ctrl-T}} clears the current tag,<br />
and again shows all RSS feeds, regardless of their assigned tags.<br />
<br />
{{Note| If the tag name contains spaces, the tag must be bounded by {{ic|"}}}}<br />
<br />
==== Special tags ====<br />
<br />
===== Custom feed names =====<br />
<br />
The name of a feed can be defined with a special tag in your urls file. Simply '''prefix''' the tag name with the {{ic|~}} character and the tag name will become the feed name.<br />
<br />
For example:<br />
<br />
<nowiki>http://rss.cnn.com/rss/cnn_topstories.rss</nowiki> "~CNN Top stories"<br />
<br />
will define the feed with feed-name "CNN Top stories"<br />
<br />
===== Hidden feeds =====<br />
<br />
A feed can be '''hidden''' from the regular list of feeds by '''prefixing''' the tag name with an {{ic|!}}.<br />
<br />
For example:<br />
<nowiki>http://rss.orf.at/news.xml</nowiki> "!ORF News (hidden)"<br />
<br />
The content of a '''hidden''' feed can only be found through a query feed.<br />
<br />
=== Ignoring articles ===<br />
<br />
There are two ways to ignore articles, delete them or not show them.<br />
{{hc|~/.newsboat/config|<br />
# ignore-mode "download" # Default: Delete them.<br />
ignore-mode "display" # Do not show them.<br />
}}<br />
The filter can be configured like so (here in POSIX extended regular expressions):<br />
{{hc|~/.newsboat/config|<nowiki><br />
ignore-article "https://feed/url" "content =~ \"tele(phone|communications)\"" <br />
ignore-article "https://feed/url" "title =~ \"text_1|text_2\""<br />
</nowiki>}}<br />
<br />
== Configuration ==<br />
<br />
Several aspects of Newsboat’s behaviour can be configured via a configuration file which is located, by default, in {{ic|~/.newsboat/config}} or {{ic|~/.config/newsboat/config}}. This configuration file contains lines of the form:<br />
<br />
<config-command> <arg1> ...<br />
<br />
=== Color schemes ===<br />
<br />
The package ships with a number of schemes in {{ic|/usr/share/doc/newsboat/contrib/colorschemes/}} which can be loaded with the include command like so:<br />
include /usr/share/doc/newsboat/contrib/colorschemes/inkpot<br />
<br />
=== Additional options ===<br />
<br />
The configuration file can also contain comments, which start with the {{ic|#}} character and go as far as the end of line. To enter a configuration argument that contains spaces, use quotes {{ic|"}} around the whole argument. It’s even possible to integrate the output of external commands into the configuration. The text between two backticks {{ic|`}} is evaluated as shell command, and its output is put on its place instead. This works like backtick evaluation in Bourne-compatible shells and allows users to use external information from the system within the configuration.<br />
<br />
See [https://gist.github.com/anonymous/42d2f5956e7bc8ee1ebc] and [http://moparx.com/configs/newsbeuter/] for example configurations.<br />
<br />
{{Note|To see a complete list of configuration command, consult {{man|1|newsboat|CONFIGURATION COMMANDS}}.}}<br />
<br />
== Tips ==<br />
<br />
=== Automatic feed reloads ===<br />
<br />
Newsboat can automatically reload all feeds on startup with the following configuration:<br />
<br />
auto-reload yes<br />
<br />
With this setting, Newsboat also runs periodic auto-reloads – by default, every 60 minutes. The number of minutes between automatic reloads can be configured like so:<br />
<br />
reload-time <desired number of minutes><br />
<br />
Alternatively, use [[cron]] or [[systemd]] to automatically reload feeds. Just add a line in your crontab, or create a systemd service/timer unit combo that issues the following command:<br />
<br />
/usr/bin/newsboat -x reload<br />
<br />
=== Loading of feeds in parallel for faster updates ===<br />
<br />
By default, Newsboat will attempt to update entries in {{ic|~/.newsboat/urls}} in sequence; however, the following setting will update them n at a time, in parallel. Adjust n to your liking.<br />
<br />
reload-threads 100<br />
<br />
=== Pass article URL to external command ===<br />
<br />
A clever little hack allows one to pass the URL of an article to an external command. The idea is to use a macro to set the browser that Newsboat opens the article with to the path of some other command and then change it back afterwards.<br />
<br />
For example, subscribers of a particular youtube channel can open the video with [[mpv]], by doing the following:<br />
<br />
macro y set browser "mpv %u" ; open-in-browser ; set browser "elinks %u"<br />
<br />
{{Note| First press the {{ic|,}} key, followed by the keybind to use the macro. In the example above, type {{ic|,}} + {{ic|y}} }}<br />
<br />
=== Subheadings ===<br />
<br />
There is another little hack that allows the user to add subheadings to sort feeds more effectively. This hack involves adding fake feeds to the {{ic|urls}} file like so:<br />
<br />
---Heading---<br />
<br />
{{Note|the {{ic|---}} characters are optional but having some sort of character identifying the headings is useful for styling.}}<br />
<br />
Then in {{ic|~/.config/newsboat/config}}, add the following two lines:<br />
<br />
highlight feedlist "---.*---" ''COLOR_OF_YOUR_CHOOSING'' default bold<br />
highlight feedlist ".*0/0.." default default invis<br />
<br />
Of course, replace {{ic|''COLOR_OF_YOUR_CHOOSING''}} with a [https://newsboat.org/releases/2.24/docs/newsboat.html#_configuring_colors newsboat supported color].<br />
<br />
This trick can also interact with Tags by replacing {{ic|---Heading---}} with:<br />
<br />
"query:---Heading---:tags # \"Tag\""<br />
<br />
Then tagging all the feeds below the heading with {{ic|Tag}}.<br />
<br />
== Troubleshooting ==<br />
<br />
=== Newsboat will not start ===<br />
<br />
Newsboat cannot start without any configured feeds! To add URLs, see [[#Managing feeds]]. If that is not the problem, check to see if another instance of Newsboat is running. Newsboat issues a lock on its database so that only one instance can access it at a time; thus, attempting to open a second instance will fail.<br />
<br />
== See Also ==<br />
<br />
*[https://newsboat.org/ Official web site]<br />
*[https://newsboat.org/releases/2.24/docs/newsboat.html Full documentation]<br />
*[https://sanctum.geek.nz/arabesque/rss-with-newsboat/ Arabesque: RSS with Newsboat]</div>Captaincurriehttps://wiki.archlinux.org/index.php?title=Makepkg&diff=358496Makepkg2015-01-28T10:29:35Z<p>Captaincurrie: /* Troubleshooting */ added link to changes in gnupg 2.1</p>
<hr />
<div>{{Lowercase title}}<br />
[[Category:Package development]]<br />
[[Category:About Arch]]<br />
[[ar:Makepkg]]<br />
[[el:Makepkg]]<br />
[[es:Makepkg]]<br />
[[fr:makepkg]]<br />
[[it:Makepkg]]<br />
[[ja:Makepkg]]<br />
[[nl:Makepkg]]<br />
[[pt:Makepkg]]<br />
[[ru:makepkg]]<br />
[[sr:Makepkg]]<br />
[[tr:Makepkg]]<br />
[[zh-CN:Makepkg]]<br />
{{Related articles start}}<br />
{{Related|Creating packages}}<br />
{{Related|PKGBUILD}}<br />
{{Related|Arch User Repository}}<br />
{{Related|pacman}}<br />
{{Related|Official repositories}}<br />
{{Related|Arch Build System}}<br />
{{Related articles end}}<br />
<br />
''makepkg'' is used for compiling and building packages suitable for installation with [[pacman]], Arch Linux's package manager. ''makepkg'' is a script that automates the building of packages; it can download and validate source files, check dependencies, configure build-time settings, compile the sources, install into a temporary root, make customizations, generate meta-info, and package everything together.<br />
<br />
''makepkg'' is provided by the {{Pkg|pacman}} package.<br />
<br />
== Configuration ==<br />
{{ic|/etc/makepkg.conf}} is the main configuration file for ''makepkg''. Most users will wish to fine-tune ''makepkg'' configuration options prior to building any packages. You also might create a {{ic|~/.makepkg.conf}} file.<br />
<br />
=== Architecture, compile flags ===<br />
The {{ic|MAKEFLAGS}}, {{ic|CFLAGS}},{{ic|CXXFLAGS}} and {{ic|CPPFLAGS}} options are used by {{Pkg|make}}, {{Pkg|gcc}}, and ''g++'' whilst compiling software with ''makepkg''. By default, these options generate generic packages that can be installed on a wide range of machines. A performance improvement can be achieved by tuning compilation for the host machine. The downside is that packages compiled specifically for the compiling host's processor may not run on other machines.<br />
<br />
{{Note|Do keep in mind that not all package build systems will use your exported variables. Some override them in the original Makefiles or the [[PKGBUILD]]. For example, cmake disregards the preprocessor options environment variable, {{ic|CPPFLAGS}}.}}<br />
<br />
{{hc|/etc/makepkg.conf|<nowiki><br />
[...]<br />
<br />
#########################################################################<br />
# ARCHITECTURE, COMPILE FLAGS<br />
#########################################################################<br />
#<br />
CARCH="x86_64"<br />
CHOST="x86_64-unknown-linux-gnu"<br />
<br />
#-- Exclusive: will only run on x86_64<br />
# -march (or -mcpu) builds exclusively for an architecture<br />
# -mtune optimizes for an architecture, but builds for whole processor family<br />
CPPFLAGS="-D_FORTIFY_SOURCE=2"<br />
CFLAGS="-march=x86-64 -mtune=generic -O2 -pipe -fstack-protector --param=ssp-buffer-size=4"<br />
CXXFLAGS="-march=x86-64 -mtune=generic -O2 -pipe -fstack-protector --param=ssp-buffer-size=4"<br />
LDFLAGS="-Wl,-O1,--sort-common,--as-needed,-z,relro"<br />
#-- Make Flags: change this for DistCC/SMP systems<br />
#MAKEFLAGS="-j2"<br />
<br />
[...]<br />
</nowiki>}}<br />
<br />
The default {{ic|makepkg.conf}} {{ic|CFLAGS}} and {{ic|CXXFLAGS}} are compatible with all machines within their respective architectures. <br />
<br />
On x86_64 machines, there are rarely significant enough real world performance gains that would warrant investing the time to rebuild official packages.<br />
<br />
As of version 4.3.0, GCC offers the {{ic|1=-march=native}} switch that enables CPU auto-detection and automatically selects optimizations supported by the local machine at GCC runtime. To use it, just modify the default settings by changing the {{ic|CFLAGS}} and {{ic|CXXFLAGS}} lines as follows:<br />
<br />
# -march=native also sets the correct -mtune=<br />
CFLAGS="-march=native -O2 -pipe -fstack-protector --param=ssp-buffer-size=4 -D_FORTIFY_SOURCE=2"<br />
CXXFLAGS="${CFLAGS}"<br />
<br />
{{Tip|To see what {{ic|1=march=native}} flags are, run:<br />
<nowiki>$ gcc -march=native -E -v - </dev/null 2>&1 | sed -n 's/.* -v - //p'</nowiki><br />
}}<br />
<br />
Further optimizing for CPU type can theoretically enhance performance because {{ic|1=-march=native}} enables all available instruction sets and improves scheduling for a particular CPU. This is especially noticeable when rebuilding applications (for example: audio/video encoding tools, scientific applications, math-heavy programs, etc.) that can take heavy advantage of newer instructions sets not enabled when using the default options (or packages) provided by Arch Linux. <br />
<br />
It is very easy to reduce performance by using "non-standard" CFLAGS because compilers tend to heavily blow up the code size with loop unrolling, bad vectorization, crazy inlining, etc. depending on compiler switches. Unless you can verify/benchmark that something is faster, there is a very good chance it is not! <br />
<br />
See the GCC man page for a complete list of available options. The Gentoo [http://www.gentoo.org/doc/en/gcc-optimization.xml Compilation Optimization Guide] and [http://wiki.gentoo.org/wiki/Safe_CFLAGS Safe CFLAGS] wiki article provide more in-depth information.<br />
<br />
====MAKEFLAGS====<br />
The {{ic|MAKEFLAGS}} option can be used to specify additional options for make. Users with multi-core/multi-processor systems can specify the number of jobs to run simultaneously. This can be accomplished with the use of ''nproc'' to determine the number of available processors, e.g. {{ic|-j4}} (where "4" is the output of ''nproc''). Some [[PKGBUILD]]'s specifically override this with {{ic|-j1}}, because of race conditions in certain versions or simply because it is not supported in the first place. Packages that fail to build because of this should be [[Reporting Bug Guidelines|reported]] on the bug tracker (or in the case of [[AUR]] packages, to the package maintainer) after making sure that the error is indeed being caused by your {{ic|MAKEFLAGS}}.<br />
<br />
See {{ic|man make}} for a complete list of available options.<br />
<br />
=== Package output ===<br />
Next, one can configure where source files and packages should be placed and identify themselves as the packager. This step is optional; packages will be created in the working directory where ''makepkg'' is run by default.<br />
<br />
{{hc|/etc/makepkg.conf|<nowiki><br />
[...]<br />
<br />
#########################################################################<br />
# PACKAGE OUTPUT<br />
#########################################################################<br />
#<br />
# Default: put built package and cached source in build directory<br />
#<br />
#-- Destination: specify a fixed directory where all packages will be placed<br />
#PKGDEST=/home/packages<br />
#-- Source cache: specify a fixed directory where source files will be cached<br />
#SRCDEST=/home/sources<br />
#-- Source packages: specify a fixed directory where all src packages will be placed<br />
#SRCPKGDEST=/home/srcpackages<br />
#-- Packager: name/email of the person or organization building packages<br />
#PACKAGER="John Doe <john@doe.com>"<br />
<br />
[...]<br />
</nowiki>}}<br />
<br />
For example, create the directory:<br />
<br />
$ mkdir /home/$USER/packages<br />
<br />
Then modify the {{ic|PKGDEST}} variable in {{ic|/etc/makepkg.conf}} accordingly.<br />
<br />
The {{ic|PACKAGER}} variable will set the {{ic|packager}} value within compiled packages' {{ic|.PKGINFO}} metadata file. By default, user-compiled packages will display:<br />
<br />
{{hc|$ pacman -Qi ''package''|<nowiki><br />
[...]<br />
Packager : Unknown Packager<br />
[...]<br />
</nowiki>}}<br />
<br />
Afterwards:<br />
<br />
{{hc|$ pacman -Qi ''package''|<nowiki><br />
[...]<br />
Packager : John Doe <john@doe.com><br />
[...]<br />
</nowiki>}}<br />
<br />
This is useful if multiple users will be compiling packages on a system, or you are otherwise distributing your packages to other users.<br />
<br />
=== Signature checking ===<br />
<br />
{{Expansion|Expand a bit on {{ic|validpgpkeys()}}, e.g: "''I then check the person who signed is expected from the software mailing list, check if they sign emails, look if the PGP fingerprint is published on their homepage, … That verifies the signature enough to add the validpgpkeys array for me.''"}}<br />
<br />
If a signature file in the form of {{ic|.sig}} is part of the [[PKGBUILD]] source array, ''makepkg'' validates the authenticity of source files. For example, the signature {{ic|''pkgname''-''pkgver''.tar.gz.sig}} is used to check the integrity of the file {{ic|''pkgname''-''pkgver''.tar.gz}} with the ''gpg'' program.<br />
<br />
If desired, signatures by other developers can be manually added to the GPG keyring. See [[GnuPG]] article for details. To temporarily disable signature checking, call the ''makepkg'' command with the {{ic|--skippgpcheck}} option.<br />
<br />
{{Note|The signature checking implemented in ''makepkg'' does not use pacman's keyring, relying on the user's keyring and the {{ic|validpgpkeys()}} array instead. [http://allanmcrae.com/2015/01/two-pgp-keyrings-for-package-management-in-arch-linux/]}}<br />
<br />
To show the current list of GPG keys, use the ''gpg'' command:<br />
<br />
$ gpg --list-keys<br />
<br />
If the {{ic|pubring.gpg}} file does not exist, it will be created for you immediately.<br />
<br />
The GPG keys are expected to be stored in the user's {{ic|~/.gnupg/pubring.gpg}} file. In case it does not contain the given signature, ''makepkg'' will abort the installation:<br />
<br />
{{hc|$ makepkg|2=<br />
[...]<br />
==> Verifying source file signatures with gpg...<br />
pkgname-pkgver.tar.gz ... FAILED (unknown public key ''1234567890'')<br />
==> ERROR: One or more PGP signatures could not be verified!<br />
}}<br />
<br />
To import the key, use:<br />
<br />
$ gpg --recv-keys ''1234567890''<br />
<br />
Or to automate:<br />
<br />
{{hc|~/.gnupg/gpg.conf|<br />
keyserver-options auto-key-retrieve<br />
}}<br />
<br />
== Usage ==<br />
<br />
Before continuing, ensure the {{Grp|base-devel}} group is installed. Packages belonging to this group are not required to be listed as build-time (make) dependencies in [[PKGBUILD]] files. Install the {{ic|base-devel}} group by issuing (as root):<br />
<br />
# pacman -S base-devel<br />
<br />
{{Note|Before complaining about missing (make) dependencies, remember that the {{Grp|base}} group is assumed to be installed on all Arch Linux systems. The group "base-devel" is assumed to be installed when building with ''makepkg'' or when using [[AUR helpers]].}}<br />
<br />
To build a package, one must first create a [[PKGBUILD]], or build script, as described in [[Creating packages]], or obtain one from the [[Arch Build System|ABS tree]], [[Arch User Repository]], or some other source. <br />
<br />
{{Warning|Only build and/or install packages from trusted sources.}}<br />
<br />
Once in possession of a {{ic|PKGBUILD}}, change to the directory where it is saved and issue the following command to build the package described by said {{ic|PKGBUILD}}:<br />
<br />
$ makepkg<br />
<br />
''makepkg'' does not support building as root as of v4.2. Besides how a {{ic|PKGBUILD}} may contain arbitrary commands, building as root is generally considered unsafe (see for example [https://bbs.archlinux.org/viewtopic.php?id=67561]).<br />
<br />
To have ''makepkg'' clean out leftover files and folders, such as files extracted to the $srcdir, add the following option. This is useful for multiple builds of the same package or updating the package version, while using the same build folder. It prevents obsolete and remnant files from carrying over to the new builds.<br />
<br />
$ makepkg -c<br />
<br />
If required dependencies are missing, ''makepkg'' will issue a warning before failing. To build the package and install needed dependencies automatically, simply use the command:<br />
<br />
$ makepkg -s<br />
<br />
Note that these dependencies must be available in the configured repositories; see [[pacman#Repositories]] for details. Alternatively, one can manually install dependencies prior to building ({{ic|pacman -S --asdeps dep1 dep2}}).<br />
<br />
Once all dependencies are satisfied and the package builds successfully, a package file ({{ic|''pkgname''-''pkgver''.pkg.tar.xz}}) will be created in the working directory. To install, run (as root):<br />
<br />
# pacman -U ''pkgname''-''pkgver''.pkg.tar.xz<br />
<br />
Alternatively, to install, using the {{ic|-i}} flag is an easier way of running {{ic|pacman -U ''pkgname''-''pkgver''.pkg.tar.xz}}, as in:<br />
<br />
$ makepkg -i<br />
<br />
== Tips and Tricks ==<br />
=== Improving compile times ===<br />
<br />
==== tmpfs ====<br />
<br />
Compiling requires handling of many small files and involves many I/O operations; therefore moving its working directory to a [[tmpfs]] may bring significant improvements in build times. <br />
<br />
The {{ic|BUILDDIR}} value may be exported within a shell to temporarily set ''makepkg'' build directory to an existing tmpfs:<br />
$ BUILDDIR=/tmp/makepkg makepkg<br />
<br />
Relevant option in {{ic|/etc/makepkg.conf}} is to be found at the end of the {{ic|BUILD ENVIRONMENT}} section:<br />
{{hc|/etc/makepkg.conf|<nowiki><br />
[...]<br />
<br />
#########################################################################<br />
# BUILD ENVIRONMENT<br />
#########################################################################<br />
#<br />
# Defaults: BUILDENV=(!distcc color !ccache check !sign)<br />
# A negated environment option will do the opposite of the comments below.<br />
#<br />
#-- distcc: Use the Distributed C/C++/ObjC compiler<br />
#-- color: Colorize output messages<br />
#-- ccache: Use ccache to cache compilation<br />
#-- check: Run the check() function if present in the PKGBUILD<br />
#-- sign: Generate PGP signature file<br />
#<br />
BUILDENV=(!distcc color !ccache check !sign)<br />
#<br />
#-- If using DistCC, your MAKEFLAGS will also need modification. In addition,<br />
#-- specify a space-delimited list of hosts running in the DistCC cluster.<br />
#DISTCC_HOSTS=""<br />
#<br />
#-- Specify a directory for package building.<br />
#BUILDDIR=/tmp/makepkg<br />
<br />
[...]<br />
</nowiki>}}<br />
<br />
Uncommenting the {{ic|1=BUILDDIR=/tmp/makepkg}} line and setting it to e.g. {{ic|1=BUILDDIR=/tmp/builds}} (or leaving it to its default value) will make use of Arch default {{ic|/tmp}} [[tmpfs]].<br />
{{Note|The [[tmpfs]] folder needs to be mounted without the {{ic|noexec}} option, else it will prevent build scripts or utilities from being executed. Also, as stated in [[fstab#tmpfs]], its default size is half of the available RAM so you may run out of space.}}<br />
Please be reminded that any package compiled in [[tmpfs]] will not persist across reboot. Therefore, such packages should be installed consecutively to building or be moved to another (persistent) directory.<br />
<br />
==== ccache ====<br />
<br />
The use of [[ccache]] can improve build times by caching the results of compilations.<br />
<br />
=== Generate new checksums ===<br />
Since [http://allanmcrae.com/2013/04/pacman-4-1-released/ pacman 4.1], {{ic|makepkg -g >> PKGBUILD}} is no longer required because pacman-contrib was [https://projects.archlinux.org/pacman.git/tree/NEWS merged into upstream pacman], including the {{ic|updpkgsums}} script that will generate new checksums and/or replace them in the PKGBUILD. In the same directory as the PKGBUILD file, run the following command:<br />
$ updpkgsums<br />
<br />
=== Makepkg source PKGBUILD twice ===<br />
Makepkg sources the PKGBUILD twice (once when initially run, and the second time under ''fakeroot''). Any non-standard functions placed in the PKGBUILD will be run twice as well.<br />
<br />
=== WARNING: Package contains reference to $srcdir ===<br />
Somehow, the literal strings {{ic|$srcdir}} or {{ic|$pkgdir}} ended up in one of the installed files in your package.<br />
<br />
To identify which files, run the following from the ''makepkg'' build directory:<br />
$ grep -R "$(pwd)/src" pkg/<br />
<br />
[http://www.mail-archive.com/arch-general@archlinux.org/msg15561.html Link] to discussion thread.<br />
<br />
=== Create uncompressed packages ===<br />
If you only want to install packages locally, you can speed up the process by avoiding the [[Wikipedia:xz|LZMA2]] compression and subsequent decompression:<br />
<br />
{{hc|/etc/makepkg.conf|2=<br />
[...]<br />
#PKGEXT='.pkg.tar.xz'<br />
PKGEXT='.pkg.tar'<br />
[...]<br />
}}<br />
<br />
=== Utilizing multiple cores on compression ===<br />
{{pkg|xz}} does support [[Wikipedia:Symmetric multiprocessing|symmetric multiprocessing (SMP)]] on compression. This can be done by adding following changes:<br />
<br />
{{hc|/etc/makepkg.conf|2=<br />
[...]<br />
COMPRESSXZ=(xz -T0 -c -z -)<br />
[...]<br />
}}<br />
<br />
<br />
<br />
=== Using Aria2 to download sources ===<br />
<br />
{{Style|{{ic|DLAGENTS}} is generic, section should not prefer one specific downloader}}<br />
<br />
You can use [[Aria2]] instead of curl to download source files, just change the {{ic|DLAGENTS}} variable as follows:<br />
<br />
{{hc|/etc/makepkg.conf|2=<br />
[...]<br />
DLAGENTS=('ftp::/usr/bin/aria2c -UWget -s4 %u -o %o'<br />
'http::/usr/bin/aria2c -UWget -s4 %u -o %o'<br />
'https::/usr/bin/aria2c -UWget -s4 %u -o %o'<br />
'rsync::/usr/bin/rsync -z %u %o'<br />
'scp::/usr/bin/scp -C %u %o')<br />
[...]<br />
}}<br />
<br />
{{Note|Use the {{ic|-UWget}} option to change the user agent to Wget. It may prevent problems when downloading from sites that filters the requests based on the user agent to provide different responses on what the users uses to access the URL. Since Aria2 is a least known downloader it may be recognized by the site as a browser instead of a downloader, so changing the user agent to Wget may fix it in most cases}}<br />
<br />
== Troubleshooting ==<br />
<br />
=== Makepkg sometimes fails to sign a package without asking for signature passphrase ===<br />
With [https://www.gnupg.org/faq/whats-new-in-2.1.html gnupg 2.1], gpg-agent no longer has to be started manually and will be started automatically on the first invokation of gpg. <br />
<br />
Thus if you don't manually start gpg-agent, makepkg will start it. <br />
<br />
The problem is that makepkg runs gpg inside a fakeroot, so gpg-agent is also started in that same environment. This leads<br />
to bad behavior.<br />
<br />
The obvious remedy is to manually start the gpg-agent, either on boot or by command, before you run makepkg.<br />
<br />
See [[GnuPG#gpg-agent]] for ways to do this.<br />
<br />
== See also ==<br />
* [https://www.archlinux.org/pacman/makepkg.8.html makepkg(8) Manual Page]<br />
* [https://www.archlinux.org/pacman/makepkg.conf.5.html makepkg.conf(5) Manual Page]<br />
* [https://github.com/pixelb/scripts/blob/master/scripts/gcccpuopt gcccpuopt]: A script to print the GCC CPU-specific options tailored for the current CPU</div>Captaincurriehttps://wiki.archlinux.org/index.php?title=Makepkg&diff=358359Makepkg2015-01-27T16:18:47Z<p>Captaincurrie: /* Makepkg sometimes fails to sign a package without asking for signature passphrase */ Added explanation for error. Removed example of how to start the gpg-agent as that information is elseware</p>
<hr />
<div>{{Lowercase title}}<br />
[[Category:Package development]]<br />
[[Category:About Arch]]<br />
[[ar:Makepkg]]<br />
[[el:Makepkg]]<br />
[[es:Makepkg]]<br />
[[fr:makepkg]]<br />
[[it:Makepkg]]<br />
[[ja:Makepkg]]<br />
[[nl:Makepkg]]<br />
[[pt:Makepkg]]<br />
[[ru:makepkg]]<br />
[[sr:Makepkg]]<br />
[[tr:Makepkg]]<br />
[[zh-CN:Makepkg]]<br />
{{Related articles start}}<br />
{{Related|Creating packages}}<br />
{{Related|PKGBUILD}}<br />
{{Related|Arch User Repository}}<br />
{{Related|pacman}}<br />
{{Related|Official repositories}}<br />
{{Related|Arch Build System}}<br />
{{Related articles end}}<br />
<br />
''makepkg'' is used for compiling and building packages suitable for installation with [[pacman]], Arch Linux's package manager. ''makepkg'' is a script that automates the building of packages; it can download and validate source files, check dependencies, configure build-time settings, compile the sources, install into a temporary root, make customizations, generate meta-info, and package everything together.<br />
<br />
''makepkg'' is provided by the {{Pkg|pacman}} package.<br />
<br />
== Configuration ==<br />
{{ic|/etc/makepkg.conf}} is the main configuration file for ''makepkg''. Most users will wish to fine-tune ''makepkg'' configuration options prior to building any packages. You also might create a {{ic|~/.makepkg.conf}} file.<br />
<br />
=== Architecture, compile flags ===<br />
The {{ic|MAKEFLAGS}}, {{ic|CFLAGS}},{{ic|CXXFLAGS}} and {{ic|CPPFLAGS}} options are used by {{Pkg|make}}, {{Pkg|gcc}}, and ''g++'' whilst compiling software with ''makepkg''. By default, these options generate generic packages that can be installed on a wide range of machines. A performance improvement can be achieved by tuning compilation for the host machine. The downside is that packages compiled specifically for the compiling host's processor may not run on other machines.<br />
<br />
{{Note|Do keep in mind that not all package build systems will use your exported variables. Some override them in the original Makefiles or the [[PKGBUILD]]. For example, cmake disregards the preprocessor options environment variable, {{ic|CPPFLAGS}}.}}<br />
<br />
{{hc|/etc/makepkg.conf|<nowiki><br />
[...]<br />
<br />
#########################################################################<br />
# ARCHITECTURE, COMPILE FLAGS<br />
#########################################################################<br />
#<br />
CARCH="x86_64"<br />
CHOST="x86_64-unknown-linux-gnu"<br />
<br />
#-- Exclusive: will only run on x86_64<br />
# -march (or -mcpu) builds exclusively for an architecture<br />
# -mtune optimizes for an architecture, but builds for whole processor family<br />
CPPFLAGS="-D_FORTIFY_SOURCE=2"<br />
CFLAGS="-march=x86-64 -mtune=generic -O2 -pipe -fstack-protector --param=ssp-buffer-size=4"<br />
CXXFLAGS="-march=x86-64 -mtune=generic -O2 -pipe -fstack-protector --param=ssp-buffer-size=4"<br />
LDFLAGS="-Wl,-O1,--sort-common,--as-needed,-z,relro"<br />
#-- Make Flags: change this for DistCC/SMP systems<br />
#MAKEFLAGS="-j2"<br />
<br />
[...]<br />
</nowiki>}}<br />
<br />
The default {{ic|makepkg.conf}} {{ic|CFLAGS}} and {{ic|CXXFLAGS}} are compatible with all machines within their respective architectures. <br />
<br />
On x86_64 machines, there are rarely significant enough real world performance gains that would warrant investing the time to rebuild official packages.<br />
<br />
As of version 4.3.0, GCC offers the {{ic|1=-march=native}} switch that enables CPU auto-detection and automatically selects optimizations supported by the local machine at GCC runtime. To use it, just modify the default settings by changing the {{ic|CFLAGS}} and {{ic|CXXFLAGS}} lines as follows:<br />
<br />
# -march=native also sets the correct -mtune=<br />
CFLAGS="-march=native -O2 -pipe -fstack-protector --param=ssp-buffer-size=4 -D_FORTIFY_SOURCE=2"<br />
CXXFLAGS="${CFLAGS}"<br />
<br />
{{Tip|To see what {{ic|1=march=native}} flags are, run:<br />
<nowiki>$ gcc -march=native -E -v - </dev/null 2>&1 | sed -n 's/.* -v - //p'</nowiki><br />
}}<br />
<br />
Further optimizing for CPU type can theoretically enhance performance because {{ic|1=-march=native}} enables all available instruction sets and improves scheduling for a particular CPU. This is especially noticeable when rebuilding applications (for example: audio/video encoding tools, scientific applications, math-heavy programs, etc.) that can take heavy advantage of newer instructions sets not enabled when using the default options (or packages) provided by Arch Linux. <br />
<br />
It is very easy to reduce performance by using "non-standard" CFLAGS because compilers tend to heavily blow up the code size with loop unrolling, bad vectorization, crazy inlining, etc. depending on compiler switches. Unless you can verify/benchmark that something is faster, there is a very good chance it is not! <br />
<br />
See the GCC man page for a complete list of available options. The Gentoo [http://www.gentoo.org/doc/en/gcc-optimization.xml Compilation Optimization Guide] and [http://wiki.gentoo.org/wiki/Safe_CFLAGS Safe CFLAGS] wiki article provide more in-depth information.<br />
<br />
====MAKEFLAGS====<br />
The {{ic|MAKEFLAGS}} option can be used to specify additional options for make. Users with multi-core/multi-processor systems can specify the number of jobs to run simultaneously. This can be accomplished with the use of ''nproc'' to determine the number of available processors, e.g. {{ic|-j4}} (where "4" is the output of ''nproc''). Some [[PKGBUILD]]'s specifically override this with {{ic|-j1}}, because of race conditions in certain versions or simply because it is not supported in the first place. Packages that fail to build because of this should be [[Reporting Bug Guidelines|reported]] on the bug tracker (or in the case of [[AUR]] packages, to the package maintainer) after making sure that the error is indeed being caused by your {{ic|MAKEFLAGS}}.<br />
<br />
See {{ic|man make}} for a complete list of available options.<br />
<br />
=== Package output ===<br />
Next, one can configure where source files and packages should be placed and identify themselves as the packager. This step is optional; packages will be created in the working directory where ''makepkg'' is run by default.<br />
<br />
{{hc|/etc/makepkg.conf|<nowiki><br />
[...]<br />
<br />
#########################################################################<br />
# PACKAGE OUTPUT<br />
#########################################################################<br />
#<br />
# Default: put built package and cached source in build directory<br />
#<br />
#-- Destination: specify a fixed directory where all packages will be placed<br />
#PKGDEST=/home/packages<br />
#-- Source cache: specify a fixed directory where source files will be cached<br />
#SRCDEST=/home/sources<br />
#-- Source packages: specify a fixed directory where all src packages will be placed<br />
#SRCPKGDEST=/home/srcpackages<br />
#-- Packager: name/email of the person or organization building packages<br />
#PACKAGER="John Doe <john@doe.com>"<br />
<br />
[...]<br />
</nowiki>}}<br />
<br />
For example, create the directory:<br />
<br />
$ mkdir /home/$USER/packages<br />
<br />
Then modify the {{ic|PKGDEST}} variable in {{ic|/etc/makepkg.conf}} accordingly.<br />
<br />
The {{ic|PACKAGER}} variable will set the {{ic|packager}} value within compiled packages' {{ic|.PKGINFO}} metadata file. By default, user-compiled packages will display:<br />
<br />
{{hc|$ pacman -Qi ''package''|<nowiki><br />
[...]<br />
Packager : Unknown Packager<br />
[...]<br />
</nowiki>}}<br />
<br />
Afterwards:<br />
<br />
{{hc|$ pacman -Qi ''package''|<nowiki><br />
[...]<br />
Packager : John Doe <john@doe.com><br />
[...]<br />
</nowiki>}}<br />
<br />
This is useful if multiple users will be compiling packages on a system, or you are otherwise distributing your packages to other users.<br />
<br />
=== Signature checking ===<br />
<br />
{{Expansion|Expand a bit on {{ic|validpgpkeys()}}, e.g: "''I then check the person who signed is expected from the software mailing list, check if they sign emails, look if the PGP fingerprint is published on their homepage, … That verifies the signature enough to add the validpgpkeys array for me.''"}}<br />
<br />
If a signature file in the form of {{ic|.sig}} is part of the [[PKGBUILD]] source array, ''makepkg'' validates the authenticity of source files. For example, the signature {{ic|''pkgname''-''pkgver''.tar.gz.sig}} is used to check the integrity of the file {{ic|''pkgname''-''pkgver''.tar.gz}} with the ''gpg'' program.<br />
<br />
If desired, signatures by other developers can be manually added to the GPG keyring. See [[GnuPG]] article for details. To temporarily disable signature checking, call the ''makepkg'' command with the {{ic|--skippgpcheck}} option.<br />
<br />
{{Note|The signature checking implemented in ''makepkg'' does not use pacman's keyring, relying on the user's keyring and the {{ic|validpgpkeys()}} array instead. [http://allanmcrae.com/2015/01/two-pgp-keyrings-for-package-management-in-arch-linux/]}}<br />
<br />
To show the current list of GPG keys, use the ''gpg'' command:<br />
<br />
$ gpg --list-keys<br />
<br />
If the {{ic|pubring.gpg}} file does not exist, it will be created for you immediately.<br />
<br />
The GPG keys are expected to be stored in the user's {{ic|~/.gnupg/pubring.gpg}} file. In case it does not contain the given signature, ''makepkg'' will abort the installation:<br />
<br />
{{hc|$ makepkg|2=<br />
[...]<br />
==> Verifying source file signatures with gpg...<br />
pkgname-pkgver.tar.gz ... FAILED (unknown public key ''1234567890'')<br />
==> ERROR: One or more PGP signatures could not be verified!<br />
}}<br />
<br />
To import the key, use:<br />
<br />
$ gpg --recv-keys ''1234567890''<br />
<br />
Or to automate:<br />
<br />
{{hc|~/.gnupg/gpg.conf|<br />
keyserver-options auto-key-retrieve<br />
}}<br />
<br />
== Usage ==<br />
<br />
Before continuing, ensure the {{Grp|base-devel}} group is installed. Packages belonging to this group are not required to be listed as build-time (make) dependencies in [[PKGBUILD]] files. Install the {{ic|base-devel}} group by issuing (as root):<br />
<br />
# pacman -S base-devel<br />
<br />
{{Note|Before complaining about missing (make) dependencies, remember that the {{Grp|base}} group is assumed to be installed on all Arch Linux systems. The group "base-devel" is assumed to be installed when building with ''makepkg'' or when using [[AUR helpers]].}}<br />
<br />
To build a package, one must first create a [[PKGBUILD]], or build script, as described in [[Creating packages]], or obtain one from the [[Arch Build System|ABS tree]], [[Arch User Repository]], or some other source. <br />
<br />
{{Warning|Only build and/or install packages from trusted sources.}}<br />
<br />
Once in possession of a {{ic|PKGBUILD}}, change to the directory where it is saved and issue the following command to build the package described by said {{ic|PKGBUILD}}:<br />
<br />
$ makepkg<br />
<br />
''makepkg'' does not support building as root as of v4.2. Besides how a {{ic|PKGBUILD}} may contain arbitrary commands, building as root is generally considered unsafe (see for example [https://bbs.archlinux.org/viewtopic.php?id=67561]).<br />
<br />
To have ''makepkg'' clean out leftover files and folders, such as files extracted to the $srcdir, add the following option. This is useful for multiple builds of the same package or updating the package version, while using the same build folder. It prevents obsolete and remnant files from carrying over to the new builds.<br />
<br />
$ makepkg -c<br />
<br />
If required dependencies are missing, ''makepkg'' will issue a warning before failing. To build the package and install needed dependencies automatically, simply use the command:<br />
<br />
$ makepkg -s<br />
<br />
Note that these dependencies must be available in the configured repositories; see [[pacman#Repositories]] for details. Alternatively, one can manually install dependencies prior to building ({{ic|pacman -S --asdeps dep1 dep2}}).<br />
<br />
Once all dependencies are satisfied and the package builds successfully, a package file ({{ic|''pkgname''-''pkgver''.pkg.tar.xz}}) will be created in the working directory. To install, run (as root):<br />
<br />
# pacman -U ''pkgname''-''pkgver''.pkg.tar.xz<br />
<br />
Alternatively, to install, using the {{ic|-i}} flag is an easier way of running {{ic|pacman -U ''pkgname''-''pkgver''.pkg.tar.xz}}, as in:<br />
<br />
$ makepkg -i<br />
<br />
== Tips and Tricks ==<br />
=== Improving compile times ===<br />
<br />
==== tmpfs ====<br />
<br />
Compiling requires handling of many small files and involves many I/O operations; therefore moving its working directory to a [[tmpfs]] may bring significant improvements in build times. <br />
<br />
The {{ic|BUILDDIR}} value may be exported within a shell to temporarily set ''makepkg'' build directory to an existing tmpfs:<br />
$ BUILDDIR=/tmp/makepkg makepkg<br />
<br />
Relevant option in {{ic|/etc/makepkg.conf}} is to be found at the end of the {{ic|BUILD ENVIRONMENT}} section:<br />
{{hc|/etc/makepkg.conf|<nowiki><br />
[...]<br />
<br />
#########################################################################<br />
# BUILD ENVIRONMENT<br />
#########################################################################<br />
#<br />
# Defaults: BUILDENV=(!distcc color !ccache check !sign)<br />
# A negated environment option will do the opposite of the comments below.<br />
#<br />
#-- distcc: Use the Distributed C/C++/ObjC compiler<br />
#-- color: Colorize output messages<br />
#-- ccache: Use ccache to cache compilation<br />
#-- check: Run the check() function if present in the PKGBUILD<br />
#-- sign: Generate PGP signature file<br />
#<br />
BUILDENV=(!distcc color !ccache check !sign)<br />
#<br />
#-- If using DistCC, your MAKEFLAGS will also need modification. In addition,<br />
#-- specify a space-delimited list of hosts running in the DistCC cluster.<br />
#DISTCC_HOSTS=""<br />
#<br />
#-- Specify a directory for package building.<br />
#BUILDDIR=/tmp/makepkg<br />
<br />
[...]<br />
</nowiki>}}<br />
<br />
Uncommenting the {{ic|1=BUILDDIR=/tmp/makepkg}} line and setting it to e.g. {{ic|1=BUILDDIR=/tmp/builds}} (or leaving it to its default value) will make use of Arch default {{ic|/tmp}} [[tmpfs]].<br />
{{Note|The [[tmpfs]] folder needs to be mounted without the {{ic|noexec}} option, else it will prevent build scripts or utilities from being executed. Also, as stated in [[fstab#tmpfs]], its default size is half of the available RAM so you may run out of space.}}<br />
Please be reminded that any package compiled in [[tmpfs]] will not persist across reboot. Therefore, such packages should be installed consecutively to building or be moved to another (persistent) directory.<br />
<br />
==== ccache ====<br />
<br />
The use of [[ccache]] can improve build times by caching the results of compilations.<br />
<br />
=== Generate new checksums ===<br />
Since [http://allanmcrae.com/2013/04/pacman-4-1-released/ pacman 4.1], {{ic|makepkg -g >> PKGBUILD}} is no longer required because pacman-contrib was [https://projects.archlinux.org/pacman.git/tree/NEWS merged into upstream pacman], including the {{ic|updpkgsums}} script that will generate new checksums and/or replace them in the PKGBUILD. In the same directory as the PKGBUILD file, run the following command:<br />
$ updpkgsums<br />
<br />
=== Makepkg source PKGBUILD twice ===<br />
Makepkg sources the PKGBUILD twice (once when initially run, and the second time under ''fakeroot''). Any non-standard functions placed in the PKGBUILD will be run twice as well.<br />
<br />
=== WARNING: Package contains reference to $srcdir ===<br />
Somehow, the literal strings {{ic|$srcdir}} or {{ic|$pkgdir}} ended up in one of the installed files in your package.<br />
<br />
To identify which files, run the following from the ''makepkg'' build directory:<br />
$ grep -R "$(pwd)/src" pkg/<br />
<br />
[http://www.mail-archive.com/arch-general@archlinux.org/msg15561.html Link] to discussion thread.<br />
<br />
=== Create uncompressed packages ===<br />
If you only want to install packages locally, you can speed up the process by avoiding the [[Wikipedia:xz|LZMA2]] compression and subsequent decompression:<br />
<br />
{{hc|/etc/makepkg.conf|2=<br />
[...]<br />
#PKGEXT='.pkg.tar.xz'<br />
PKGEXT='.pkg.tar'<br />
[...]<br />
}}<br />
<br />
=== Utilizing multiple cores on compression ===<br />
{{pkg|xz}} does support [[Wikipedia:Symmetric multiprocessing|symmetric multiprocessing (SMP)]] on compression. This can be done by adding following changes:<br />
<br />
{{hc|/etc/makepkg.conf|2=<br />
[...]<br />
COMPRESSXZ=(xz -T0 -c -z -)<br />
[...]<br />
}}<br />
<br />
<br />
<br />
=== Using Aria2 to download sources ===<br />
<br />
{{Style|{{ic|DLAGENTS}} is generic, section should not prefer one specific downloader}}<br />
<br />
You can use [[Aria2]] instead of curl to download source files, just change the {{ic|DLAGENTS}} variable as follows:<br />
<br />
{{hc|/etc/makepkg.conf|2=<br />
[...]<br />
DLAGENTS=('ftp::/usr/bin/aria2c -UWget -s4 %u -o %o'<br />
'http::/usr/bin/aria2c -UWget -s4 %u -o %o'<br />
'https::/usr/bin/aria2c -UWget -s4 %u -o %o'<br />
'rsync::/usr/bin/rsync -z %u %o'<br />
'scp::/usr/bin/scp -C %u %o')<br />
[...]<br />
}}<br />
<br />
{{Note|Use the {{ic|-UWget}} option to change the user agent to Wget. It may prevent problems when downloading from sites that filters the requests based on the user agent to provide different responses on what the users uses to access the URL. Since Aria2 is a least known downloader it may be recognized by the site as a browser instead of a downloader, so changing the user agent to Wget may fix it in most cases}}<br />
<br />
== Troubleshooting ==<br />
<br />
=== Makepkg sometimes fails to sign a package without asking for signature passphrase ===<br />
With [[gnupg]] 2.1, gpg-agent no longer has to be started manually and will be started automatically on the first invokation of gpg. <br />
<br />
Thus if you don't manually start gpg-agent, makepkg will start it. <br />
<br />
The problem is that makepkg runs gpg inside a fakeroot, so gpg-agent is also started in that same environment. This leads<br />
to bad behavior.<br />
<br />
The obvious remedy is to manually start the gpg-agent, either on boot or by command, before you run makepkg.<br />
<br />
See [[GnuPG#gpg-agent]] for ways to do this.<br />
<br />
== See also ==<br />
* [https://www.archlinux.org/pacman/makepkg.8.html makepkg(8) Manual Page]<br />
* [https://www.archlinux.org/pacman/makepkg.conf.5.html makepkg.conf(5) Manual Page]<br />
* [https://github.com/pixelb/scripts/blob/master/scripts/gcccpuopt gcccpuopt]: A script to print the GCC CPU-specific options tailored for the current CPU</div>Captaincurriehttps://wiki.archlinux.org/index.php?title=Systemd-nspawn&diff=357492Systemd-nspawn2015-01-21T11:17:43Z<p>Captaincurrie: /* Networking */ Added examples section; cleaned up language</p>
<hr />
<div>{{Lowercase title}}<br />
[[Category:Virtualization]]<br />
[[Category:Linux Containers]]<br />
[[ja:Systemd-nspawn]]<br />
{{Related articles start}}<br />
{{Related|systemd}}<br />
{{Related|Linux Containers}}<br />
{{Related|systemd-networkd}}<br />
{{Related|Docker}}<br />
{{Related|Lxc-systemd}}<br />
{{Related articles end}}<br />
<br />
''systemd-nspawn'' is like the [[chroot]] command, but it is a ''chroot on steroids''.<br />
<br />
''systemd-nspawn'' may be used to run a command or OS in a light-weight namespace container. It is more powerful than [[chroot]] since it fully virtualizes the file system hierarchy, as well as the process tree, the various IPC subsystems and the host and domain name.<br />
<br />
''systemd-nspawn'' limits access to various kernel interfaces in the container to read-only, such as {{ic|/sys}}, {{ic|/proc/sys}} or {{ic|/sys/fs/selinux}}. Network interfaces and the system clock may not be changed from within the container. Device nodes may not be created. The host system cannot be rebooted and kernel modules may not be loaded from within the container.<br />
<br />
This mechanism differs from [[Lxc-systemd]] or [[Libvirt]]-lxc, as it is a much simpler tool to configure.<br />
== Installation ==<br />
''systemd-nspawn'' is part of and packaged with {{Pkg|systemd}}. <br />
<br />
== Examples ==<br />
=== Create and boot a minimal Arch Linux distribution in a container ===<br />
<br />
First install {{Pkg|arch-install-scripts}}.<br />
<br />
Next, create a directory to hold the container. In this example we will use {{ic|~/MyContainer}}. <br />
<br />
Next, we use pacstrap to install a basic arch-system into the container.<br />
At minimum we need to install the {{Grp|base}} group. <br />
<br />
# pacstrap -i -c -d ~/MyContainer base [additional pkgs/groups]<br />
<br />
{{Tip| the '''-i''' option will '''avoid''' auto-confirmation of package selection. As you don't need to install the Linux kernel in the container, you can remove it from the package list selection to save space. See [[Pacman#Usage]].}}<br />
<br />
Once your installation is finished, boot into the container:<br />
# systemd-nspawn -bD ~/MyContainer<br />
<br />
And that's it! Log in as "root" with no password.<br />
<br />
To terminate your session hold {{ic|Ctrl}} and press {{ic|]}} three times.<br />
The container will still be running, only your session is terminated.<br />
<br />
=== Enable Container on boot ===<br />
<br />
If you want to use a container frequently, you can have systemd start it on boot.<br />
<br />
# mv ~/MyContainer /var/lib/container/MyContainer<br />
# systemctl enable systemd-nspawn@MyContainer.service<br />
# systemctl start systemd-nspawn@MyContainer.service<br />
<br />
{{Note| ''systemd-nspawn@.service'' is a template unit that expects nspawn containers to be under {{ic|/var/lib/container}}.}} <br />
{{Tip|<br />
* Instead of moving your container, as above, you can just ''symlink'' it to where it is expected to be,<br />
# ln -s ~/MyContainer /var/lib/container/MyContainer<br />
* The template ''systemd-nspawn@.service'' contains<br />
<nowiki>ExecStart = /usr/bin/systemd-nspawn --quiet --keep-unit --boot --link-journal=guest --directory=/var/lib/container/%i </nowiki><br />
To customize the startup of a container, add ''.conf'' files (See {{ic|systemd.unit(1)}}) under ''systemd-nspawn@MyContainer.service.d'' or by writing your own service file. <br />
<br />
See {{ic|systemd-nspawn(1)}} for all options.<br />
}}<br />
<br />
=== Building and Testing packages ===<br />
{{Expansion| Please share how systemd-nspawn fits into your build environment}}<br />
== Management ==<br />
=== machinectl ===<br />
<br />
Managing your containers is essentially done with the {{ic|machinectl}} command. See {{ic|machinectl(1)}} for more detail then listed here.<br />
<br />
Examples:<br />
<br />
* Spawn a new shell inside a running container: {{bc|machinectl login MyContainer}}<br />
* Show detailed information about a container: {{bc| machinectl status MyContainer}}<br />
* Reboot a container: {{bc| machinectl reboot MyContainer}}<br />
* Poweroff a container: {{bc| machinectrl poweroff MyContainer}}<br />
{{Tip| shutdown and reboot operations can be performed from within a container session using the systemd {{ic|reboot}} and {{ic|shutdown}} commands}}<br />
<br />
=== systemd toolchain ===<br />
Much of the core systemd toolchain has been updated to work with containers. Tools that do usually provide<br />
a {{ic|1= -M, --machine=}}option which will take a container name as argument.<br />
<br />
Examples:<br />
<br />
* See journal logs for a particular machine: {{bc| $ journalctl -M MyContainer}}<br />
* Show control group contents: {{bc|$ systemd-cgls -M MyContainer}}<br />
* See startup time of container: {{bc|$ systemd-analyze -M MyContainer}}<br />
<br />
== Tips ==<br />
=== X environment ===<br />
<br />
See [[Xhost]] and [[Change root#Run_graphical_applications_from_chroot]].<br />
<br />
You will need to set the {{ic|DISPLAY}} environment variable inside your container session to connect to the external X server.<br />
=== Networking ===<br />
<br />
The examples above will give the container a workable network, with no extra configuration needed. <br />
<br />
You can describe more complex networks using [[systemd-networkd]].<br />
<br />
==== Examples ====<br />
{{Expansion| This section needs some good example network setups}}<br />
<br />
==Troubleshooting ==<br />
<br />
=== root login fails ===<br />
If you get the following when you try to login:<br />
<br />
arch-nspawn login: root<br />
Login incorrect<br />
<br />
And ''journalctl'' shows:<br />
<br />
pam_securetty(login:auth): access denied: tty 'pts/0' is not secure !<br />
<br />
remove {{ic|/etc/securetty}} from the '''container''' filesystem.<br />
See [http://unix.stackexchange.com/questions/41840/effect-of-entries-in-etc-securetty/41939#41939].<br />
<br />
== See also ==<br />
* [http://www.freedesktop.org/software/systemd/man/machinectl.html machinectl man page]<br />
* [http://www.freedesktop.org/software/systemd/man/systemd-nspawn.html systemd-nspawn man page]<br />
* [http://lwn.net/Articles/572957/ Creating containers with systemd-nspawn]<br />
* [https://www.youtube.com/results?search_query=systemd-nspawn&aq=f Presentation by Lennart Pottering on systemd-nspawn]</div>Captaincurriehttps://wiki.archlinux.org/index.php?title=Systemd-nspawn&diff=357491Systemd-nspawn2015-01-21T11:12:14Z<p>Captaincurrie: /* machinectl */ language</p>
<hr />
<div>{{Lowercase title}}<br />
[[Category:Virtualization]]<br />
[[Category:Linux Containers]]<br />
[[ja:Systemd-nspawn]]<br />
{{Related articles start}}<br />
{{Related|systemd}}<br />
{{Related|Linux Containers}}<br />
{{Related|systemd-networkd}}<br />
{{Related|Docker}}<br />
{{Related|Lxc-systemd}}<br />
{{Related articles end}}<br />
<br />
''systemd-nspawn'' is like the [[chroot]] command, but it is a ''chroot on steroids''.<br />
<br />
''systemd-nspawn'' may be used to run a command or OS in a light-weight namespace container. It is more powerful than [[chroot]] since it fully virtualizes the file system hierarchy, as well as the process tree, the various IPC subsystems and the host and domain name.<br />
<br />
''systemd-nspawn'' limits access to various kernel interfaces in the container to read-only, such as {{ic|/sys}}, {{ic|/proc/sys}} or {{ic|/sys/fs/selinux}}. Network interfaces and the system clock may not be changed from within the container. Device nodes may not be created. The host system cannot be rebooted and kernel modules may not be loaded from within the container.<br />
<br />
This mechanism differs from [[Lxc-systemd]] or [[Libvirt]]-lxc, as it is a much simpler tool to configure.<br />
== Installation ==<br />
''systemd-nspawn'' is part of and packaged with {{Pkg|systemd}}. <br />
<br />
== Examples ==<br />
=== Create and boot a minimal Arch Linux distribution in a container ===<br />
<br />
First install {{Pkg|arch-install-scripts}}.<br />
<br />
Next, create a directory to hold the container. In this example we will use {{ic|~/MyContainer}}. <br />
<br />
Next, we use pacstrap to install a basic arch-system into the container.<br />
At minimum we need to install the {{Grp|base}} group. <br />
<br />
# pacstrap -i -c -d ~/MyContainer base [additional pkgs/groups]<br />
<br />
{{Tip| the '''-i''' option will '''avoid''' auto-confirmation of package selection. As you don't need to install the Linux kernel in the container, you can remove it from the package list selection to save space. See [[Pacman#Usage]].}}<br />
<br />
Once your installation is finished, boot into the container:<br />
# systemd-nspawn -bD ~/MyContainer<br />
<br />
And that's it! Log in as "root" with no password.<br />
<br />
To terminate your session hold {{ic|Ctrl}} and press {{ic|]}} three times.<br />
The container will still be running, only your session is terminated.<br />
<br />
=== Enable Container on boot ===<br />
<br />
If you want to use a container frequently, you can have systemd start it on boot.<br />
<br />
# mv ~/MyContainer /var/lib/container/MyContainer<br />
# systemctl enable systemd-nspawn@MyContainer.service<br />
# systemctl start systemd-nspawn@MyContainer.service<br />
<br />
{{Note| ''systemd-nspawn@.service'' is a template unit that expects nspawn containers to be under {{ic|/var/lib/container}}.}} <br />
{{Tip|<br />
* Instead of moving your container, as above, you can just ''symlink'' it to where it is expected to be,<br />
# ln -s ~/MyContainer /var/lib/container/MyContainer<br />
* The template ''systemd-nspawn@.service'' contains<br />
<nowiki>ExecStart = /usr/bin/systemd-nspawn --quiet --keep-unit --boot --link-journal=guest --directory=/var/lib/container/%i </nowiki><br />
To customize the startup of a container, add ''.conf'' files (See {{ic|systemd.unit(1)}}) under ''systemd-nspawn@MyContainer.service.d'' or by writing your own service file. <br />
<br />
See {{ic|systemd-nspawn(1)}} for all options.<br />
}}<br />
<br />
=== Building and Testing packages ===<br />
{{Expansion| Please share how systemd-nspawn fits into your build environment}}<br />
== Management ==<br />
=== machinectl ===<br />
<br />
Managing your containers is essentially done with the {{ic|machinectl}} command. See {{ic|machinectl(1)}} for more detail then listed here.<br />
<br />
Examples:<br />
<br />
* Spawn a new shell inside a running container: {{bc|machinectl login MyContainer}}<br />
* Show detailed information about a container: {{bc| machinectl status MyContainer}}<br />
* Reboot a container: {{bc| machinectl reboot MyContainer}}<br />
* Poweroff a container: {{bc| machinectrl poweroff MyContainer}}<br />
{{Tip| shutdown and reboot operations can be performed from within a container session using the systemd {{ic|reboot}} and {{ic|shutdown}} commands}}<br />
<br />
=== systemd toolchain ===<br />
Much of the core systemd toolchain has been updated to work with containers. Tools that do usually provide<br />
a {{ic|1= -M, --machine=}}option which will take a container name as argument.<br />
<br />
Examples:<br />
<br />
* See journal logs for a particular machine: {{bc| $ journalctl -M MyContainer}}<br />
* Show control group contents: {{bc|$ systemd-cgls -M MyContainer}}<br />
* See startup time of container: {{bc|$ systemd-analyze -M MyContainer}}<br />
<br />
== Tips ==<br />
=== X environment ===<br />
<br />
See [[Xhost]] and [[Change root#Run_graphical_applications_from_chroot]].<br />
<br />
You will need to set the {{ic|DISPLAY}} environment variable inside your container session to connect to the external X server.<br />
=== Networking ===<br />
<br />
The above described installation will give the container a right out of the box workable network, with no extra configuration needed. If you want a more complex network setup and isolate the container network from your host network, please visit the [[systemd-networkd| systemd-networkd Arch wiki]]<br />
<br />
==Troubleshooting ==<br />
<br />
=== root login fails ===<br />
If you get the following when you try to login:<br />
<br />
arch-nspawn login: root<br />
Login incorrect<br />
<br />
And ''journalctl'' shows:<br />
<br />
pam_securetty(login:auth): access denied: tty 'pts/0' is not secure !<br />
<br />
remove {{ic|/etc/securetty}} from the '''container''' filesystem.<br />
See [http://unix.stackexchange.com/questions/41840/effect-of-entries-in-etc-securetty/41939#41939].<br />
<br />
== See also ==<br />
* [http://www.freedesktop.org/software/systemd/man/machinectl.html machinectl man page]<br />
* [http://www.freedesktop.org/software/systemd/man/systemd-nspawn.html systemd-nspawn man page]<br />
* [http://lwn.net/Articles/572957/ Creating containers with systemd-nspawn]<br />
* [https://www.youtube.com/results?search_query=systemd-nspawn&aq=f Presentation by Lennart Pottering on systemd-nspawn]</div>Captaincurriehttps://wiki.archlinux.org/index.php?title=Systemd-nspawn&diff=357490Systemd-nspawn2015-01-21T11:10:51Z<p>Captaincurrie: /* Enable Container on boot */ language</p>
<hr />
<div>{{Lowercase title}}<br />
[[Category:Virtualization]]<br />
[[Category:Linux Containers]]<br />
[[ja:Systemd-nspawn]]<br />
{{Related articles start}}<br />
{{Related|systemd}}<br />
{{Related|Linux Containers}}<br />
{{Related|systemd-networkd}}<br />
{{Related|Docker}}<br />
{{Related|Lxc-systemd}}<br />
{{Related articles end}}<br />
<br />
''systemd-nspawn'' is like the [[chroot]] command, but it is a ''chroot on steroids''.<br />
<br />
''systemd-nspawn'' may be used to run a command or OS in a light-weight namespace container. It is more powerful than [[chroot]] since it fully virtualizes the file system hierarchy, as well as the process tree, the various IPC subsystems and the host and domain name.<br />
<br />
''systemd-nspawn'' limits access to various kernel interfaces in the container to read-only, such as {{ic|/sys}}, {{ic|/proc/sys}} or {{ic|/sys/fs/selinux}}. Network interfaces and the system clock may not be changed from within the container. Device nodes may not be created. The host system cannot be rebooted and kernel modules may not be loaded from within the container.<br />
<br />
This mechanism differs from [[Lxc-systemd]] or [[Libvirt]]-lxc, as it is a much simpler tool to configure.<br />
== Installation ==<br />
''systemd-nspawn'' is part of and packaged with {{Pkg|systemd}}. <br />
<br />
== Examples ==<br />
=== Create and boot a minimal Arch Linux distribution in a container ===<br />
<br />
First install {{Pkg|arch-install-scripts}}.<br />
<br />
Next, create a directory to hold the container. In this example we will use {{ic|~/MyContainer}}. <br />
<br />
Next, we use pacstrap to install a basic arch-system into the container.<br />
At minimum we need to install the {{Grp|base}} group. <br />
<br />
# pacstrap -i -c -d ~/MyContainer base [additional pkgs/groups]<br />
<br />
{{Tip| the '''-i''' option will '''avoid''' auto-confirmation of package selection. As you don't need to install the Linux kernel in the container, you can remove it from the package list selection to save space. See [[Pacman#Usage]].}}<br />
<br />
Once your installation is finished, boot into the container:<br />
# systemd-nspawn -bD ~/MyContainer<br />
<br />
And that's it! Log in as "root" with no password.<br />
<br />
To terminate your session hold {{ic|Ctrl}} and press {{ic|]}} three times.<br />
The container will still be running, only your session is terminated.<br />
<br />
=== Enable Container on boot ===<br />
<br />
If you want to use a container frequently, you can have systemd start it on boot.<br />
<br />
# mv ~/MyContainer /var/lib/container/MyContainer<br />
# systemctl enable systemd-nspawn@MyContainer.service<br />
# systemctl start systemd-nspawn@MyContainer.service<br />
<br />
{{Note| ''systemd-nspawn@.service'' is a template unit that expects nspawn containers to be under {{ic|/var/lib/container}}.}} <br />
{{Tip|<br />
* Instead of moving your container, as above, you can just ''symlink'' it to where it is expected to be,<br />
# ln -s ~/MyContainer /var/lib/container/MyContainer<br />
* The template ''systemd-nspawn@.service'' contains<br />
<nowiki>ExecStart = /usr/bin/systemd-nspawn --quiet --keep-unit --boot --link-journal=guest --directory=/var/lib/container/%i </nowiki><br />
To customize the startup of a container, add ''.conf'' files (See {{ic|systemd.unit(1)}}) under ''systemd-nspawn@MyContainer.service.d'' or by writing your own service file. <br />
<br />
See {{ic|systemd-nspawn(1)}} for all options.<br />
}}<br />
<br />
=== Building and Testing packages ===<br />
{{Expansion| Please share how systemd-nspawn fits into your build environment}}<br />
== Management ==<br />
=== machinectl ===<br />
<br />
Managing your containers is essentially done with the {{ic|machinectl}} command. See {{ic|machinectl(1)}} for more detail then listed here.<br />
<br />
Examples:<br />
<br />
* Spawn a new shell inside a running container: {{bc|machinectl login MyContainer}}<br />
* Show detailed information about a container: {{bc| machinectl status MyContainer}}<br />
* Reboot a container: {{bc| machinectl reboot MyContainer}}<br />
* Poweroff a container: {{bc| machinectrl poweroff MyContainer}}<br />
{{Tip| shutdown and reboot operations can be performed from within a container session using the same commands you would use<br />
in your host system}}<br />
<br />
=== systemd toolchain ===<br />
Much of the core systemd toolchain has been updated to work with containers. Tools that do usually provide<br />
a {{ic|1= -M, --machine=}}option which will take a container name as argument.<br />
<br />
Examples:<br />
<br />
* See journal logs for a particular machine: {{bc| $ journalctl -M MyContainer}}<br />
* Show control group contents: {{bc|$ systemd-cgls -M MyContainer}}<br />
* See startup time of container: {{bc|$ systemd-analyze -M MyContainer}}<br />
<br />
== Tips ==<br />
=== X environment ===<br />
<br />
See [[Xhost]] and [[Change root#Run_graphical_applications_from_chroot]].<br />
<br />
You will need to set the {{ic|DISPLAY}} environment variable inside your container session to connect to the external X server.<br />
=== Networking ===<br />
<br />
The above described installation will give the container a right out of the box workable network, with no extra configuration needed. If you want a more complex network setup and isolate the container network from your host network, please visit the [[systemd-networkd| systemd-networkd Arch wiki]]<br />
<br />
==Troubleshooting ==<br />
<br />
=== root login fails ===<br />
If you get the following when you try to login:<br />
<br />
arch-nspawn login: root<br />
Login incorrect<br />
<br />
And ''journalctl'' shows:<br />
<br />
pam_securetty(login:auth): access denied: tty 'pts/0' is not secure !<br />
<br />
remove {{ic|/etc/securetty}} from the '''container''' filesystem.<br />
See [http://unix.stackexchange.com/questions/41840/effect-of-entries-in-etc-securetty/41939#41939].<br />
<br />
== See also ==<br />
* [http://www.freedesktop.org/software/systemd/man/machinectl.html machinectl man page]<br />
* [http://www.freedesktop.org/software/systemd/man/systemd-nspawn.html systemd-nspawn man page]<br />
* [http://lwn.net/Articles/572957/ Creating containers with systemd-nspawn]<br />
* [https://www.youtube.com/results?search_query=systemd-nspawn&aq=f Presentation by Lennart Pottering on systemd-nspawn]</div>Captaincurriehttps://wiki.archlinux.org/index.php?title=User_talk:Indigo&diff=357260User talk:Indigo2015-01-20T10:12:57Z<p>Captaincurrie: /* Comments */ question</p>
<hr />
<div>Feel free to leave comments about my wiki edits or other points of interest. --[[User:Indigo|Indigo]] ([[User talk:Indigo|talk]]) 17:43, 27 September 2012 (UTC)<br />
<br />
== Comments ==<br />
Hey Indigo,<br />
<br />
I moved the, now, systemd-nspawn page yesturday. I did so before i had read the talk page and had<br />
seen that this has been discussed. I just did it because i thought it was the right thing to do. <br />
<br />
I'm still new to editing the arch wiki, what is the proper way to make these big changes while being respectful.<br />
At the same time, somebody has got to make the big changes. [[User:Captaincurrie|Captaincurrie]] ([[User talk:Captaincurrie|talk]]) 10:12, 20 January 2015 (UTC)</div>Captaincurriehttps://wiki.archlinux.org/index.php?title=Talk:Systemd-nspawn&diff=357257Talk:Systemd-nspawn2015-01-20T10:08:30Z<p>Captaincurrie: new question</p>
<hr />
<div>== <s>Rename page?</s> ==<br />
<br />
Wouldn't it be better to rename this page to [[systemd-nspawn]]? This page is ''mostly'' about this tool, so I think it is the better title. -- [[User:Lahwaacz|Lahwaacz]] ([[User talk:Lahwaacz|talk]]) 18:00, 18 March 2014 (UTC)<br />
<br />
:Note that the page contained an invalid DISPLAYTITLE entry: [https://wiki.archlinux.org/index.php?title=Arch_systemd_container&diff=306160&oldid=305960] -- [[User:Lahwaacz|Lahwaacz]] ([[User talk:Lahwaacz|talk]]) 19:58, 20 March 2014 (UTC)<br />
<br />
::Well, I guess it's ok, it would also give [[Linux Containers]] a clearer role as a generic intro to containers (only theoretical, just planned in its current Stub template note). -- [[User:Kynikos|Kynikos]] ([[User talk:Kynikos|talk]]) 17:14, 21 March 2014 (UTC)<br />
<br />
:::I like the suggestion. Good structure forward to group systemd-* toolset articles like that for the wiki. One question which arises with "systemd" themes though is when they are better served by a [[Systemd/User|systemd subpage]] and when titled as an [[Systemd-networkd|affiliated]] article (I'm sure you have covered that somewhere else before; I was looking at the [[systemd]] related links in consideration). The stub template note you refer to makes a good plan as well (one might group it under world domination plans at the same time:) Following that approach you could move and reverse redirect of this page to [[systemd-nspawn]] sometime and move/point to [[Linux Containers/systemd-nspawn]] once the stub and [[Linux Containers/LXC]] is in place. The latter being a grouping according to functionality rather than project/packaging. <br />
:::--[[User:Indigo|Indigo]] ([[User talk:Indigo|talk]]) 01:43, 22 March 2014 (UTC)<br />
<br />
::::The main reason why I prefer [[systemd-nspawn]] over [[systemd/systemd-nspawn]] is that it seems unnecessary to repeat "systemd" twice, separated just by "/" (there is no such problem for [[systemd/User]]). Grouping by the "Related articles" box should be enough.<br />
::::If you really want to group the articles in a subpage, I would prefer [[Linux Containers/systemd-nspawn]] anyway, because the subpages of [[systemd]] would cover half of the wiki already :)<br />
::::For completeness, there is also [[lxc-systemd]].<br />
::::-- [[User:Lahwaacz|Lahwaacz]] ([[User talk:Lahwaacz|talk]]) 07:46, 22 March 2014 (UTC)<br />
<br />
:::::Having systemd twice in the URL would indeed be tedious, I did not picture that. Makes good sense to distinguish whether subpage or page like that. <br />
:::::--[[User:Indigo|Indigo]] ([[User talk:Indigo|talk]]) 10:10, 22 March 2014 (UTC)<br />
<br />
:::Update: the Stub note in [[Linux Containers]] was changed with [https://wiki.archlinux.org/index.php?title=Linux_Containers&diff=next&oldid=313752]. -- [[User:Kynikos|Kynikos]] ([[User talk:Kynikos|talk]]) 06:34, 8 May 2014 (UTC)<br />
<br />
::::The stub remains/ed. Yet, Captaincurrie has moved the article to Lahwaacz's initial suggestion above. I've just checked backlinks. Closing this item. --[[User:Indigo|Indigo]] ([[User talk:Indigo|talk]]) 21:58, 19 January 2015 (UTC)<br />
<br />
== user namespaces ==<br />
<br />
systemd-nspawn ''never'' uses user namespaces, as you can see [http://cgit.freedesktop.org/systemd/systemd/tree/src/nspawn/nspawn.c?id=05947befcec9afb83b9ce48d613ff372c63e2ed1#n1394 from the source]. User namespaces do not appear to work with a chroot at all right now, because you can't enter one while in a chroot and you can't use chroot while in a user namespace. - [[User:Thestinger|thestinger]] ([[User talk:Thestinger|talk]]) 19:35, 23 April 2014 (UTC)<br />
<br />
:The report is still open, I'm restoring the link here just in case: {{Bug|36969}}. The removed content is [https://wiki.archlinux.org/index.php?title=Arch_systemd_container&curid=15990&diff=311593&oldid=309230]. -- [[User:Kynikos|Kynikos]] ([[User talk:Kynikos|talk]]) 01:45, 25 April 2014 (UTC)<br />
<br />
:In conclusion from above mentioning user namespaces was not relevant on this page (pity really). So the only way to restrict the nspawn-container appears to be limiting its capabilities on start-up (as per man systemd-nspawn). Regarding {{Bug|36969}}: it was originally opened for lxc-containers anyway and those appear to support user namespaces now. Hence, the only question remaining for this article at this point would be, if there are any remaining issues arising for systemd in general when activating CONFIG_USER_NS for lxc (opinion on that?). <br />
:I have added the bug and a couple links with background info to [[Talk:Linux_Containers#Clean.2C_practical_and_detailed_howtos_.26_links|talk:linux containers]] so the reference does not get lost. <br />
:--[[User:Indigo|Indigo]] ([[User talk:Indigo|talk]]) 08:56, 3 May 2014 (UTC)<br />
<br />
== systemd-nspawn as a build environment ==<br />
I've been struggling trying to set this up and i assume others will as well. Would be nice to have an example of a build workflow using this tool on this<br />
or on a seperate page. [[User:Captaincurrie|Captaincurrie]] ([[User talk:Captaincurrie|talk]]) 18:32, 19 January 2015 (UTC)<br />
:The {{pkg|devtools}} package implements this for Arch packaging, and is used for building everything in the repositories. It's as simple as replacing {{ic|makepkg}} with {{ic|extra-i686-build}} + {{ic|extra-x86_64-build}}. -- [[User:thestinger|thestinger]] 18:41, 19 January 2015 (UTC)<br />
:: Cool, i'll give that a try. Thanks :) [[User:Captaincurrie|Captaincurrie]] ([[User talk:Captaincurrie|talk]]) 10:05, 20 January 2015 (UTC)<br />
<br />
== systemd-nspawn usage examples ==<br />
This page needs lots of awesome usage examples because its such an awesome tool. Please give suggestions. [[User:Captaincurrie|Captaincurrie]] ([[User talk:Captaincurrie|talk]]) 10:08, 20 January 2015 (UTC)</div>Captaincurriehttps://wiki.archlinux.org/index.php?title=Talk:Systemd-nspawn&diff=357256Talk:Systemd-nspawn2015-01-20T10:05:30Z<p>Captaincurrie: /* systemd-nspawn as a build environment */ reply to thesinger</p>
<hr />
<div>== <s>Rename page?</s> ==<br />
<br />
Wouldn't it be better to rename this page to [[systemd-nspawn]]? This page is ''mostly'' about this tool, so I think it is the better title. -- [[User:Lahwaacz|Lahwaacz]] ([[User talk:Lahwaacz|talk]]) 18:00, 18 March 2014 (UTC)<br />
<br />
:Note that the page contained an invalid DISPLAYTITLE entry: [https://wiki.archlinux.org/index.php?title=Arch_systemd_container&diff=306160&oldid=305960] -- [[User:Lahwaacz|Lahwaacz]] ([[User talk:Lahwaacz|talk]]) 19:58, 20 March 2014 (UTC)<br />
<br />
::Well, I guess it's ok, it would also give [[Linux Containers]] a clearer role as a generic intro to containers (only theoretical, just planned in its current Stub template note). -- [[User:Kynikos|Kynikos]] ([[User talk:Kynikos|talk]]) 17:14, 21 March 2014 (UTC)<br />
<br />
:::I like the suggestion. Good structure forward to group systemd-* toolset articles like that for the wiki. One question which arises with "systemd" themes though is when they are better served by a [[Systemd/User|systemd subpage]] and when titled as an [[Systemd-networkd|affiliated]] article (I'm sure you have covered that somewhere else before; I was looking at the [[systemd]] related links in consideration). The stub template note you refer to makes a good plan as well (one might group it under world domination plans at the same time:) Following that approach you could move and reverse redirect of this page to [[systemd-nspawn]] sometime and move/point to [[Linux Containers/systemd-nspawn]] once the stub and [[Linux Containers/LXC]] is in place. The latter being a grouping according to functionality rather than project/packaging. <br />
:::--[[User:Indigo|Indigo]] ([[User talk:Indigo|talk]]) 01:43, 22 March 2014 (UTC)<br />
<br />
::::The main reason why I prefer [[systemd-nspawn]] over [[systemd/systemd-nspawn]] is that it seems unnecessary to repeat "systemd" twice, separated just by "/" (there is no such problem for [[systemd/User]]). Grouping by the "Related articles" box should be enough.<br />
::::If you really want to group the articles in a subpage, I would prefer [[Linux Containers/systemd-nspawn]] anyway, because the subpages of [[systemd]] would cover half of the wiki already :)<br />
::::For completeness, there is also [[lxc-systemd]].<br />
::::-- [[User:Lahwaacz|Lahwaacz]] ([[User talk:Lahwaacz|talk]]) 07:46, 22 March 2014 (UTC)<br />
<br />
:::::Having systemd twice in the URL would indeed be tedious, I did not picture that. Makes good sense to distinguish whether subpage or page like that. <br />
:::::--[[User:Indigo|Indigo]] ([[User talk:Indigo|talk]]) 10:10, 22 March 2014 (UTC)<br />
<br />
:::Update: the Stub note in [[Linux Containers]] was changed with [https://wiki.archlinux.org/index.php?title=Linux_Containers&diff=next&oldid=313752]. -- [[User:Kynikos|Kynikos]] ([[User talk:Kynikos|talk]]) 06:34, 8 May 2014 (UTC)<br />
<br />
::::The stub remains/ed. Yet, Captaincurrie has moved the article to Lahwaacz's initial suggestion above. I've just checked backlinks. Closing this item. --[[User:Indigo|Indigo]] ([[User talk:Indigo|talk]]) 21:58, 19 January 2015 (UTC)<br />
<br />
== user namespaces ==<br />
<br />
systemd-nspawn ''never'' uses user namespaces, as you can see [http://cgit.freedesktop.org/systemd/systemd/tree/src/nspawn/nspawn.c?id=05947befcec9afb83b9ce48d613ff372c63e2ed1#n1394 from the source]. User namespaces do not appear to work with a chroot at all right now, because you can't enter one while in a chroot and you can't use chroot while in a user namespace. - [[User:Thestinger|thestinger]] ([[User talk:Thestinger|talk]]) 19:35, 23 April 2014 (UTC)<br />
<br />
:The report is still open, I'm restoring the link here just in case: {{Bug|36969}}. The removed content is [https://wiki.archlinux.org/index.php?title=Arch_systemd_container&curid=15990&diff=311593&oldid=309230]. -- [[User:Kynikos|Kynikos]] ([[User talk:Kynikos|talk]]) 01:45, 25 April 2014 (UTC)<br />
<br />
:In conclusion from above mentioning user namespaces was not relevant on this page (pity really). So the only way to restrict the nspawn-container appears to be limiting its capabilities on start-up (as per man systemd-nspawn). Regarding {{Bug|36969}}: it was originally opened for lxc-containers anyway and those appear to support user namespaces now. Hence, the only question remaining for this article at this point would be, if there are any remaining issues arising for systemd in general when activating CONFIG_USER_NS for lxc (opinion on that?). <br />
:I have added the bug and a couple links with background info to [[Talk:Linux_Containers#Clean.2C_practical_and_detailed_howtos_.26_links|talk:linux containers]] so the reference does not get lost. <br />
:--[[User:Indigo|Indigo]] ([[User talk:Indigo|talk]]) 08:56, 3 May 2014 (UTC)<br />
<br />
== systemd-nspawn as a build environment ==<br />
I've been struggling trying to set this up and i assume others will as well. Would be nice to have an example of a build workflow using this tool on this<br />
or on a seperate page. [[User:Captaincurrie|Captaincurrie]] ([[User talk:Captaincurrie|talk]]) 18:32, 19 January 2015 (UTC)<br />
:The {{pkg|devtools}} package implements this for Arch packaging, and is used for building everything in the repositories. It's as simple as replacing {{ic|makepkg}} with {{ic|extra-i686-build}} + {{ic|extra-x86_64-build}}. -- [[User:thestinger|thestinger]] 18:41, 19 January 2015 (UTC)<br />
:: Cool, i'll give that a try. Thanks :) [[User:Captaincurrie|Captaincurrie]] ([[User talk:Captaincurrie|talk]]) 10:05, 20 January 2015 (UTC)</div>Captaincurriehttps://wiki.archlinux.org/index.php?title=Systemd-nspawn&diff=357255Systemd-nspawn2015-01-20T10:04:15Z<p>Captaincurrie: language.</p>
<hr />
<div>{{Lowercase title}}<br />
[[Category:Virtualization]]<br />
[[Category:Linux Containers]]<br />
[[ja:Systemd-nspawn]]<br />
{{Related articles start}}<br />
{{Related|systemd}}<br />
{{Related|Linux Containers}}<br />
{{Related|systemd-networkd}}<br />
{{Related|Docker}}<br />
{{Related|Lxc-systemd}}<br />
{{Related articles end}}<br />
<br />
''systemd-nspawn'' is like the [[chroot]] command, but it is a ''chroot on steroids''.<br />
<br />
''systemd-nspawn'' may be used to run a command or OS in a light-weight namespace container. It is more powerful than [[chroot]] since it fully virtualizes the file system hierarchy, as well as the process tree, the various IPC subsystems and the host and domain name.<br />
<br />
''systemd-nspawn'' limits access to various kernel interfaces in the container to read-only, such as {{ic|/sys}}, {{ic|/proc/sys}} or {{ic|/sys/fs/selinux}}. Network interfaces and the system clock may not be changed from within the container. Device nodes may not be created. The host system cannot be rebooted and kernel modules may not be loaded from within the container.<br />
<br />
This mechanism differs from [[Lxc-systemd]] or [[Libvirt]]-lxc, as it is a much simpler tool to configure.<br />
== Installation ==<br />
''systemd-nspawn'' is part of and packaged with {{Pkg|systemd}}. <br />
<br />
== Examples ==<br />
=== Create and boot a minimal Arch Linux distribution in a container ===<br />
<br />
First install {{Pkg|arch-install-scripts}}.<br />
<br />
Next, create a directory to hold the container. In this example we will use {{ic|~/MyContainer}}. <br />
<br />
Next, we use pacstrap to install a basic arch-system into the container.<br />
At minimum we need to install the {{Grp|base}} group. <br />
<br />
# pacstrap -i -c -d ~/MyContainer base [additional pkgs/groups]<br />
<br />
{{Tip| the '''-i''' option will '''avoid''' auto-confirmation of package selection. As you don't need to install the Linux kernel in the container, you can remove it from the package list selection to save space. See [[Pacman#Usage]].}}<br />
<br />
Once your installation is finished, boot into the container:<br />
# systemd-nspawn -bD ~/MyContainer<br />
<br />
And that's it! Log in as "root" with no password.<br />
<br />
To terminate your session hold {{ic|Ctrl}} and press {{ic|]}} three times.<br />
The container will still be running, only your session is terminated.<br />
<br />
=== Enable Container on boot ===<br />
<br />
If you want to use a container frequently, you can have systemd start it on boot.<br />
<br />
# mv ~/MyContainer /var/lib/container/MyContainer<br />
# systemctl enable systemd-nspawn@MyContainer.service<br />
# systemctl start systemd-nspawn@MyContainer.service<br />
<br />
{{Note| ''systemd-nspawn@.service'' expects nspawn containers to be under {{ic|/var/lib/container}}.}} <br />
{{Tip|<br />
* Instead of moving your container, as above, you use a symlink<br />
# ln -s ~/MyContainer /var/lib/container/MyContainer<br />
* The template ''systemd-nspawn@.service'' contains<br />
<nowiki>ExecStart = /usr/bin/systemd-nspawn --quiet --keep-unit --boot --link-journal=guest --directory=/var/lib/container/%i </nowiki><br />
To customize the startup of a container, add ''.conf'' files (See {{ic|systemd.unit(1)}}) under ''systemd-nspawn@MyContainer.service.d'' or by writing your own service file. <br />
<br />
See {{ic|systemd-nspawn(1)}} for all options.<br />
}}<br />
<br />
=== Building and Testing packages ===<br />
{{Expansion| Please share how systemd-nspawn fits into your build environment}}<br />
== Management ==<br />
=== machinectl ===<br />
<br />
Managing your containers is essentially done with the {{ic|machinectl}} command. See {{ic|machinectl(1)}} for more detail then listed here.<br />
<br />
Examples:<br />
<br />
* Spawn a new shell inside a running container: {{bc|machinectl login MyContainer}}<br />
* Show detailed information about a container: {{bc| machinectl status MyContainer}}<br />
* Reboot a container: {{bc| machinectl reboot MyContainer}}<br />
* Poweroff a container: {{bc| machinectrl poweroff MyContainer}}<br />
{{Tip| shutdown and reboot operations can be performed from within a container session using the same commands you would use<br />
in your host system}}<br />
<br />
=== systemd toolchain ===<br />
Much of the core systemd toolchain has been updated to work with containers. Tools that do usually provide<br />
a {{ic|1= -M, --machine=}}option which will take a container name as argument.<br />
<br />
Examples:<br />
<br />
* See journal logs for a particular machine: {{bc| $ journalctl -M MyContainer}}<br />
* Show control group contents: {{bc|$ systemd-cgls -M MyContainer}}<br />
* See startup time of container: {{bc|$ systemd-analyze -M MyContainer}}<br />
<br />
== Tips ==<br />
=== X environment ===<br />
<br />
See [[Xhost]] and [[Change root#Run_graphical_applications_from_chroot]].<br />
<br />
You will need to set the {{ic|DISPLAY}} environment variable inside your container session to connect to the external X server.<br />
=== Networking ===<br />
<br />
The above described installation will give the container a right out of the box workable network, with no extra configuration needed. If you want a more complex network setup and isolate the container network from your host network, please visit the [[systemd-networkd| systemd-networkd Arch wiki]]<br />
<br />
==Troubleshooting ==<br />
<br />
=== root login fails ===<br />
If you get the following when you try to login:<br />
<br />
arch-nspawn login: root<br />
Login incorrect<br />
<br />
And ''journalctl'' shows:<br />
<br />
pam_securetty(login:auth): access denied: tty 'pts/0' is not secure !<br />
<br />
remove {{ic|/etc/securetty}} from the '''container''' filesystem.<br />
See [http://unix.stackexchange.com/questions/41840/effect-of-entries-in-etc-securetty/41939#41939].<br />
<br />
== See also ==<br />
* [http://www.freedesktop.org/software/systemd/man/machinectl.html machinectl man page]<br />
* [http://www.freedesktop.org/software/systemd/man/systemd-nspawn.html systemd-nspawn man page]<br />
* [http://lwn.net/Articles/572957/ Creating containers with systemd-nspawn]<br />
* [https://www.youtube.com/results?search_query=systemd-nspawn&aq=f Presentation by Lennart Pottering on systemd-nspawn]</div>Captaincurriehttps://wiki.archlinux.org/index.php?title=Systemd-nspawn&diff=357168Systemd-nspawn2015-01-19T19:51:01Z<p>Captaincurrie: /* Enable Container on boot */ language</p>
<hr />
<div>{{Lowercase title}}<br />
[[Category:Virtualization]]<br />
[[Category:Linux Containers]]<br />
[[ja:Systemd-nspawn]]<br />
{{Related articles start}}<br />
{{Related|systemd}}<br />
{{Related|Linux Containers}}<br />
{{Related|systemd-networkd}}<br />
{{Related|Docker}}<br />
{{Related|Lxc-systemd}}<br />
{{Related articles end}}<br />
<br />
''systemd-nspawn'' is like the [[chroot]] command, but it is a ''chroot on steroids''.<br />
<br />
''systemd-nspawn'' may be used to run a command or OS in a light-weight namespace container. It is more powerful than [[chroot]] since it fully virtualizes the file system hierarchy, as well as the process tree, the various IPC subsystems and the host and domain name.<br />
<br />
''systemd-nspawn'' limits access to various kernel interfaces in the container to read-only, such as {{ic|/sys}}, {{ic|/proc/sys}} or {{ic|/sys/fs/selinux}}. Network interfaces and the system clock may not be changed from within the container. Device nodes may not be created. The host system cannot be rebooted and kernel modules may not be loaded from within the container.<br />
<br />
This mechanism differs from [[Lxc-systemd]] or [[Libvirt]]-lxc, as it is a much simpler tool to configure.<br />
== Installation ==<br />
''systemd-nspawn'' itself is part of and packaged with {{Pkg|systemd}}. <br />
<br />
== Examples ==<br />
=== Create and boot a minimal Arch Linux distribution in a container ===<br />
<br />
First install {{Pkg|arch-install-scripts}}.<br />
<br />
Next, create a directory to hold the container. In this example we will use {{ic|~/MyContainer}}. <br />
<br />
Next, we use pacstrap to install a basic arch-system into the container.<br />
At minimum we need to install the {{Grp|base}} group. <br />
<br />
# pacstrap -i -c -d ~/MyContainer base [additional pkgs/groups]<br />
<br />
{{Tip| the '''-i''' option will '''avoid''' auto-confirmation of package selection. As you don't need to install the Linux kernel in the container, you can remove it from the package list selection to save space. See [[Pacman#Usage]].}}<br />
<br />
Once your installation is finished, boot into the container:<br />
# systemd-nspawn -bD ~/MyContainer<br />
<br />
And that's it! Log in as "root" with no password.<br />
<br />
To terminate your session hold {{ic|Ctrl}} and press {{ic|]}} three times.<br />
The container will still be running, only your session is terminated.<br />
<br />
=== Enable Container on boot ===<br />
<br />
If you want to use a container frequently, you can have systemd start it on boot.<br />
<br />
# mv ~/MyContainer /var/lib/container/MyContainer<br />
# systemctl enable systemd-nspawn@MyContainer.service<br />
# systemctl start systemd-nspawn@MyContainer.service<br />
<br />
{{Note| ''systemd-nspawn@.service'' expects nspawn containers to be under {{ic|/var/lib/container}}.}} <br />
{{Tip|<br />
* Instead of moving your container, as above, you use a symlink<br />
# ln -s ~/MyContainer /var/lib/container/MyContainer<br />
* The template ''systemd-nspawn@.service'' contains<br />
<nowiki>ExecStart = /usr/bin/systemd-nspawn --quiet --keep-unit --boot --link-journal=guest --directory=/var/lib/container/%i </nowiki><br />
To customize the startup of a container, add ''.conf'' files (See {{ic|systemd.unit(1)}}) under ''systemd-nspawn@MyContainer.service.d'' or by writing your own service file. <br />
<br />
See {{ic|systemd-nspawn(1)}} for all options.<br />
}}<br />
<br />
=== Building and Testing packages ===<br />
{{Expansion| Please share how systemd-nspawn fits into your build environment}}<br />
== Management ==<br />
=== machinectl ===<br />
<br />
Managing your containers is essentially done with the {{ic|machinectl}} command. See {{ic|machinectl(1)}} for more detail then listed here.<br />
<br />
Examples:<br />
<br />
* Spawn a new shell inside a running container: {{bc|machinectl login MyContainer}}<br />
* Show detailed information about a container: {{bc| machinectl status MyContainer}}<br />
* Reboot a container: {{bc| machinectl reboot MyContainer}}<br />
* Poweroff a container: {{bc| machinectrl poweroff MyContainer}}<br />
{{Note| shutdown and reboot operations can be performed from within a container session using the same commands you would use<br />
in your host system}}<br />
<br />
=== systemd toolchain ===<br />
Much of the core systemd toolchain has been updated to work with containers. Tools that do usually provide<br />
a {{ic|1= -M, --machine=}}option which will take a container name as argument.<br />
<br />
Examples:<br />
<br />
* See journal logs for a particular machine: {{bc| $ journalctl -M MyContainer}}<br />
* Show control group contents: {{bc|$ systemd-cgls -M MyContainer}}<br />
* See startup time of container: {{bc|$ systemd-analyze -M MyContainer}}<br />
<br />
== Tips ==<br />
=== X environment ===<br />
<br />
See [[Xhost]] and [[Change root#Run_graphical_applications_from_chroot]].<br />
<br />
You will need to set the {{ic|DISPLAY}} environment variable inside your container session to connect to the external X server.<br />
=== Networking ===<br />
<br />
The above described installation will give the container a right out of the box workable network, with no extra configuration needed. If you want a more complex network setup and isolate the container network from your host network, please visit the [[systemd-networkd| systemd-networkd Arch wiki]]<br />
<br />
==Troubleshooting ==<br />
<br />
=== root login fails ===<br />
If you get the following when you try to login:<br />
<br />
arch-nspawn login: root<br />
Login incorrect<br />
<br />
And ''journalctl'' shows:<br />
<br />
pam_securetty(login:auth): access denied: tty 'pts/0' is not secure !<br />
<br />
Just try to [http://unix.stackexchange.com/questions/41840/effect-of-entries-in-etc-securetty/41939#41939 remove /etc/securetty] from the container filesystem.<br />
<br />
= See also =<br />
* [http://www.freedesktop.org/software/systemd/man/machinectl.html machinectl man page]<br />
* [http://www.freedesktop.org/software/systemd/man/systemd-nspawn.html systemd-nspawn man page]<br />
* [http://lwn.net/Articles/572957/ Creating containers with systemd-nspawn]<br />
* [https://www.youtube.com/results?search_query=systemd-nspawn&aq=f Presentation by Lennart Pottering on systemd-nspawn]</div>Captaincurriehttps://wiki.archlinux.org/index.php?title=Systemd-nspawn&diff=357167Systemd-nspawn2015-01-19T19:50:47Z<p>Captaincurrie: /* Enable Container on boot */ cleaned up language</p>
<hr />
<div>{{Lowercase title}}<br />
[[Category:Virtualization]]<br />
[[Category:Linux Containers]]<br />
[[ja:Systemd-nspawn]]<br />
{{Related articles start}}<br />
{{Related|systemd}}<br />
{{Related|Linux Containers}}<br />
{{Related|systemd-networkd}}<br />
{{Related|Docker}}<br />
{{Related|Lxc-systemd}}<br />
{{Related articles end}}<br />
<br />
''systemd-nspawn'' is like the [[chroot]] command, but it is a ''chroot on steroids''.<br />
<br />
''systemd-nspawn'' may be used to run a command or OS in a light-weight namespace container. It is more powerful than [[chroot]] since it fully virtualizes the file system hierarchy, as well as the process tree, the various IPC subsystems and the host and domain name.<br />
<br />
''systemd-nspawn'' limits access to various kernel interfaces in the container to read-only, such as {{ic|/sys}}, {{ic|/proc/sys}} or {{ic|/sys/fs/selinux}}. Network interfaces and the system clock may not be changed from within the container. Device nodes may not be created. The host system cannot be rebooted and kernel modules may not be loaded from within the container.<br />
<br />
This mechanism differs from [[Lxc-systemd]] or [[Libvirt]]-lxc, as it is a much simpler tool to configure.<br />
== Installation ==<br />
''systemd-nspawn'' itself is part of and packaged with {{Pkg|systemd}}. <br />
<br />
== Examples ==<br />
=== Create and boot a minimal Arch Linux distribution in a container ===<br />
<br />
First install {{Pkg|arch-install-scripts}}.<br />
<br />
Next, create a directory to hold the container. In this example we will use {{ic|~/MyContainer}}. <br />
<br />
Next, we use pacstrap to install a basic arch-system into the container.<br />
At minimum we need to install the {{Grp|base}} group. <br />
<br />
# pacstrap -i -c -d ~/MyContainer base [additional pkgs/groups]<br />
<br />
{{Tip| the '''-i''' option will '''avoid''' auto-confirmation of package selection. As you don't need to install the Linux kernel in the container, you can remove it from the package list selection to save space. See [[Pacman#Usage]].}}<br />
<br />
Once your installation is finished, boot into the container:<br />
# systemd-nspawn -bD ~/MyContainer<br />
<br />
And that's it! Log in as "root" with no password.<br />
<br />
To terminate your session hold {{ic|Ctrl}} and press {{ic|]}} three times.<br />
The container will still be running, only your session is terminated.<br />
<br />
=== Enable Container on boot ===<br />
<br />
If you want to use a container frequently, you can have systemd start it on boot.<br />
<br />
# mv ~/MyContainer /var/lib/container/MyContainer<br />
# systemctl enable systemd-nspawn@MyContainer.service<br />
# systemctl start systemd-nspawn@MyContainer.service<br />
<br />
{{Note| ''systemd-nspawn@.service'' expects nspawn containers to be under {{ic|/var/lib/container}}.}} <br />
{{Tip|<br />
* instead of moving your container, as above, you use a symlink<br />
# ln -s ~/MyContainer /var/lib/container/MyContainer<br />
* The template ''systemd-nspawn@.service'' contains<br />
<nowiki>ExecStart = /usr/bin/systemd-nspawn --quiet --keep-unit --boot --link-journal=guest --directory=/var/lib/container/%i </nowiki><br />
To customize the startup of a container, add ''.conf'' files (See {{ic|systemd.unit(1)}}) under ''systemd-nspawn@MyContainer.service.d'' or by writing your own service file. <br />
<br />
See {{ic|systemd-nspawn(1)}} for all options.<br />
}}<br />
<br />
=== Building and Testing packages ===<br />
{{Expansion| Please share how systemd-nspawn fits into your build environment}}<br />
== Management ==<br />
=== machinectl ===<br />
<br />
Managing your containers is essentially done with the {{ic|machinectl}} command. See {{ic|machinectl(1)}} for more detail then listed here.<br />
<br />
Examples:<br />
<br />
* Spawn a new shell inside a running container: {{bc|machinectl login MyContainer}}<br />
* Show detailed information about a container: {{bc| machinectl status MyContainer}}<br />
* Reboot a container: {{bc| machinectl reboot MyContainer}}<br />
* Poweroff a container: {{bc| machinectrl poweroff MyContainer}}<br />
{{Note| shutdown and reboot operations can be performed from within a container session using the same commands you would use<br />
in your host system}}<br />
<br />
=== systemd toolchain ===<br />
Much of the core systemd toolchain has been updated to work with containers. Tools that do usually provide<br />
a {{ic|1= -M, --machine=}}option which will take a container name as argument.<br />
<br />
Examples:<br />
<br />
* See journal logs for a particular machine: {{bc| $ journalctl -M MyContainer}}<br />
* Show control group contents: {{bc|$ systemd-cgls -M MyContainer}}<br />
* See startup time of container: {{bc|$ systemd-analyze -M MyContainer}}<br />
<br />
== Tips ==<br />
=== X environment ===<br />
<br />
See [[Xhost]] and [[Change root#Run_graphical_applications_from_chroot]].<br />
<br />
You will need to set the {{ic|DISPLAY}} environment variable inside your container session to connect to the external X server.<br />
=== Networking ===<br />
<br />
The above described installation will give the container a right out of the box workable network, with no extra configuration needed. If you want a more complex network setup and isolate the container network from your host network, please visit the [[systemd-networkd| systemd-networkd Arch wiki]]<br />
<br />
==Troubleshooting ==<br />
<br />
=== root login fails ===<br />
If you get the following when you try to login:<br />
<br />
arch-nspawn login: root<br />
Login incorrect<br />
<br />
And ''journalctl'' shows:<br />
<br />
pam_securetty(login:auth): access denied: tty 'pts/0' is not secure !<br />
<br />
Just try to [http://unix.stackexchange.com/questions/41840/effect-of-entries-in-etc-securetty/41939#41939 remove /etc/securetty] from the container filesystem.<br />
<br />
= See also =<br />
* [http://www.freedesktop.org/software/systemd/man/machinectl.html machinectl man page]<br />
* [http://www.freedesktop.org/software/systemd/man/systemd-nspawn.html systemd-nspawn man page]<br />
* [http://lwn.net/Articles/572957/ Creating containers with systemd-nspawn]<br />
* [https://www.youtube.com/results?search_query=systemd-nspawn&aq=f Presentation by Lennart Pottering on systemd-nspawn]</div>Captaincurriehttps://wiki.archlinux.org/index.php?title=Systemd-nspawn&diff=357165Systemd-nspawn2015-01-19T19:47:10Z<p>Captaincurrie: Placed various bits of information in their proper place</p>
<hr />
<div>{{Lowercase title}}<br />
[[Category:Virtualization]]<br />
[[Category:Linux Containers]]<br />
[[ja:Systemd-nspawn]]<br />
{{Related articles start}}<br />
{{Related|systemd}}<br />
{{Related|Linux Containers}}<br />
{{Related|systemd-networkd}}<br />
{{Related|Docker}}<br />
{{Related|Lxc-systemd}}<br />
{{Related articles end}}<br />
<br />
''systemd-nspawn'' is like the [[chroot]] command, but it is a ''chroot on steroids''.<br />
<br />
''systemd-nspawn'' may be used to run a command or OS in a light-weight namespace container. It is more powerful than [[chroot]] since it fully virtualizes the file system hierarchy, as well as the process tree, the various IPC subsystems and the host and domain name.<br />
<br />
''systemd-nspawn'' limits access to various kernel interfaces in the container to read-only, such as {{ic|/sys}}, {{ic|/proc/sys}} or {{ic|/sys/fs/selinux}}. Network interfaces and the system clock may not be changed from within the container. Device nodes may not be created. The host system cannot be rebooted and kernel modules may not be loaded from within the container.<br />
<br />
This mechanism differs from [[Lxc-systemd]] or [[Libvirt]]-lxc, as it is a much simpler tool to configure.<br />
== Installation ==<br />
''systemd-nspawn'' itself is part of and packaged with {{Pkg|systemd}}. <br />
<br />
== Examples ==<br />
=== Create and boot a minimal Arch Linux distribution in a container ===<br />
<br />
First install {{Pkg|arch-install-scripts}}.<br />
<br />
Next, create a directory to hold the container. In this example we will use {{ic|~/MyContainer}}. <br />
<br />
Next, we use pacstrap to install a basic arch-system into the container.<br />
At minimum we need to install the {{Grp|base}} group. <br />
<br />
# pacstrap -i -c -d ~/MyContainer base [additional pkgs/groups]<br />
<br />
{{Tip| the '''-i''' option will '''avoid''' auto-confirmation of package selection. As you don't need to install the Linux kernel in the container, you can remove it from the package list selection to save space. See [[Pacman#Usage]].}}<br />
<br />
Once your installation is finished, boot into the container:<br />
# systemd-nspawn -bD ~/MyContainer<br />
<br />
And that's it! Log in as "root" with no password.<br />
<br />
To terminate your session hold {{ic|Ctrl}} and press {{ic|]}} three times.<br />
The container will still be running, only your session is terminated.<br />
<br />
=== Enable Container on boot ===<br />
<br />
If you want to use a container frequently, you can have systemd start it on boot.<br />
<br />
# mv ~/MyContainer /var/lib/container/MyContainer<br />
# systemctl enable systemd-nspawn@MyContainer.service<br />
# systemctl start systemd-nspawn@MyContainer.service<br />
<br />
{{Note| ''systemd-nspawn@.service'' expects nspawn containers to be under {{ic|/var/lib/container}}.}} <br />
{{Tip|<br />
* instead of moving your container, as above, you use a symlink<br />
# ln -s ~/MyContainer /var/lib/container/MyContainer<br />
* The template ''systemd-nspawn@.service'' contains<br />
<nowiki>ExecStart = /usr/bin/systemd-nspawn --quiet --keep-unit --boot --link-journal=guest --directory=/var/lib/container/%i </nowiki><br />
You can customize the startup of ''MyContainer'' by adding ''.conf'' files (See {{ic|systemd.unit(1)}}) under ''systemd-nspawn@MyContainer.service.d'' or by writing your own service file. <br />
See {{ic|systemd-nspawn(1)}} for all options.<br />
}}<br />
<br />
=== Building and Testing packages ===<br />
{{Expansion| Please share how systemd-nspawn fits into your build environment}}<br />
== Management ==<br />
=== machinectl ===<br />
<br />
Managing your containers is essentially done with the {{ic|machinectl}} command. See {{ic|machinectl(1)}} for more detail then listed here.<br />
<br />
Examples:<br />
<br />
* Spawn a new shell inside a running container: {{bc|machinectl login MyContainer}}<br />
* Show detailed information about a container: {{bc| machinectl status MyContainer}}<br />
* Reboot a container: {{bc| machinectl reboot MyContainer}}<br />
* Poweroff a container: {{bc| machinectrl poweroff MyContainer}}<br />
{{Note| shutdown and reboot operations can be performed from within a container session using the same commands you would use<br />
in your host system}}<br />
<br />
=== systemd toolchain ===<br />
Much of the core systemd toolchain has been updated to work with containers. Tools that do usually provide<br />
a {{ic|1= -M, --machine=}}option which will take a container name as argument.<br />
<br />
Examples:<br />
<br />
* See journal logs for a particular machine: {{bc| $ journalctl -M MyContainer}}<br />
* Show control group contents: {{bc|$ systemd-cgls -M MyContainer}}<br />
* See startup time of container: {{bc|$ systemd-analyze -M MyContainer}}<br />
<br />
== Tips ==<br />
=== X environment ===<br />
<br />
See [[Xhost]] and [[Change root#Run_graphical_applications_from_chroot]].<br />
<br />
You will need to set the {{ic|DISPLAY}} environment variable inside your container session to connect to the external X server.<br />
=== Networking ===<br />
<br />
The above described installation will give the container a right out of the box workable network, with no extra configuration needed. If you want a more complex network setup and isolate the container network from your host network, please visit the [[systemd-networkd| systemd-networkd Arch wiki]]<br />
<br />
==Troubleshooting ==<br />
<br />
=== root login fails ===<br />
If you get the following when you try to login:<br />
<br />
arch-nspawn login: root<br />
Login incorrect<br />
<br />
And ''journalctl'' shows:<br />
<br />
pam_securetty(login:auth): access denied: tty 'pts/0' is not secure !<br />
<br />
Just try to [http://unix.stackexchange.com/questions/41840/effect-of-entries-in-etc-securetty/41939#41939 remove /etc/securetty] from the container filesystem.<br />
<br />
= See also =<br />
* [http://www.freedesktop.org/software/systemd/man/machinectl.html machinectl man page]<br />
* [http://www.freedesktop.org/software/systemd/man/systemd-nspawn.html systemd-nspawn man page]<br />
* [http://lwn.net/Articles/572957/ Creating containers with systemd-nspawn]<br />
* [https://www.youtube.com/results?search_query=systemd-nspawn&aq=f Presentation by Lennart Pottering on systemd-nspawn]</div>Captaincurriehttps://wiki.archlinux.org/index.php?title=Systemd-nspawn&diff=357164Systemd-nspawn2015-01-19T19:40:15Z<p>Captaincurrie: /* Management */ changed name</p>
<hr />
<div>{{Lowercase title}}<br />
[[Category:Virtualization]]<br />
[[Category:Linux Containers]]<br />
[[ja:Systemd-nspawn]]<br />
{{Related articles start}}<br />
{{Related|systemd}}<br />
{{Related|Linux Containers}}<br />
{{Related|systemd-networkd}}<br />
{{Related|Docker}}<br />
{{Related|Lxc-systemd}}<br />
{{Related articles end}}<br />
<br />
''systemd-nspawn'' is like the [[chroot]] command, but it is a ''chroot on steroids''.<br />
<br />
''systemd-nspawn'' may be used to run a command or OS in a light-weight namespace container. It is more powerful than [[chroot]] since it fully virtualizes the file system hierarchy, as well as the process tree, the various IPC subsystems and the host and domain name.<br />
<br />
''systemd-nspawn'' limits access to various kernel interfaces in the container to read-only, such as {{ic|/sys}}, {{ic|/proc/sys}} or {{ic|/sys/fs/selinux}}. Network interfaces and the system clock may not be changed from within the container. Device nodes may not be created. The host system cannot be rebooted and kernel modules may not be loaded from within the container.<br />
<br />
This mechanism differs from [[Lxc-systemd]] or [[Libvirt]]-lxc, as it is a much simpler tool to configure.<br />
== Installation ==<br />
''systemd-nspawn'' itself is part of and packaged with {{Pkg|systemd}}. <br />
<br />
== Examples ==<br />
=== Create and boot a minimal Arch Linux distribution in a container ===<br />
<br />
First install {{Pkg|arch-install-scripts}}.<br />
<br />
Next, create a directory to hold the container. In this example we will use {{ic|~/MyContainer}}. <br />
<br />
Next, we use pacstrap to install a basic arch-system into the container.<br />
At minimum we need to install the {{Grp|base}} group. <br />
<br />
# pacstrap -i -c -d ~/MyContainer base [additional pkgs/groups]<br />
<br />
{{Tip| the '''-i''' option will '''avoid''' auto-confirmation of package selection. As you don't need to install the Linux kernel in the container, you can remove it from the package list selection to save space. See [[Pacman#Usage]].}}<br />
<br />
Once your installation is finished, boot into the container:<br />
# systemd-nspawn -bD ~/MyContainer<br />
<br />
And that's it! Log in as "root" with no password.<br />
<br />
=== Enable Container on boot ===<br />
<br />
If you want to use a container frequently, you can have systemd start it on boot.<br />
<br />
# mv ~/MyContainer /var/lib/container/MyContainer<br />
# systemctl enable systemd-nspawn@MyContainer.service<br />
# systemctl start systemd-nspawn@MyContainer.service<br />
<br />
{{Note| ''systemd-nspawn@.service'' expects nspawn containers to be under {{ic|/var/lib/container}}.}} <br />
{{Tip|<br />
* instead of moving your container, as above, you use a symlink<br />
# ln -s ~/MyContainer /var/lib/container/MyContainer<br />
* The template ''systemd-nspawn@.service'' contains<br />
<nowiki>ExecStart = /usr/bin/systemd-nspawn --quiet --keep-unit --boot --link-journal=guest --directory=/var/lib/container/%i </nowiki><br />
You can customize the startup of ''MyContainer'' by adding ''.conf'' files (See {{ic|systemd.unit(1)}}) under ''systemd-nspawn@MyContainer.service.d'' or by writing your own service file. <br />
See {{ic|systemd-nspawn(1)}} for all options.<br />
}}<br />
<br />
=== Building and Testing packages ===<br />
{{Expansion| Please share how systemd-nspawn fits into your build environment}}<br />
== Management ==<br />
=== machinectl ===<br />
<br />
Managing your containers is essentially done with the {{ic|machinectl}} command. See {{ic|machinectl(1)}} for more detail then listed here.<br />
<br />
Examples:<br />
<br />
* Spawn a new shell inside a running container: {{bc|machinectl login MyContainer}}<br />
* Reboot a container: {{bc| machinectl reboot MyContainer}}<br />
* Show detailed information about a container: {{bc| machinectl status MyContainer}}<br />
<br />
To terminate your session from within, hold {{ic|Ctrl}} and press {{ic|]}} three times.<br />
The container will still be running, only your session is terminated.<br />
<br />
==== Shutdown the container ====<br />
<br />
You can use many of the same options with {{ic|machinectl}} as with {{ic|systemctl}} to control the container state, such as {{ic|reboot}}, {{ic|poweroff}}... There is also the {{ic|terminate}} option which will "kill all processes of the virtual machine or container and deallocates all resources attached to that instance".<br />
<br />
See [http://www.freedesktop.org/software/systemd/man/machinectl.html man machinectl] for more options.<br />
<br />
=== systemd toolchain ===<br />
Much of the core systemd toolchain has been updated to work with containers. Tools that do usually provide<br />
a {{ic|1= -M, --machine=}}option which will take a container name as argument.<br />
<br />
Examples:<br />
<br />
* See journal logs for a particular machine: {{bc| $ journalctl -M MyContainer}}<br />
* Show control group contents: {{bc|$ systemd-cgls -M MyContainer}}<br />
* See startup time of container: {{bc|$ systemd-analyze -M MyContainer}}<br />
<br />
== Tips ==<br />
=== X environment ===<br />
<br />
See [[Xhost]] and [[Change root#Run_graphical_applications_from_chroot]].<br />
<br />
You will need to set the {{ic|DISPLAY}} environment variable inside your container session to connect to the external X server.<br />
=== Networking ===<br />
<br />
The above described installation will give the container a right out of the box workable network, with no extra configuration needed. If you want a more complex network setup and isolate the container network from your host network, please visit the [[systemd-networkd| systemd-networkd Arch wiki]]<br />
<br />
==Troubleshooting ==<br />
<br />
=== root login fails ===<br />
If you get the following when you try to login:<br />
<br />
arch-nspawn login: root<br />
Login incorrect<br />
<br />
And ''journalctl'' shows:<br />
<br />
pam_securetty(login:auth): access denied: tty 'pts/0' is not secure !<br />
<br />
Just try to [http://unix.stackexchange.com/questions/41840/effect-of-entries-in-etc-securetty/41939#41939 remove /etc/securetty] from the container filesystem.<br />
<br />
= See also =<br />
* [http://www.freedesktop.org/software/systemd/man/machinectl.html machinectl man page]<br />
* [http://www.freedesktop.org/software/systemd/man/systemd-nspawn.html systemd-nspawn man page]<br />
* [http://lwn.net/Articles/572957/ Creating containers with systemd-nspawn]<br />
* [https://www.youtube.com/results?search_query=systemd-nspawn&aq=f Presentation by Lennart Pottering on systemd-nspawn]</div>Captaincurriehttps://wiki.archlinux.org/index.php?title=Systemd-nspawn&diff=357158Systemd-nspawn2015-01-19T18:58:28Z<p>Captaincurrie: /* Management */ Not finished yet, restructuring and adding relevent information to using machinctrl as well as examples of other tools that you can help manage your containers</p>
<hr />
<div>{{Lowercase title}}<br />
[[Category:Virtualization]]<br />
[[Category:Linux Containers]]<br />
[[ja:Systemd-nspawn]]<br />
{{Related articles start}}<br />
{{Related|systemd}}<br />
{{Related|Linux Containers}}<br />
{{Related|systemd-networkd}}<br />
{{Related|Docker}}<br />
{{Related|Lxc-systemd}}<br />
{{Related articles end}}<br />
<br />
''systemd-nspawn'' is like the [[chroot]] command, but it is a ''chroot on steroids''.<br />
<br />
''systemd-nspawn'' may be used to run a command or OS in a light-weight namespace container. It is more powerful than [[chroot]] since it fully virtualizes the file system hierarchy, as well as the process tree, the various IPC subsystems and the host and domain name.<br />
<br />
''systemd-nspawn'' limits access to various kernel interfaces in the container to read-only, such as {{ic|/sys}}, {{ic|/proc/sys}} or {{ic|/sys/fs/selinux}}. Network interfaces and the system clock may not be changed from within the container. Device nodes may not be created. The host system cannot be rebooted and kernel modules may not be loaded from within the container.<br />
<br />
This mechanism differs from [[Lxc-systemd]] or [[Libvirt]]-lxc, as it is a much simpler tool to configure.<br />
== Installation ==<br />
''systemd-nspawn'' itself is part of and packaged with {{Pkg|systemd}}. <br />
<br />
== Examples ==<br />
=== Create and boot a minimal Arch Linux distribution in a container ===<br />
<br />
First install {{Pkg|arch-install-scripts}}.<br />
<br />
Next, create a directory to hold the container. In this example we will use {{ic|~/MyContainer}}. <br />
<br />
Next, we use pacstrap to install a basic arch-system into the container.<br />
At minimum we need to install the {{Grp|base}} group. <br />
<br />
# pacstrap -i -c -d ~/MyContainer base [additional pkgs/groups]<br />
<br />
{{Tip| the '''-i''' option will '''avoid''' auto-confirmation of package selection. As you don't need to install the Linux kernel in the container, you can remove it from the package list selection to save space. See [[Pacman#Usage]].}}<br />
<br />
Once your installation is finished, boot into the container:<br />
# systemd-nspawn -bD ~/MyContainer<br />
<br />
And that's it! Log in as "root" with no password.<br />
<br />
=== Enable Container on boot ===<br />
<br />
If you want to use a container frequently, you can have systemd start it on boot.<br />
<br />
# mv ~/MyContainer /var/lib/container/MyContainer<br />
# systemctl enable systemd-nspawn@MyContainer.service<br />
# systemctl start systemd-nspawn@MyContainer.service<br />
<br />
{{Note| ''systemd-nspawn@.service'' expects nspawn containers to be under {{ic|/var/lib/container}}.}} <br />
{{Tip|<br />
* instead of moving your container, as above, you use a symlink<br />
# ln -s ~/MyContainer /var/lib/container/MyContainer<br />
* The template ''systemd-nspawn@.service'' contains<br />
<nowiki>ExecStart = /usr/bin/systemd-nspawn --quiet --keep-unit --boot --link-journal=guest --directory=/var/lib/container/%i </nowiki><br />
You can customize the startup of ''MyContainer'' by adding ''.conf'' files (See {{ic|systemd.unit(1)}}) under ''systemd-nspawn@MyContainer.service.d'' or by writing your own service file. <br />
See {{ic|systemd-nspawn(1)}} for all options.<br />
}}<br />
<br />
=== Building and Testing packages ===<br />
{{Expansion| Please share how systemd-nspawn fits into your build environment}}<br />
== Management ==<br />
=== machinectl ===<br />
<br />
Managing your containers is essentially done with the {{ic|machinectl}} command. See {{ic|machinectl(1)}} for more detail then listed here.<br />
<br />
Examples:<br />
<br />
* Spawn a new shell inside a running container: {{bc|machinectl login MyContainer}}<br />
* Reboot a container: {{bc| machinectl reboot MyContainer}}<br />
* Show detailed information about a container: {{bc| machinectl status MyContainer}}<br />
<br />
To terminate your session from within, hold {{ic|Ctrl}} and press {{ic|]}} three times.<br />
The container will still be running, only your session is terminated.<br />
<br />
==== Shutdown the container ====<br />
<br />
You can use many of the same options with {{ic|machinectl}} as with {{ic|systemctl}} to control the container state, such as {{ic|reboot}}, {{ic|poweroff}}... There is also the {{ic|terminate}} option which will "kill all processes of the virtual machine or container and deallocates all resources attached to that instance".<br />
<br />
See [http://www.freedesktop.org/software/systemd/man/machinectl.html man machinectl] for more options.<br />
<br />
=== Introspection ===<br />
Much of the core systemd toolchain has been updated to work with containers. Tools that do usually provide<br />
a {{ic|1= -M, --machine=}}option which will take a container name as argument.<br />
<br />
Examples:<br />
<br />
* See journal logs for a particular machine: {{bc| $ journalctl -M MyContainer}}<br />
* Show control group contents: {{bc|$ systemd-cgls -M MyContainer}}<br />
* See startup time of container: {{bc|$ systemd-analyze -M MyContainer}}<br />
<br />
== Tips ==<br />
=== X environment ===<br />
<br />
See [[Xhost]] and [[Change root#Run_graphical_applications_from_chroot]].<br />
<br />
You will need to set the {{ic|DISPLAY}} environment variable inside your container session to connect to the external X server.<br />
=== Networking ===<br />
<br />
The above described installation will give the container a right out of the box workable network, with no extra configuration needed. If you want a more complex network setup and isolate the container network from your host network, please visit the [[systemd-networkd| systemd-networkd Arch wiki]]<br />
<br />
==Troubleshooting ==<br />
<br />
=== root login fails ===<br />
If you get the following when you try to login:<br />
<br />
arch-nspawn login: root<br />
Login incorrect<br />
<br />
And ''journalctl'' shows:<br />
<br />
pam_securetty(login:auth): access denied: tty 'pts/0' is not secure !<br />
<br />
Just try to [http://unix.stackexchange.com/questions/41840/effect-of-entries-in-etc-securetty/41939#41939 remove /etc/securetty] from the container filesystem.<br />
<br />
= See also =<br />
* [http://www.freedesktop.org/software/systemd/man/machinectl.html machinectl man page]<br />
* [http://www.freedesktop.org/software/systemd/man/systemd-nspawn.html systemd-nspawn man page]<br />
* [http://lwn.net/Articles/572957/ Creating containers with systemd-nspawn]<br />
* [https://www.youtube.com/results?search_query=systemd-nspawn&aq=f Presentation by Lennart Pottering on systemd-nspawn]</div>Captaincurriehttps://wiki.archlinux.org/index.php?title=Talk:Systemd-nspawn&diff=357155Talk:Systemd-nspawn2015-01-19T18:32:42Z<p>Captaincurrie: added a new question</p>
<hr />
<div>== Rename page? ==<br />
<br />
Wouldn't it be better to rename this page to [[systemd-nspawn]]? This page is ''mostly'' about this tool, so I think it is the better title. -- [[User:Lahwaacz|Lahwaacz]] ([[User talk:Lahwaacz|talk]]) 18:00, 18 March 2014 (UTC)<br />
<br />
:Note that the page contained an invalid DISPLAYTITLE entry: [https://wiki.archlinux.org/index.php?title=Arch_systemd_container&diff=306160&oldid=305960] -- [[User:Lahwaacz|Lahwaacz]] ([[User talk:Lahwaacz|talk]]) 19:58, 20 March 2014 (UTC)<br />
<br />
::Well, I guess it's ok, it would also give [[Linux Containers]] a clearer role as a generic intro to containers (only theoretical, just planned in its current Stub template note). -- [[User:Kynikos|Kynikos]] ([[User talk:Kynikos|talk]]) 17:14, 21 March 2014 (UTC)<br />
<br />
:::I like the suggestion. Good structure forward to group systemd-* toolset articles like that for the wiki. One question which arises with "systemd" themes though is when they are better served by a [[Systemd/User|systemd subpage]] and when titled as an [[Systemd-networkd|affiliated]] article (I'm sure you have covered that somewhere else before; I was looking at the [[systemd]] related links in consideration). The stub template note you refer to makes a good plan as well (one might group it under world domination plans at the same time:) Following that approach you could move and reverse redirect of this page to [[systemd-nspawn]] sometime and move/point to [[Linux Containers/systemd-nspawn]] once the stub and [[Linux Containers/LXC]] is in place. The latter being a grouping according to functionality rather than project/packaging. <br />
:::--[[User:Indigo|Indigo]] ([[User talk:Indigo|talk]]) 01:43, 22 March 2014 (UTC)<br />
<br />
::::The main reason why I prefer [[systemd-nspawn]] over [[systemd/systemd-nspawn]] is that it seems unnecessary to repeat "systemd" twice, separated just by "/" (there is no such problem for [[systemd/User]]). Grouping by the "Related articles" box should be enough.<br />
::::If you really want to group the articles in a subpage, I would prefer [[Linux Containers/systemd-nspawn]] anyway, because the subpages of [[systemd]] would cover half of the wiki already :)<br />
::::For completeness, there is also [[lxc-systemd]].<br />
::::-- [[User:Lahwaacz|Lahwaacz]] ([[User talk:Lahwaacz|talk]]) 07:46, 22 March 2014 (UTC)<br />
<br />
:::::Having systemd twice in the URL would indeed be tedious, I did not picture that. Makes good sense to distinguish whether subpage or page like that. <br />
:::::--[[User:Indigo|Indigo]] ([[User talk:Indigo|talk]]) 10:10, 22 March 2014 (UTC)<br />
<br />
:::Update: the Stub note in [[Linux Containers]] was changed with [https://wiki.archlinux.org/index.php?title=Linux_Containers&diff=next&oldid=313752]. -- [[User:Kynikos|Kynikos]] ([[User talk:Kynikos|talk]]) 06:34, 8 May 2014 (UTC)<br />
<br />
== user namespaces ==<br />
<br />
systemd-nspawn ''never'' uses user namespaces, as you can see [http://cgit.freedesktop.org/systemd/systemd/tree/src/nspawn/nspawn.c?id=05947befcec9afb83b9ce48d613ff372c63e2ed1#n1394 from the source]. User namespaces do not appear to work with a chroot at all right now, because you can't enter one while in a chroot and you can't use chroot while in a user namespace. - [[User:Thestinger|thestinger]] ([[User talk:Thestinger|talk]]) 19:35, 23 April 2014 (UTC)<br />
<br />
:The report is still open, I'm restoring the link here just in case: {{Bug|36969}}. The removed content is [https://wiki.archlinux.org/index.php?title=Arch_systemd_container&curid=15990&diff=311593&oldid=309230]. -- [[User:Kynikos|Kynikos]] ([[User talk:Kynikos|talk]]) 01:45, 25 April 2014 (UTC)<br />
<br />
:In conclusion from above mentioning user namespaces was not relevant on this page (pity really). So the only way to restrict the nspawn-container appears to be limiting its capabilities on start-up (as per man systemd-nspawn). Regarding {{Bug|36969}}: it was originally opened for lxc-containers anyway and those appear to support user namespaces now. Hence, the only question remaining for this article at this point would be, if there are any remaining issues arising for systemd in general when activating CONFIG_USER_NS for lxc (opinion on that?). <br />
:I have added the bug and a couple links with background info to [[Talk:Linux_Containers#Clean.2C_practical_and_detailed_howtos_.26_links|talk:linux containers]] so the reference does not get lost. <br />
:--[[User:Indigo|Indigo]] ([[User talk:Indigo|talk]]) 08:56, 3 May 2014 (UTC)<br />
<br />
== systemd-nspawn as a build environment ==<br />
I've been struggling trying to set this up and i assume others will as well. Would be nice to have an example of a build workflow using this tool on this<br />
or on a seperate page. [[User:Captaincurrie|Captaincurrie]] ([[User talk:Captaincurrie|talk]]) 18:32, 19 January 2015 (UTC)</div>Captaincurriehttps://wiki.archlinux.org/index.php?title=Systemd-nspawn&diff=357154Systemd-nspawn2015-01-19T18:29:05Z<p>Captaincurrie: /* Enable Container on boot */ edited spacing</p>
<hr />
<div>{{Lowercase title}}<br />
[[Category:Virtualization]]<br />
[[Category:Linux Containers]]<br />
[[ja:Systemd-nspawn]]<br />
{{Related articles start}}<br />
{{Related|systemd}}<br />
{{Related|Linux Containers}}<br />
{{Related|systemd-networkd}}<br />
{{Related|Docker}}<br />
{{Related|Lxc-systemd}}<br />
{{Related articles end}}<br />
<br />
''systemd-nspawn'' is like the [[chroot]] command, but it is a ''chroot on steroids''.<br />
<br />
''systemd-nspawn'' may be used to run a command or OS in a light-weight namespace container. It is more powerful than [[chroot]] since it fully virtualizes the file system hierarchy, as well as the process tree, the various IPC subsystems and the host and domain name.<br />
<br />
''systemd-nspawn'' limits access to various kernel interfaces in the container to read-only, such as {{ic|/sys}}, {{ic|/proc/sys}} or {{ic|/sys/fs/selinux}}. Network interfaces and the system clock may not be changed from within the container. Device nodes may not be created. The host system cannot be rebooted and kernel modules may not be loaded from within the container.<br />
<br />
This mechanism differs from [[Lxc-systemd]] or [[Libvirt]]-lxc, as it is a much simpler tool to configure.<br />
== Installation ==<br />
''systemd-nspawn'' itself is part of and packaged with {{Pkg|systemd}}. <br />
<br />
== Examples ==<br />
=== Create and boot a minimal Arch Linux distribution in a container ===<br />
<br />
First install {{Pkg|arch-install-scripts}}.<br />
<br />
Next, create a directory to hold the container. In this example we will use {{ic|~/MyContainer}}. <br />
<br />
Next, we use pacstrap to install a basic arch-system into the container.<br />
At minimum we need to install the {{Grp|base}} group. <br />
<br />
# pacstrap -i -c -d ~/MyContainer base [additional pkgs/groups]<br />
<br />
{{Tip| the '''-i''' option will '''avoid''' auto-confirmation of package selection. As you don't need to install the Linux kernel in the container, you can remove it from the package list selection to save space. See [[Pacman#Usage]].}}<br />
<br />
Once your installation is finished, boot into the container:<br />
# systemd-nspawn -bD ~/MyContainer<br />
<br />
And that's it! Log in as "root" with no password.<br />
<br />
=== Enable Container on boot ===<br />
<br />
If you want to use a container frequently, you can have systemd start it on boot.<br />
<br />
# mv ~/MyContainer /var/lib/container/MyContainer<br />
# systemctl enable systemd-nspawn@MyContainer.service<br />
# systemctl start systemd-nspawn@MyContainer.service<br />
<br />
{{Note| ''systemd-nspawn@.service'' expects nspawn containers to be under {{ic|/var/lib/container}}.}} <br />
{{Tip|<br />
* instead of moving your container, as above, you use a symlink<br />
# ln -s ~/MyContainer /var/lib/container/MyContainer<br />
* The template ''systemd-nspawn@.service'' contains<br />
<nowiki>ExecStart = /usr/bin/systemd-nspawn --quiet --keep-unit --boot --link-journal=guest --directory=/var/lib/container/%i </nowiki><br />
You can customize the startup of ''MyContainer'' by adding ''.conf'' files (See {{ic|systemd.unit(1)}}) under ''systemd-nspawn@MyContainer.service.d'' or by writing your own service file. <br />
See {{ic|systemd-nspawn(1)}} for all options.<br />
}}<br />
<br />
=== Building and Testing packages ===<br />
{{Expansion| Please share how systemd-nspawn fits into your build environment}}<br />
== Management ==<br />
<br />
You can use the core systemd toolchain to manage and introspect your containers.<br />
<br />
=== machinectl ===<br />
<br />
Managing your containers is essentially done with the {{ic|$ machinectl}} command. See {{ic|machinectl(1)}} for more detail then listed here.<br />
<br />
==== logging in/logging out ====<br />
machinectl login MyContainer<br />
Spawn a new shell inside a running container.<br />
You can open more than one session by loging in from another terminal.<br />
<br />
To terminate your session from within, hold {{ic|Ctrl}} and press {{ic|]}} three times.<br />
The container will still be running, only your session is terminated.<br />
<br />
==== Shutdown the container ====<br />
<br />
You can use many of the same options with {{ic|machinectl}} as with {{ic|systemctl}} to control the container state, such as {{ic|reboot}}, {{ic|poweroff}}... There is also the {{ic|terminate}} option which will "kill all processes of the virtual machine or container and deallocates all resources attached to that instance".<br />
<br />
See [http://www.freedesktop.org/software/systemd/man/machinectl.html man machinectl] for more options.<br />
<br />
=== Introspection ===<br />
<br />
If you want to see the [[control group]] contents, run {{ic|$ systemd-cgls}}<br />
<br />
== Tips ==<br />
=== X environment ===<br />
<br />
See [[Xhost]] and [[Change root#Run_graphical_applications_from_chroot]].<br />
<br />
You will need to set the {{ic|DISPLAY}} environment variable inside your container session to connect to the external X server.<br />
=== Networking ===<br />
<br />
The above described installation will give the container a right out of the box workable network, with no extra configuration needed. If you want a more complex network setup and isolate the container network from your host network, please visit the [[systemd-networkd| systemd-networkd Arch wiki]]<br />
<br />
==Troubleshooting ==<br />
<br />
=== root login fails ===<br />
If you get the following when you try to login:<br />
<br />
arch-nspawn login: root<br />
Login incorrect<br />
<br />
And ''journalctl'' shows:<br />
<br />
pam_securetty(login:auth): access denied: tty 'pts/0' is not secure !<br />
<br />
Just try to [http://unix.stackexchange.com/questions/41840/effect-of-entries-in-etc-securetty/41939#41939 remove /etc/securetty] from the container filesystem.<br />
<br />
= See also =<br />
* [http://www.freedesktop.org/software/systemd/man/machinectl.html machinectl man page]<br />
* [http://www.freedesktop.org/software/systemd/man/systemd-nspawn.html systemd-nspawn man page]<br />
* [http://lwn.net/Articles/572957/ Creating containers with systemd-nspawn]<br />
* [https://www.youtube.com/results?search_query=systemd-nspawn&aq=f Presentation by Lennart Pottering on systemd-nspawn]</div>Captaincurriehttps://wiki.archlinux.org/index.php?title=Systemd-nspawn&diff=357153Systemd-nspawn2015-01-19T18:26:42Z<p>Captaincurrie: merged workflows with examples. Cleared up language in examples. Added see also.</p>
<hr />
<div>{{Lowercase title}}<br />
[[Category:Virtualization]]<br />
[[Category:Linux Containers]]<br />
[[ja:Systemd-nspawn]]<br />
{{Related articles start}}<br />
{{Related|systemd}}<br />
{{Related|Linux Containers}}<br />
{{Related|systemd-networkd}}<br />
{{Related|Docker}}<br />
{{Related|Lxc-systemd}}<br />
{{Related articles end}}<br />
<br />
''systemd-nspawn'' is like the [[chroot]] command, but it is a ''chroot on steroids''.<br />
<br />
''systemd-nspawn'' may be used to run a command or OS in a light-weight namespace container. It is more powerful than [[chroot]] since it fully virtualizes the file system hierarchy, as well as the process tree, the various IPC subsystems and the host and domain name.<br />
<br />
''systemd-nspawn'' limits access to various kernel interfaces in the container to read-only, such as {{ic|/sys}}, {{ic|/proc/sys}} or {{ic|/sys/fs/selinux}}. Network interfaces and the system clock may not be changed from within the container. Device nodes may not be created. The host system cannot be rebooted and kernel modules may not be loaded from within the container.<br />
<br />
This mechanism differs from [[Lxc-systemd]] or [[Libvirt]]-lxc, as it is a much simpler tool to configure.<br />
== Installation ==<br />
''systemd-nspawn'' itself is part of and packaged with {{Pkg|systemd}}. <br />
<br />
== Examples ==<br />
=== Create and boot a minimal Arch Linux distribution in a container ===<br />
<br />
First install {{Pkg|arch-install-scripts}}.<br />
<br />
Next, create a directory to hold the container. In this example we will use {{ic|~/MyContainer}}. <br />
<br />
Next, we use pacstrap to install a basic arch-system into the container.<br />
At minimum we need to install the {{Grp|base}} group. <br />
<br />
# pacstrap -i -c -d ~/MyContainer base [additional pkgs/groups]<br />
<br />
{{Tip| the '''-i''' option will '''avoid''' auto-confirmation of package selection. As you don't need to install the Linux kernel in the container, you can remove it from the package list selection to save space. See [[Pacman#Usage]].}}<br />
<br />
Once your installation is finished, boot into the container:<br />
# systemd-nspawn -bD ~/MyContainer<br />
<br />
And that's it! Log in as "root" with no password.<br />
<br />
=== Enable Container on boot ===<br />
<br />
If you want to use a container frequently, you can have systemd start it on boot.<br />
<br />
# mv ~/MyContainer /var/lib/container/MyContainer<br />
# systemctl enable systemd-nspawn@MyContainer.service<br />
# systemctl start systemd-nspawn@MyContainer.service<br />
<br />
{{Note| ''systemd-nspawn@.service'' expects nspawn containers to be under {{ic|/var/lib/container}}.}} <br />
{{Tip|<br />
* instead of moving your container, as above, you use a symlink<br />
# ln -s ~/MyContainer /var/lib/container/MyContainer<br />
* The template ''systemd-nspawn@.service'' contains<br />
<nowiki>ExecStart = /usr/bin/systemd-nspawn --quiet --keep-unit --boot --link-journal=guest --directory=/var/lib/container/%i </nowiki><br />
You can customize the startup of ''MyContainer'' by adding ''.conf'' files (See {{ic|systemd.unit(1)}}) under ''systemd-nspawn@MyContainer.service.d'' or by writing your own service file. <br />
See {{ic|systemd-nspawn(1)}} for all options.<br />
}}<br />
<br />
=== Building and Testing packages ===<br />
{{Expansion| Please share how systemd-nspawn fits into your build environment}}<br />
== Management ==<br />
<br />
You can use the core systemd toolchain to manage and introspect your containers.<br />
<br />
=== machinectl ===<br />
<br />
Managing your containers is essentially done with the {{ic|$ machinectl}} command. See {{ic|machinectl(1)}} for more detail then listed here.<br />
<br />
==== logging in/logging out ====<br />
machinectl login MyContainer<br />
Spawn a new shell inside a running container.<br />
You can open more than one session by loging in from another terminal.<br />
<br />
To terminate your session from within, hold {{ic|Ctrl}} and press {{ic|]}} three times.<br />
The container will still be running, only your session is terminated.<br />
<br />
==== Shutdown the container ====<br />
<br />
You can use many of the same options with {{ic|machinectl}} as with {{ic|systemctl}} to control the container state, such as {{ic|reboot}}, {{ic|poweroff}}... There is also the {{ic|terminate}} option which will "kill all processes of the virtual machine or container and deallocates all resources attached to that instance".<br />
<br />
See [http://www.freedesktop.org/software/systemd/man/machinectl.html man machinectl] for more options.<br />
<br />
=== Introspection ===<br />
<br />
If you want to see the [[control group]] contents, run {{ic|$ systemd-cgls}}<br />
<br />
== Tips ==<br />
=== X environment ===<br />
<br />
See [[Xhost]] and [[Change root#Run_graphical_applications_from_chroot]].<br />
<br />
You will need to set the {{ic|DISPLAY}} environment variable inside your container session to connect to the external X server.<br />
=== Networking ===<br />
<br />
The above described installation will give the container a right out of the box workable network, with no extra configuration needed. If you want a more complex network setup and isolate the container network from your host network, please visit the [[systemd-networkd| systemd-networkd Arch wiki]]<br />
<br />
==Troubleshooting ==<br />
<br />
=== root login fails ===<br />
If you get the following when you try to login:<br />
<br />
arch-nspawn login: root<br />
Login incorrect<br />
<br />
And ''journalctl'' shows:<br />
<br />
pam_securetty(login:auth): access denied: tty 'pts/0' is not secure !<br />
<br />
Just try to [http://unix.stackexchange.com/questions/41840/effect-of-entries-in-etc-securetty/41939#41939 remove /etc/securetty] from the container filesystem.<br />
<br />
= See also =<br />
* [http://www.freedesktop.org/software/systemd/man/machinectl.html machinectl man page]<br />
* [http://www.freedesktop.org/software/systemd/man/systemd-nspawn.html systemd-nspawn man page]<br />
* [http://lwn.net/Articles/572957/ Creating containers with systemd-nspawn]<br />
* [https://www.youtube.com/results?search_query=systemd-nspawn&aq=f Presentation by Lennart Pottering on systemd-nspawn]</div>Captaincurriehttps://wiki.archlinux.org/index.php?title=Systemd-nspawn&diff=357152Systemd-nspawn2015-01-19T18:19:22Z<p>Captaincurrie: /* Enable Arch Linux container on boot */ Restructured and removed information that appears elsewhere in this article</p>
<hr />
<div>{{Lowercase title}}<br />
[[Category:Virtualization]]<br />
[[Category:Linux Containers]]<br />
[[ja:Systemd-nspawn]]<br />
{{Related articles start}}<br />
{{Related|systemd}}<br />
{{Related|Linux Containers}}<br />
{{Related|systemd-networkd}}<br />
{{Related|Docker}}<br />
{{Related|Lxc-systemd}}<br />
{{Related articles end}}<br />
<br />
''systemd-nspawn'' is like the [[chroot]] command, but it is a ''chroot on steroids''.<br />
<br />
''systemd-nspawn'' may be used to run a command or OS in a light-weight namespace container. It is more powerful than [[chroot]] since it fully virtualizes the file system hierarchy, as well as the process tree, the various IPC subsystems and the host and domain name.<br />
<br />
''systemd-nspawn'' limits access to various kernel interfaces in the container to read-only, such as {{ic|/sys}}, {{ic|/proc/sys}} or {{ic|/sys/fs/selinux}}. Network interfaces and the system clock may not be changed from within the container. Device nodes may not be created. The host system cannot be rebooted and kernel modules may not be loaded from within the container.<br />
<br />
This mechanism differs from [[Lxc-systemd]] or [[Libvirt]]-lxc, as it is a much simpler tool to configure.<br />
== Installation ==<br />
''systemd-nspawn'' itself is part of and packaged with {{Pkg|systemd}}. <br />
<br />
== Examples ==<br />
=== Create and boot a minimal Arch Linux distribution in a container ===<br />
<br />
First install {{Pkg|arch-install-scripts}}.<br />
<br />
Next, create a directory to hold the container. In this example we will use {{ic|~/MyContainer}}. <br />
<br />
Next, we use pacstrap to install a basic arch-system into the container.<br />
At minimum we need to install the {{Grp|base}} group. <br />
<br />
# pacstrap -i -c -d ~/MyContainer base [additional pkgs/groups]<br />
<br />
{{Tip| the '''-i''' option will '''avoid''' auto-confirmation of package selection. As you don't need to install the Linux kernel in the container, you can remove it from the package list selection to save space. See [[Pacman#Usage]].}}<br />
<br />
Once your installation is finished, boot into the container:<br />
# systemd-nspawn -bD ~/MyContainer<br />
<br />
And that's it! Log in as "root" with no password.<br />
<br />
=== Enable Container on boot ===<br />
<br />
If you want to use a container frequently, you can have systemd start it on boot.<br />
<br />
# mv ~/MyContainer /var/lib/container/MyContainer<br />
# systemctl enable systemd-nspawn@MyContainer.service<br />
# systemctl start systemd-nspawn@MyContainer.service<br />
<br />
{{Note| ''systemd-nspawn@.service'' expects nspawn containers to be under {{ic|/var/lib/container}}.}} <br />
{{Tip|<br />
* instead of moving your container, as above, you use a symlink<br />
# ln -s ~/MyContainer /var/lib/container/MyContainer<br />
* ''systemd-nspawn@.service'' contains<br />
<nowiki>ExecStart = /usr/bin/systemd-nspawn --quiet --keep-unit --boot --link-journal=guest --directory=/var/lib/container/%i </nowiki><br />
You can customize it by adding config files under ''systemd-nspawn@MyContainer.service.d'' or by writing your own service file. <br />
See {{ic|systemd-nspawn(1)}} for all options.<br />
}}<br />
<br />
== Management ==<br />
<br />
You can use the core systemd toolchain to manage and introspect your containers.<br />
<br />
=== machinectl ===<br />
<br />
Managing your containers is essentially done with the {{ic|$ machinectl}} command. See {{ic|machinectl(1)}} for more detail then listed here.<br />
<br />
==== logging in/logging out ====<br />
machinectl login MyContainer<br />
Spawn a new shell inside a running container.<br />
You can open more than one session by loging in from another terminal.<br />
<br />
To terminate your session from within, hold {{ic|Ctrl}} and press {{ic|]}} three times.<br />
The container will still be running, only your session is terminated.<br />
<br />
==== Shutdown the container ====<br />
<br />
You can use many of the same options with {{ic|machinectl}} as with {{ic|systemctl}} to control the container state, such as {{ic|reboot}}, {{ic|poweroff}}... There is also the {{ic|terminate}} option which will "kill all processes of the virtual machine or container and deallocates all resources attached to that instance".<br />
<br />
See [http://www.freedesktop.org/software/systemd/man/machinectl.html man machinectl] for more options.<br />
<br />
=== Introspection ===<br />
<br />
If you want to see the [[control group]] contents, run {{ic|$ systemd-cgls}}<br />
<br />
== Workflows ==<br />
systemd-nspawn's simplicity allows for it to be integrated into existing and new workflows.<br />
<br />
{{Expansion| Please share how systemd-nspawn fits into your environment}}<br />
=== Building and Testing packages ===<br />
<br />
== Tips ==<br />
=== X environment ===<br />
<br />
See [[Xhost]] and [[Change root#Run_graphical_applications_from_chroot]].<br />
<br />
You will need to set the {{ic|DISPLAY}} environment variable inside your container session to connect to the external X server.<br />
=== Networking ===<br />
<br />
The above described installation will give the container a right out of the box workable network, with no extra configuration needed. If you want a more complex network setup and isolate the container network from your host network, please visit the [[systemd-networkd| systemd-networkd Arch wiki]]<br />
<br />
==Troubleshooting ==<br />
<br />
=== root login fails ===<br />
If you get the following when you try to login:<br />
<br />
arch-nspawn login: root<br />
Login incorrect<br />
<br />
And ''journalctl'' shows:<br />
<br />
pam_securetty(login:auth): access denied: tty 'pts/0' is not secure !<br />
<br />
Just try to [http://unix.stackexchange.com/questions/41840/effect-of-entries-in-etc-securetty/41939#41939 remove /etc/securetty] from the container filesystem.<br />
<br />
= See also =<br />
<br />
* [http://www.freedesktop.org/software/systemd/man/systemd-nspawn.html systemd-nspawn man page]<br />
* [http://lwn.net/Articles/572957/ Creating containers with systemd-nspawn]<br />
* [http://www.freedesktop.org/software/systemd/man/machinectl.html machinectl man page]</div>Captaincurriehttps://wiki.archlinux.org/index.php?title=Systemd-nspawn&diff=357148Systemd-nspawn2015-01-19T18:02:02Z<p>Captaincurrie: Added workflows section so people can see how they might add systemd-nspawn to their...workflow</p>
<hr />
<div>{{Lowercase title}}<br />
[[Category:Virtualization]]<br />
[[Category:Linux Containers]]<br />
[[ja:Systemd-nspawn]]<br />
{{Related articles start}}<br />
{{Related|systemd}}<br />
{{Related|Linux Containers}}<br />
{{Related|systemd-networkd}}<br />
{{Related|Docker}}<br />
{{Related|Lxc-systemd}}<br />
{{Related articles end}}<br />
<br />
''systemd-nspawn'' is like the [[chroot]] command, but it is a ''chroot on steroids''.<br />
<br />
''systemd-nspawn'' may be used to run a command or OS in a light-weight namespace container. It is more powerful than [[chroot]] since it fully virtualizes the file system hierarchy, as well as the process tree, the various IPC subsystems and the host and domain name.<br />
<br />
''systemd-nspawn'' limits access to various kernel interfaces in the container to read-only, such as {{ic|/sys}}, {{ic|/proc/sys}} or {{ic|/sys/fs/selinux}}. Network interfaces and the system clock may not be changed from within the container. Device nodes may not be created. The host system cannot be rebooted and kernel modules may not be loaded from within the container.<br />
<br />
This mechanism differs from [[Lxc-systemd]] or [[Libvirt]]-lxc, as it is a much simpler tool to configure.<br />
== Installation ==<br />
''systemd-nspawn'' itself is part of and packaged with {{Pkg|systemd}}. <br />
<br />
== Examples ==<br />
=== Create and boot a minimal Arch Linux distribution in a container ===<br />
<br />
First install {{Pkg|arch-install-scripts}}.<br />
<br />
Next, create a directory to hold the container. In this example we will use {{ic|~/MyContainer}}. <br />
<br />
Next, we use pacstrap to install a basic arch-system into the container.<br />
At minimum we need to install the {{Grp|base}} group. <br />
<br />
# pacstrap -i -c -d ~/MyContainer base [additional pkgs/groups]<br />
<br />
{{Tip| the '''-i''' option will '''avoid''' auto-confirmation of package selection. As you don't need to install the Linux kernel in the container, you can remove it from the package list selection to save space. See [[Pacman#Usage]].}}<br />
<br />
Once your installation is finished, boot into the container:<br />
# systemd-nspawn -bD ~/MyContainer<br />
<br />
And that's it! Log in as "root" with no password.<br />
<br />
=== Enable Arch Linux container on boot ===<br />
<br />
If you want to use the container frequently, you can start it on system startup. an easy way is to boot it on [[Arch boot process|init]] of the machine. Then you will be able to login using the ''machinectl'' mechanism.<br />
<br />
First, you need to ''register'' your container on the host. To do this, you can either {{ic|# mv /path/to/''MyContainer'' /var/lib/container/''MyContainer''}} '''or''' just create a directory symlink:<br />
<br />
# ln -s /path/to/''MyContainer'' /var/lib/container/''MyContainer''<br />
<br />
Following that [[systemd#Basic systemctl usage|enable and start]] the {{ic|systemd-nspawn@''MyContainer''.service}}. To be sure the container is now registered, run the following command:<br />
<br />
{{hc|$ machinectl list|<br />
MACHINE CONTAINER SERVICE <br />
''MyContainer'' container nspawn <br />
<br />
1 machines listed.<br />
}}<br />
<br />
{{Tip|<br />
* the ''systemd-nspawn'' service will execute this command: {{ic|<nowiki>/usr/bin/systemd-nspawn --quiet --keep-unit --boot --link-journal=guest --directory=/var/lib/container/%i </nowiki>}}. You will need to modify this file and add some more options in case your container directory is not symlinked {{ic|/var/lib/container/MyContainer}}, you want to use an disk image file or set the [[SELinux]] security to container. To isolate network setting for your container, please refer to [[systemd-networkd]]. Further boot option information can be found in {{ic|systemd-nspawn(1)}}.<br />
* When disabling {{ic|systemd-nspawn@.service}}, you can manually boot the container by executing {{ic|# systemd-nspawn -bD /path/to/container}}. Once you are logged in the container, run {{ic|# systemctl poweroff}} to shut it down<br />
}}<br />
<br />
== Management ==<br />
<br />
You can use the core systemd toolchain to manage and introspect your containers.<br />
<br />
=== machinectl ===<br />
<br />
Managing your containers is essentially done with the {{ic|$ machinectl}} command. See {{ic|machinectl(1)}} for more detail then listed here.<br />
<br />
==== logging in/logging out ====<br />
machinectl login MyContainer<br />
Spawn a new shell inside a running container.<br />
You can open more than one session by loging in from another terminal.<br />
<br />
To terminate your session from within, hold {{ic|Ctrl}} and press {{ic|]}} three times.<br />
The container will still be running, only your session is terminated.<br />
<br />
==== Shutdown the container ====<br />
<br />
You can use many of the same options with {{ic|machinectl}} as with {{ic|systemctl}} to control the container state, such as {{ic|reboot}}, {{ic|poweroff}}... There is also the {{ic|terminate}} option which will "kill all processes of the virtual machine or container and deallocates all resources attached to that instance".<br />
<br />
See [http://www.freedesktop.org/software/systemd/man/machinectl.html man machinectl] for more options.<br />
<br />
=== Introspection ===<br />
<br />
If you want to see the [[control group]] contents, run {{ic|$ systemd-cgls}}<br />
<br />
== Workflows ==<br />
systemd-nspawn's simplicity allows for it to be integrated into existing and new workflows.<br />
<br />
{{Expansion| Please share how systemd-nspawn fits into your environment}}<br />
=== Building and Testing packages ===<br />
<br />
== Tips ==<br />
=== X environment ===<br />
<br />
See [[Xhost]] and [[Change root#Run_graphical_applications_from_chroot]].<br />
<br />
You will need to set the {{ic|DISPLAY}} environment variable inside your container session to connect to the external X server.<br />
=== Networking ===<br />
<br />
The above described installation will give the container a right out of the box workable network, with no extra configuration needed. If you want a more complex network setup and isolate the container network from your host network, please visit the [[systemd-networkd| systemd-networkd Arch wiki]]<br />
<br />
==Troubleshooting ==<br />
<br />
=== root login fails ===<br />
If you get the following when you try to login:<br />
<br />
arch-nspawn login: root<br />
Login incorrect<br />
<br />
And ''journalctl'' shows:<br />
<br />
pam_securetty(login:auth): access denied: tty 'pts/0' is not secure !<br />
<br />
Just try to [http://unix.stackexchange.com/questions/41840/effect-of-entries-in-etc-securetty/41939#41939 remove /etc/securetty] from the container filesystem.<br />
<br />
= See also =<br />
<br />
* [http://www.freedesktop.org/software/systemd/man/systemd-nspawn.html systemd-nspawn man page]<br />
* [http://lwn.net/Articles/572957/ Creating containers with systemd-nspawn]<br />
* [http://www.freedesktop.org/software/systemd/man/machinectl.html machinectl man page]</div>Captaincurriehttps://wiki.archlinux.org/index.php?title=Systemd-nspawn&diff=357146Systemd-nspawn2015-01-19T17:54:04Z<p>Captaincurrie: lowerd header level</p>
<hr />
<div>{{Lowercase title}}<br />
[[Category:Virtualization]]<br />
[[Category:Linux Containers]]<br />
[[ja:Systemd-nspawn]]<br />
{{Related articles start}}<br />
{{Related|systemd}}<br />
{{Related|Linux Containers}}<br />
{{Related|systemd-networkd}}<br />
{{Related|Docker}}<br />
{{Related|Lxc-systemd}}<br />
{{Related articles end}}<br />
<br />
''systemd-nspawn'' is like the [[chroot]] command, but it is a ''chroot on steroids''.<br />
<br />
''systemd-nspawn'' may be used to run a command or OS in a light-weight namespace container. It is more powerful than [[chroot]] since it fully virtualizes the file system hierarchy, as well as the process tree, the various IPC subsystems and the host and domain name.<br />
<br />
''systemd-nspawn'' limits access to various kernel interfaces in the container to read-only, such as {{ic|/sys}}, {{ic|/proc/sys}} or {{ic|/sys/fs/selinux}}. Network interfaces and the system clock may not be changed from within the container. Device nodes may not be created. The host system cannot be rebooted and kernel modules may not be loaded from within the container.<br />
<br />
This mechanism differs from [[Lxc-systemd]] or [[Libvirt]]-lxc, as it is a much simpler tool to configure.<br />
== Installation ==<br />
''systemd-nspawn'' itself is part of and packaged with {{Pkg|systemd}}. <br />
<br />
== Examples ==<br />
=== Create and boot a minimal Arch Linux distribution in a container ===<br />
<br />
First install {{Pkg|arch-install-scripts}}.<br />
<br />
Next, create a directory to hold the container. In this example we will use {{ic|~/MyContainer}}. <br />
<br />
Next, we use pacstrap to install a basic arch-system into the container.<br />
At minimum we need to install the {{Grp|base}} group. <br />
<br />
# pacstrap -i -c -d ~/MyContainer base [additional pkgs/groups]<br />
<br />
{{Tip| the '''-i''' option will '''avoid''' auto-confirmation of package selection. As you don't need to install the Linux kernel in the container, you can remove it from the package list selection to save space. See [[Pacman#Usage]].}}<br />
<br />
Once your installation is finished, boot into the container:<br />
# systemd-nspawn -bD ~/MyContainer<br />
<br />
And that's it! Log in as "root" with no password.<br />
<br />
=== Enable Arch Linux container on boot ===<br />
<br />
If you want to use the container frequently, you can start it on system startup. an easy way is to boot it on [[Arch boot process|init]] of the machine. Then you will be able to login using the ''machinectl'' mechanism.<br />
<br />
First, you need to ''register'' your container on the host. To do this, you can either {{ic|# mv /path/to/''MyContainer'' /var/lib/container/''MyContainer''}} '''or''' just create a directory symlink:<br />
<br />
# ln -s /path/to/''MyContainer'' /var/lib/container/''MyContainer''<br />
<br />
Following that [[systemd#Basic systemctl usage|enable and start]] the {{ic|systemd-nspawn@''MyContainer''.service}}. To be sure the container is now registered, run the following command:<br />
<br />
{{hc|$ machinectl list|<br />
MACHINE CONTAINER SERVICE <br />
''MyContainer'' container nspawn <br />
<br />
1 machines listed.<br />
}}<br />
<br />
{{Tip|<br />
* the ''systemd-nspawn'' service will execute this command: {{ic|<nowiki>/usr/bin/systemd-nspawn --quiet --keep-unit --boot --link-journal=guest --directory=/var/lib/container/%i </nowiki>}}. You will need to modify this file and add some more options in case your container directory is not symlinked {{ic|/var/lib/container/MyContainer}}, you want to use an disk image file or set the [[SELinux]] security to container. To isolate network setting for your container, please refer to [[systemd-networkd]]. Further boot option information can be found in {{ic|systemd-nspawn(1)}}.<br />
* When disabling {{ic|systemd-nspawn@.service}}, you can manually boot the container by executing {{ic|# systemd-nspawn -bD /path/to/container}}. Once you are logged in the container, run {{ic|# systemctl poweroff}} to shut it down<br />
}}<br />
<br />
== Management ==<br />
<br />
You can use the core systemd toolchain to manage and introspect your containers.<br />
<br />
=== machinectl ===<br />
<br />
Managing your containers is essentially done with the {{ic|$ machinectl}} command. See {{ic|machinectl(1)}} for more detail then listed here.<br />
<br />
==== logging in/logging out ====<br />
machinectl login MyContainer<br />
Spawn a new shell inside a running container.<br />
You can open more than one session by loging in from another terminal.<br />
<br />
To terminate your session from within, hold {{ic|Ctrl}} and press {{ic|]}} three times.<br />
The container will still be running, only your session is terminated.<br />
<br />
==== Shutdown the container ====<br />
<br />
You can use many of the same options with {{ic|machinectl}} as with {{ic|systemctl}} to control the container state, such as {{ic|reboot}}, {{ic|poweroff}}... There is also the {{ic|terminate}} option which will "kill all processes of the virtual machine or container and deallocates all resources attached to that instance".<br />
<br />
See [http://www.freedesktop.org/software/systemd/man/machinectl.html man machinectl] for more options.<br />
<br />
=== Introspection ===<br />
<br />
If you want to see the [[control group]] contents, run {{ic|$ systemd-cgls}}<br />
<br />
== Tips ==<br />
=== X environment ===<br />
<br />
See [[Xhost]] and [[Change root#Run_graphical_applications_from_chroot]].<br />
<br />
You will need to set the {{ic|DISPLAY}} environment variable inside your container session to connect to the external X server.<br />
=== Networking ===<br />
<br />
The above described installation will give the container a right out of the box workable network, with no extra configuration needed. If you want a more complex network setup and isolate the container network from your host network, please visit the [[systemd-networkd| systemd-networkd Arch wiki]]<br />
<br />
==Troubleshooting ==<br />
<br />
=== root login fails ===<br />
If you get the following when you try to login:<br />
<br />
arch-nspawn login: root<br />
Login incorrect<br />
<br />
And ''journalctl'' shows:<br />
<br />
pam_securetty(login:auth): access denied: tty 'pts/0' is not secure !<br />
<br />
Just try to [http://unix.stackexchange.com/questions/41840/effect-of-entries-in-etc-securetty/41939#41939 remove /etc/securetty] from the container filesystem.<br />
<br />
= See also =<br />
<br />
* [http://www.freedesktop.org/software/systemd/man/systemd-nspawn.html systemd-nspawn man page]<br />
* [http://lwn.net/Articles/572957/ Creating containers with systemd-nspawn]<br />
* [http://www.freedesktop.org/software/systemd/man/machinectl.html machinectl man page]</div>Captaincurriehttps://wiki.archlinux.org/index.php?title=Systemd-nspawn&diff=357145Systemd-nspawn2015-01-19T17:52:05Z<p>Captaincurrie: adjusted headers</p>
<hr />
<div>{{Lowercase title}}<br />
[[Category:Virtualization]]<br />
[[Category:Linux Containers]]<br />
[[ja:Systemd-nspawn]]<br />
{{Related articles start}}<br />
{{Related|systemd}}<br />
{{Related|Linux Containers}}<br />
{{Related|systemd-networkd}}<br />
{{Related|Docker}}<br />
{{Related|Lxc-systemd}}<br />
{{Related articles end}}<br />
<br />
''systemd-nspawn'' is like the [[chroot]] command, but it is a ''chroot on steroids''.<br />
<br />
''systemd-nspawn'' may be used to run a command or OS in a light-weight namespace container. It is more powerful than [[chroot]] since it fully virtualizes the file system hierarchy, as well as the process tree, the various IPC subsystems and the host and domain name.<br />
<br />
''systemd-nspawn'' limits access to various kernel interfaces in the container to read-only, such as {{ic|/sys}}, {{ic|/proc/sys}} or {{ic|/sys/fs/selinux}}. Network interfaces and the system clock may not be changed from within the container. Device nodes may not be created. The host system cannot be rebooted and kernel modules may not be loaded from within the container.<br />
<br />
This mechanism differs from [[Lxc-systemd]] or [[Libvirt]]-lxc, as it is a much simpler tool to configure.<br />
= Installation =<br />
''systemd-nspawn'' itself is part of and packaged with {{Pkg|systemd}}. <br />
<br />
= Examples =<br />
== Create and boot a minimal Arch Linux distribution in a container ==<br />
<br />
First install {{Pkg|arch-install-scripts}}.<br />
<br />
Next, create a directory to hold the container. In this example we will use {{ic|~/MyContainer}}. <br />
<br />
Next, we use pacstrap to install a basic arch-system into the container.<br />
At minimum we need to install the {{Grp|base}} group. <br />
<br />
# pacstrap -i -c -d ~/MyContainer base [additional pkgs/groups]<br />
<br />
{{Tip| the '''-i''' option will '''avoid''' auto-confirmation of package selection. As you don't need to install the Linux kernel in the container, you can remove it from the package list selection to save space. See [[Pacman#Usage]].}}<br />
<br />
Once your installation is finished, boot into the container:<br />
# systemd-nspawn -bD ~/MyContainer<br />
<br />
And that's it! Log in as "root" with no password.<br />
<br />
== Enable Arch Linux container on boot ==<br />
<br />
If you want to use the container frequently, you can start it on system startup. an easy way is to boot it on [[Arch boot process|init]] of the machine. Then you will be able to login using the ''machinectl'' mechanism.<br />
<br />
First, you need to ''register'' your container on the host. To do this, you can either {{ic|# mv /path/to/''MyContainer'' /var/lib/container/''MyContainer''}} '''or''' just create a directory symlink:<br />
<br />
# ln -s /path/to/''MyContainer'' /var/lib/container/''MyContainer''<br />
<br />
Following that [[systemd#Basic systemctl usage|enable and start]] the {{ic|systemd-nspawn@''MyContainer''.service}}. To be sure the container is now registered, run the following command:<br />
<br />
{{hc|$ machinectl list|<br />
MACHINE CONTAINER SERVICE <br />
''MyContainer'' container nspawn <br />
<br />
1 machines listed.<br />
}}<br />
<br />
{{Tip|<br />
* the ''systemd-nspawn'' service will execute this command: {{ic|<nowiki>/usr/bin/systemd-nspawn --quiet --keep-unit --boot --link-journal=guest --directory=/var/lib/container/%i </nowiki>}}. You will need to modify this file and add some more options in case your container directory is not symlinked {{ic|/var/lib/container/MyContainer}}, you want to use an disk image file or set the [[SELinux]] security to container. To isolate network setting for your container, please refer to [[systemd-networkd]]. Further boot option information can be found in {{ic|systemd-nspawn(1)}}.<br />
* When disabling {{ic|systemd-nspawn@.service}}, you can manually boot the container by executing {{ic|# systemd-nspawn -bD /path/to/container}}. Once you are logged in the container, run {{ic|# systemctl poweroff}} to shut it down<br />
}}<br />
<br />
= Management =<br />
<br />
You can use the core systemd toolchain to manage and introspect your containers.<br />
<br />
== machinectl ==<br />
<br />
Managing your containers is essentially done with the {{ic|$ machinectl}} command. See {{ic|machinectl(1)}} for more detail then listed here.<br />
<br />
=== logging in/logging out ===<br />
machinectl login MyContainer<br />
Spawn a new shell inside a running container.<br />
You can open more than one session by loging in from another terminal.<br />
<br />
To terminate your session from within, hold {{ic|Ctrl}} and press {{ic|]}} three times.<br />
The container will still be running, only your session is terminated.<br />
<br />
=== Shutdown the container ===<br />
<br />
You can use many of the same options with {{ic|machinectl}} as with {{ic|systemctl}} to control the container state, such as {{ic|reboot}}, {{ic|poweroff}}... There is also the {{ic|terminate}} option which will "kill all processes of the virtual machine or container and deallocates all resources attached to that instance".<br />
<br />
See [http://www.freedesktop.org/software/systemd/man/machinectl.html man machinectl] for more options.<br />
<br />
== Introspection ==<br />
<br />
If you want to see the [[control group]] contents, run {{ic|$ systemd-cgls}}<br />
<br />
= Tips =<br />
== X environment ==<br />
<br />
See [[Xhost]] and [[Change root#Run_graphical_applications_from_chroot]].<br />
<br />
You will need to set the {{ic|DISPLAY}} environment variable inside your container session to connect to the external X server.<br />
== Networking ==<br />
<br />
The above described installation will give the container a right out of the box workable network, with no extra configuration needed. If you want a more complex network setup and isolate the container network from your host network, please visit the [[systemd-networkd| systemd-networkd Arch wiki]]<br />
<br />
= Troubleshooting =<br />
<br />
== root login fails ==<br />
If you get the following when you try to login:<br />
<br />
arch-nspawn login: root<br />
Login incorrect<br />
<br />
And ''journalctl'' shows:<br />
<br />
pam_securetty(login:auth): access denied: tty 'pts/0' is not secure !<br />
<br />
Just try to [http://unix.stackexchange.com/questions/41840/effect-of-entries-in-etc-securetty/41939#41939 remove /etc/securetty] from the container filesystem.<br />
<br />
= See also =<br />
<br />
* [http://www.freedesktop.org/software/systemd/man/systemd-nspawn.html systemd-nspawn man page]<br />
* [http://lwn.net/Articles/572957/ Creating containers with systemd-nspawn]<br />
* [http://www.freedesktop.org/software/systemd/man/machinectl.html machinectl man page]</div>Captaincurriehttps://wiki.archlinux.org/index.php?title=Talk:Arch_systemd_container&diff=357144Talk:Arch systemd container2015-01-19T17:37:53Z<p>Captaincurrie: Captaincurrie moved page Talk:Arch systemd container to Talk:Systemd-nspawn: An 'Arch systemd container' is just an example of using systemd-nspawn</p>
<hr />
<div>#REDIRECT [[Talk:Systemd-nspawn]]</div>Captaincurriehttps://wiki.archlinux.org/index.php?title=Talk:Systemd-nspawn&diff=357143Talk:Systemd-nspawn2015-01-19T17:37:53Z<p>Captaincurrie: Captaincurrie moved page Talk:Arch systemd container to Talk:Systemd-nspawn: An 'Arch systemd container' is just an example of using systemd-nspawn</p>
<hr />
<div>== Rename page? ==<br />
<br />
Wouldn't it be better to rename this page to [[systemd-nspawn]]? This page is ''mostly'' about this tool, so I think it is the better title. -- [[User:Lahwaacz|Lahwaacz]] ([[User talk:Lahwaacz|talk]]) 18:00, 18 March 2014 (UTC)<br />
<br />
:Note that the page contained an invalid DISPLAYTITLE entry: [https://wiki.archlinux.org/index.php?title=Arch_systemd_container&diff=306160&oldid=305960] -- [[User:Lahwaacz|Lahwaacz]] ([[User talk:Lahwaacz|talk]]) 19:58, 20 March 2014 (UTC)<br />
<br />
::Well, I guess it's ok, it would also give [[Linux Containers]] a clearer role as a generic intro to containers (only theoretical, just planned in its current Stub template note). -- [[User:Kynikos|Kynikos]] ([[User talk:Kynikos|talk]]) 17:14, 21 March 2014 (UTC)<br />
<br />
:::I like the suggestion. Good structure forward to group systemd-* toolset articles like that for the wiki. One question which arises with "systemd" themes though is when they are better served by a [[Systemd/User|systemd subpage]] and when titled as an [[Systemd-networkd|affiliated]] article (I'm sure you have covered that somewhere else before; I was looking at the [[systemd]] related links in consideration). The stub template note you refer to makes a good plan as well (one might group it under world domination plans at the same time:) Following that approach you could move and reverse redirect of this page to [[systemd-nspawn]] sometime and move/point to [[Linux Containers/systemd-nspawn]] once the stub and [[Linux Containers/LXC]] is in place. The latter being a grouping according to functionality rather than project/packaging. <br />
:::--[[User:Indigo|Indigo]] ([[User talk:Indigo|talk]]) 01:43, 22 March 2014 (UTC)<br />
<br />
::::The main reason why I prefer [[systemd-nspawn]] over [[systemd/systemd-nspawn]] is that it seems unnecessary to repeat "systemd" twice, separated just by "/" (there is no such problem for [[systemd/User]]). Grouping by the "Related articles" box should be enough.<br />
::::If you really want to group the articles in a subpage, I would prefer [[Linux Containers/systemd-nspawn]] anyway, because the subpages of [[systemd]] would cover half of the wiki already :)<br />
::::For completeness, there is also [[lxc-systemd]].<br />
::::-- [[User:Lahwaacz|Lahwaacz]] ([[User talk:Lahwaacz|talk]]) 07:46, 22 March 2014 (UTC)<br />
<br />
:::::Having systemd twice in the URL would indeed be tedious, I did not picture that. Makes good sense to distinguish whether subpage or page like that. <br />
:::::--[[User:Indigo|Indigo]] ([[User talk:Indigo|talk]]) 10:10, 22 March 2014 (UTC)<br />
<br />
:::Update: the Stub note in [[Linux Containers]] was changed with [https://wiki.archlinux.org/index.php?title=Linux_Containers&diff=next&oldid=313752]. -- [[User:Kynikos|Kynikos]] ([[User talk:Kynikos|talk]]) 06:34, 8 May 2014 (UTC)<br />
<br />
== user namespaces ==<br />
<br />
systemd-nspawn ''never'' uses user namespaces, as you can see [http://cgit.freedesktop.org/systemd/systemd/tree/src/nspawn/nspawn.c?id=05947befcec9afb83b9ce48d613ff372c63e2ed1#n1394 from the source]. User namespaces do not appear to work with a chroot at all right now, because you can't enter one while in a chroot and you can't use chroot while in a user namespace. - [[User:Thestinger|thestinger]] ([[User talk:Thestinger|talk]]) 19:35, 23 April 2014 (UTC)<br />
<br />
:The report is still open, I'm restoring the link here just in case: {{Bug|36969}}. The removed content is [https://wiki.archlinux.org/index.php?title=Arch_systemd_container&curid=15990&diff=311593&oldid=309230]. -- [[User:Kynikos|Kynikos]] ([[User talk:Kynikos|talk]]) 01:45, 25 April 2014 (UTC)<br />
<br />
:In conclusion from above mentioning user namespaces was not relevant on this page (pity really). So the only way to restrict the nspawn-container appears to be limiting its capabilities on start-up (as per man systemd-nspawn). Regarding {{Bug|36969}}: it was originally opened for lxc-containers anyway and those appear to support user namespaces now. Hence, the only question remaining for this article at this point would be, if there are any remaining issues arising for systemd in general when activating CONFIG_USER_NS for lxc (opinion on that?). <br />
:I have added the bug and a couple links with background info to [[Talk:Linux_Containers#Clean.2C_practical_and_detailed_howtos_.26_links|talk:linux containers]] so the reference does not get lost. <br />
:--[[User:Indigo|Indigo]] ([[User talk:Indigo|talk]]) 08:56, 3 May 2014 (UTC)</div>Captaincurriehttps://wiki.archlinux.org/index.php?title=Arch_systemd_container&diff=357142Arch systemd container2015-01-19T17:37:53Z<p>Captaincurrie: Captaincurrie moved page Arch systemd container to Systemd-nspawn over redirect: An 'Arch systemd container' is just an example of using systemd-nspawn</p>
<hr />
<div>#REDIRECT [[Systemd-nspawn]]</div>Captaincurrie