Here is a scenario. You have a microcontroller that reads a number of things – temperatures, pressures, whatever – and you want to have a screen for your Linux desktop that sits on the panel and shows you the status. If you click on it, you get extended status and can even issue some commands. Most desktop computers support the notion of widgets, but developing them is a pain, isn’t it? And even if you’re developing one for KDE, what about people who use Gnome?
Turns out there’s an easy answer, and it was apparently inspired by a tool from the Mac world. This tool was called BitBar (now XBar). This program places a widget on your menu bar that can display anything you want. You can write any kind of program you like – shell script, C, whatever. The output printed from the program controls what appears on the widget using simple markup-like language.
That’s fine for the Mac, but what about Linux? If you use Gnome, there is a very similar project called Argos. It is largely compatible with XBar, although there are a few things specific to it. If you’re using KDE (like me), you’ll need Kargos, which is more or less a port of Argos and adds a few things of its own.
Good news, bad news
The good news is that in theory you could write a script that would work under all three systems. The bad news is that everyone has their own differences and quirks. Of course, too, if you’re using a compliant program it could cause a problem on the Mac unless you recompile it.
To compound this problem, the Kargos documentation appears to be flawed. This is partly because the version in the KDE repositories is outdated and even if you get the latest version from GitHub it is still out of date with the documentation. You really want to install from a clone from the GitHub, not from the release package or from the KDE repository for plasmoid. Part of the problem is also that the documentation is terse and you sometimes get things working, but not always. It is not clear if this is a design or an interaction with the KDE desktop which is constantly changing.
Since I’m using KDE, I’ll focus on Kargos, and I’ll highlight a few points about Argos as I go along. But you can expect to experiment anyway.
Basics
When you install the widget, you need to point it to a script. Typically, the script will run periodically. For Kargos, you can set this interval in two different ways which we will discuss later.
In the simplest case, the script would produce a line of text that will appear on the panel, a separator, and then one or more lines of text that will appear when you click on the widget. Consider this:
#!/bin/bash echo Hello Hackaday echo --- echo Test echo 1 echo 2 echo 3 echo 4
If you place the Kargos widget on a panel and configure it to read your script, you will end up with only the text Hello Hackaday on your panel. When you click, you see something like this:
Excitement

As it is, it’s not very exciting. However, each line of text can have a pipe character and some attributes to spruce things up and add function. Replace the line that says Hello Hackaday with this:
ICON=$( curl -s "https://hackaday.com/favicon.ico | base64 -w 0 ) echo "Hello Hackaday | image="$ICON" href=http://www.hackaday.com"
Now the panel will look a little more elegant and if you click on the little chain link icon you will visit your favorite website. Of course, the real interesting thing is when you can make objects change. If you set a refresh interval on the configuration screen, the script will run often. You can also name the script with a repeat interval. For example, a script of haddemo.10s.sh
will run every 10 seconds but haddemo.2m.sh
will run every two minutes.
You can also add arefresh=true
attribute to a line of text so that clicking it runs the script again. Suppose you want to ping Google on demand. You can set the timer to 0 and do this:
#!/bin/bash OUTPUT=$( ping -c 1 -q google.com | grep ^rtt | cut -d ' ' -f 4 | cut -d '/' -f 1 ) if [ -z "$OUTPUT" ] then echo "Error click to refresh | refresh=true color=orange" bash="'/usr/bin/systemsettings kcm_networkmanagement'" terminal=false fi # get an integer to compare (bash doesn't like floats) IOUT=$( echo $OUTPUT | sed s/.// ) COLOR=green if [ $IOUT -gt 90000 ] # 900000 is 90 ms then COLOR=red fi echo "Google.com: $OUTPUT ms | refresh=true color=$COLOR" bash="'/usr/bin/systemsettings kcm_networkmanagement'" terminal=false echo ---
Now you will get a ping time from Google on your bar. It will change color if it is slow or unable to ping. A small button will allow you to open the network management.
However…
Colors don’t seem to work in drop down menus, which may be the desktop manager forcing theme colors, so your mileage may vary. There are also some differences from Argos. For example, Argos has an environment variable that tells you if the widget is open or not. This allows you to avoid running unnecessary parts of your script for better performance.
There are other differences as well, but if you stick to the basics, you should be fine. Even where things are different, it’s still easier than writing two completely different widgets for the different systems.
There also seems to be some strange behavior. For example, the onclick attribute also doesn’t work in dropdowns. Of course, it’s open source, so if you hate it that much, feel free to go fix it!
great example
Since I like to follow the headlines on Hackday, I decided to take advantage of a feature of Kargos. In the previous examples, I only had one line before the drop-down separator (“—”). But if you have more than one line, the widget will cycle through them with a delay that you can set in the widget settings.
Using awk
it is easy to read the Hackaday RSS feed and extract titles and links. A few images and you end up with a nice RSS display. The parsing might not work for an arbitrary RSS feed because it’s fairly simple-minded, but – in theory – you should be able to adapt it to other feeds.
Here is the code:
#!/bin/bash curl "https://hackaday.com/feed/" 2>/dev/null | awk ' BEGIN { n=-1; } # skip first item /That’s not a lot of code for a full RSS reader. You can see the stories in the panel and click on them or open the widget to see a list at the same time.
Next steps
Since the data is just text, it’s simple to create small widgets using this system. For example, here’s a handy memory status widget:
#!/bin/bash cat /proc/meminfo echo --- echo "Tools" echo "--System status | bash=/usr/bin/ksysguard onclick=bash" echo "--Htop | bash=/usr/bin/htop" terminal=true cat /proc/meminfo
Obviously, having a script that reads data from an ESP32 or an Arduino would be trivial. Since a lot of what you want to do with something like this is OS independent, browsing through some of the plugins for xbar might give you an idea.
If you want something fancier for KDE, check out Scriptinator. You can customize it more, but it’s a bit more complex to manage.
For some reason, I’m obsessed with the Hackaday feed. I turned it into a filesystem. It also greets me when I log in. Some of the plugins you will find are in bash and some are in Python. Don’t forget that you can also mix them.