Tutorial – Desktop News Feeds
Pipe Menus
The menugenerator
script should work with any window manager that follows freedesktop.org standards. Before showing a fallback solution for cases when those standards are not applicable, I want to show you a cool alternative solution that is only valid for the Blackbox family of window managers (e.g., Openbox and Fluxbox): pipe menus.
Pipe menus are window manager applications that apply the old Unix practice of doing complex stuff by connecting (piping) small tools together, each of which does one thing well. A pipe menu is created on the fly not by reading .desktop
files but from plain text output of any program you desire. Pipe menus can display and do practically anything, from checking email to reading your horoscope.
My very simple RSS menu generator for Openbox is called rssmenu
(Listing 8). This code reads the same file as the previous script and parses it in the same way. The only difference is that it formats the output not as a .desktop
file, but with the markup required by Openbox [9].
Listing 8
rssmenu
Figure 5 shows how to bind the rssmenu
script to an Openbox submenu entry with the Obmenu tool. Figure 6 displays what happens, in practice, when you select the corresponding mynews submenu inside Openbox: again, clickable news headlines in a very quick and discrete interface.
Zenity
As cool as they are, the ways to embed headlines dynamically in Linux system menus shown so far are not applicable to window managers that, for whatever reason, do not offer such menus. These days, this is mostly the case of tiling window managers like i3, which are deliberately designed to never show root windows.
In all these cases, you can still achieve an equivalent functionality with the Zenity utility [10]. Figure 7 shows the Zenity dialog you get when you launch the script in Listing 9 from a prompt or a hotkey of your choice.
Listing 9
zenitymenu
The general scheme is always the same: read headline titles and URLs from the rssmix
file and open in Firefox tabs (lines 18-22) all those selected by the user in the Zenity dialog. The Zenity options in line 16 are self-explanatory; what matters is how it exchanges data with the rest of the script:
- The
cut
command extracts headline titles fromrssmix
and passes them to thezenity
standard input. - The
zenity
output is saved in the$HEADLINES
variable, which has the format:
Red Hat Reports $823 Revenue|Navarro: Kavanaugh should step aside|Debian, Ubuntu... Leaving Users Vulnerable
The loop starting in line 22 reads those titles from $HEADLINES
using the pipe ('|'
) character as the field separator to open the corresponding URL in Firefox (line 21). The script knows which URLs correspond to each title because they constitute key-value pairs in the NEWSURLS
associative array defined in line 4, filled in line 13, and looked up in line 21. Yes, it would have been possible to use Zenity in a way that would not need an associative array. Fact is, I really wanted to show you how to use those powerful data structures in a shell script.
Conclusions
You can use the menu generation methods for much more than creating headlines as clickable menu entries: Please let me know what you make of them.
As far as RSS goes, it is wonderful, but the best way to use it productively remains careful planning and self-discipline. Here, I show you a starting point, but we each have different needs. The following are just a few examples of the many ways you can play with the scripts you saw here:
- Create many separate menus, each with its own topic (e.g., work, hobbies, general news), number of headlines, and refresh frequencies to minimize distractions. For example, you could load work feeds daily and entertainment feeds only on weekends or in the evenings).
- Pass headlines to speech synthesizers that read them to you.
- Save headlines automatically as bookmarks.
- Use the scripts to build a self-refreshing web page in HTML, and make that the home page of all your browsers.
- Mix and display headlines from different sources in dedicated website sidebars, as I do on my main blog [11].
Infos
- What is RSS?: http://www.whatisrss.com
- Desktop entry specification: https://specifications.freedesktop.org/desktop-entry-spec/desktop-entry-spec-latest.html
- Desktop menu specification: https://specifications.freedesktop.org/menu-spec/menu-spec-1.0.html
- Desktop registered categories: https://standards.freedesktop.org/menu-spec/latest/apa.html
- Desktop files: putting your application in (Gnome) desktop menus: https://developer.gnome.org/integration-guide/stable/desktop-files.html.en
- Creating a .desktop file for a new (Ubuntu) application: https://askubuntu.com/questions/281293/creating-a-desktop-file-for-a-new-application
- MenuLibre: https://bluesabre.org/projects/menulibre/
- Here documents: https://www.tldp.org/LDP/abs/html/here-docs.html
- Openbox: http://openbox.org/wiki/Main_Page
- Zenity: https://help.gnome.org/users/zenity/3.24/
- Headlines in a sidebar on my website: http://stop.zona-m.net
« Previous 1 2 3
Buy this article as PDF
(incl. VAT)
Buy Linux Magazine
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters
Support Our Work
Linux Magazine content is made possible with support from readers like you. Please consider contributing when you’ve found an article to be beneficial.
News
-
Linux Servers Targeted by Akira Ransomware
A group of bad actors who have already extorted $42 million have their sights set on the Linux platform.
-
TUXEDO Computers Unveils Linux Laptop Featuring AMD Ryzen CPU
This latest release is the first laptop to include the new CPU from Ryzen and Linux preinstalled.
-
XZ Gets the All-Clear
The back door xz vulnerability has been officially reverted for Fedora 40 and versions 38 and 39 were never affected.
-
Canonical Collaborates with Qualcomm on New Venture
This new joint effort is geared toward bringing Ubuntu and Ubuntu Core to Qualcomm-powered devices.
-
Kodi 21.0 Open-Source Entertainment Hub Released
After a year of development, the award-winning Kodi cross-platform, media center software is now available with many new additions and improvements.
-
Linux Usage Increases in Two Key Areas
If market share is your thing, you'll be happy to know that Linux is on the rise in two areas that, if they keep climbing, could have serious meaning for Linux's future.
-
Vulnerability Discovered in xz Libraries
An urgent alert for Fedora 40 has been posted and users should pay attention.
-
Canonical Bumps LTS Support to 12 years
If you're worried that your Ubuntu LTS release won't be supported long enough to last, Canonical has a surprise for you in the form of 12 years of security coverage.
-
Fedora 40 Beta Released Soon
With the official release of Fedora 40 coming in April, it's almost time to download the beta and see what's new.
-
New Pentesting Distribution to Compete with Kali Linux
SnoopGod is now available for your testing needs