Home >System Tutorial >LINUX >Informant - A Command Line Arch Linux News Reader
Informant is an Arch Linux News reader designed to also be used as a pacman hook. When installed and configured as a pacman hook, Informant automatically retrieves the latest news from the Arch Linux website and displays it during system updates or package installations. This ensures that users are informed about any critical information that may affect their system or require specific actions.
Table of Contents
The informant utility offers three subcommands: "check," "list," and "read." These subcommands serve different purposes and provide specific functionality.
The Informant utility includes a PreTransaction pacman hook that is designed to interrupt a pacman transaction if there are any unread Arch Linux News items. This hook specifically runs during upgrades and installations but not during removals.
When you install Informant, its hook is installed in the directory /usr/share/libalpm/hooks/. This means that you have the flexibility to override the default pacman hook behavior by placing a new hook in the directory /etc/pacman.d/hooks/ with the name 00-informant.hook. By doing so, you can customize or modify the hook's functionality according to your specific needs.
Informant is available in AUR, so you can install it using AUR helpers such as Paru or Yay in Arch Linux and its variants such as EndeavourOS and Manjaro Linux.
Using Paru:
$ paru -S informant
Using Yay:
$ yay -S informant
Once installed, you can configure Informant as a pacman hook by editing the /usr/share/libalpm/hooks/00-informant.hook
file. This file is automatically created by default. If it doesn't exist for any reason, you can create the file and add the following contents:
[Trigger] Operation = Install Operation = Upgrade Type = Package Target = * Target = !informant [Action] Description = Checking Arch News with Informant ... When = PreTransaction Exec = /usr/bin/informant check AbortOnFail
Code Explanation:
Let us break down the above code and see what each option does.
In the [Trigger] section, the code defines the conditions under which the hook should be triggered. In this case, the hook will be triggered for two operations: "Install" and "Upgrade".
The Type = Package indicates that the hook applies to package-related operations. The Target = * specifies that the hook applies to any package. However, Target = !informant excludes the package named "informant" from triggering the hook. This means the hook won't be executed when installing or upgrading the "informant" package itself.
In the [Action] section, the code specifies the action to be performed when the hook is triggered. The Description field provides a brief description of the action, which in this case is "Checking Arch News with Informant …".
The When = PreTransaction indicates that the action should take place before the transaction is executed. In other words, it runs as a pre-action before the package installation or upgrade occurs.
The Exec = /usr/bin/informant check line specifies the command to be executed. It runs the command /usr/bin/informant check, which checks for Arch News using the "informant" utility.
Lastly, AbortOnFail is a directive that ensures that if the "informant check" command fails, it will abort the transaction. This helps ensure that any important news or updates are addressed before proceeding with the package installation or upgrade.
In summary, with this configuration, the pacman hook will be triggered during package installation or upgrade operations. It specifies that the hook should not be executed when the target package is "informant" itself. The hook action involves running the command /usr/bin/informant check to check for Arch News using the "informant" utility. The AbortOnFail directive ensures that if the check fails, it will interrupt the transaction.
As stated already, when you try to update or install any package, the informant will interrupt the pacman transaction if there are any unread news. Have a look at the following output. I tried to update my Arch Linux using 'pacman -Syyu' command. The informant tool interrupted the transaction and displayed there are 10 unread messages left and suggested me to read them before running any further pacman transactions.
[..] :: Running pre-transaction hooks... (1/1) Checking Arch News with Informant ... <strong><mark>There are 10 unread news items! Use informant to read them. :: informant: Run `informant read` before re-running your pacman command</mark></strong> error: command failed to execute correctly error: failed to commit transaction (failed to run transaction hooks) Errors occurred, no packages were upgraded.
To read the Arch Linux news using Informant, simply run:
$ informant read
This will list all unread commands. You will be prompted to go the next message after reading each one. Simply press 'y' to read next item.
After reading all items, simply re-run the pacman command. This time it will run without any interruption.
As you see in the above output, there is a permission denied error message:
ERROR: Unable to read cache information: [Errno 13] Permission denied: '/var/cache/informant/6/c/0/1/e/6c01e271562517b0f36f92a0135827dfdab1ed9faf33b98f5b8338e2'
To get rid of this error, either run all commands prefixed with sudo or add your current user to group "informant" to avoid the need for sudo.
$ sudo usermod -aG informant ostechnix
Replace ostechnix with your actual username.
Here are a few examples of how you can use the "informant" command:
1. Checking for Unread News:
$ informant check
This command checks for any unread news items. If there are unread items, it displays them in the terminal.
2. Listing News Titles:
$ informant list
This command lists the titles of the most recent news items, regardless of whether they have been read or not.
3. Reading a Specific News Item:
$ informant read 3
This command reads the news item with index 3. You can replace 3 with the specific index or title of the news item you want to read.
4. Looping through Unread News Items:
$ informant read
Running this command without specifying a news item will begin a loop, where each unread news item is displayed one by one. You will be prompted to continue to the next item after reading each one.
5. Marking All Items as Read:
$ informant read --all
This command marks all unread news items as read without printing their content.
These examples demonstrate how you can utilize different subcommands and options provided by the "informant" command to check, list, read, and manage Arch Linux News items according to your needs.
If you wish to disable the "informant" hook entirely, you can create a symlink to /dev/null in the /etc/pacman.d/hooks/ directory. For example, you can use the following command to create the symlink:
$ ln -s /dev/null /etc/pacman.d/hooks/00-informant.hook
Replace the path of the hook file with your own. This effectively redirects the hook to /dev/null, which essentially discards its output and disables its functionality.
For more detailed information and guidance on pacman hooks, including their usage and configuration, you can refer to the manual page by running the following command:
$ man alpm-hooks
If the hook or the "informant" utility breaks and prevents you from completing a successful pacman transaction, even after attempting to read the news, you can resolve the issue by removing the "informant" package from your system.
To remove informant, just run:
$ sudo pacman -Rsn informant
Here's a FAQ (Frequently Asked Questions) for the Informant utility:
1. What is Informant?Informant is a command-line utility designed for Arch Linux users to conveniently read and manage Arch Linux News.
2. How does Informant work?Informant utilizes the Arch Linux News RSS feed to retrieve and present news items in a readable format within the terminal.
3. How do I install Informant?Informant can be installed from the Arch User Repository (AUR) using AUR helpers like Paru or Yay. For example, you can run paru -S informant or yay -S informant to install it.
4. What are the sub-commands of Informant?Informant provides subcommands such as 'check' to check for unread news items, 'list' to list the titles of recent news items, and 'read' to read specific news items or loop through unread items.
5. How can I check for unread news items using Informant?You can run informant check to check for any unread news items. It will display the content of the item if there is only one unread item, marking it as read.
6. Can I list the titles of recent news items without marking them as read?Yes, you can use informant list to list the titles of the most recent news items, regardless of their read status. Add the --unread option to restrict the list to unread items only.
7. How can I read a specific news item using Informant?You can run informant read
Yes, you can use informant read --all to mark all unread news items as read without printing their content.
9. Can I customize Informant's behavior?Informant provides options such as --reverse to list news items in reverse order and --unread to focus on unread items. Use informant --help to explore additional options.
10. How can I uninstall Informant?You can uninstall Informant using your package manager. For example, run pacman -Rsn informant to remove the Informant package from your system.
If you have any additional questions or need further assistance with Informant, feel free to consult the documentation or post your questions via the comment section below.
Informant is a utility that provides notifications and displays news from the Arch Linux website whenever there are important announcements, updates, or issues related to the Arch Linux distribution. With the help of Informant, the Arch users can stay up to date with the latest news, announcements, and important information related to the Arch Linux distribution.
Resource:
The above is the detailed content of Informant - A Command Line Arch Linux News Reader. For more information, please follow other related articles on the PHP Chinese website!