Ma_Sys.ma i3bar Scripts

Summary

This repository contains a collection of different scripts for configuring a status bar. The most recent script version works in combination with i3bar(1), older versions work with conky(1).

The installable Debian package can be created by running ant package.

Introduction

A status bar can be used to display system information. Usually, date and time information is provided along with other information the user may consider useful.

For example, some people display the state of multimedia applications, others display network information like IP addresses and hostnames and some like to have a permanent glance at the system’s load in terms of disk usage, processor load, memory etc.

Background

Programs like conky(1) and i3status(1) exist to aid in solving this task, but require extensive and often machine-dependent configuration. The necessity for configuration is natural, as the design and rationale behind a good status bar seems to be a very personal thing.

However, being machine-dependent is not really a “nice” property for people who know their personal status bar style but want to use their configuration across many systems. In these cases one either has to edit the configuration for every system or come up with some kind of automation.

This repository provides exactly that: Some examples of more or less advanced automated status bar “creation“ for a single user’s personal configuration style. As a result, it is most unlikely that anybody will use the provided scripts or status bar directly, but it may serve as an inspiration of how to go about it. Additionally, for the most recent version, the reasons for including specific figures in the status bar output are explained with the expectation that this may serve a user who wants to thoughtfully craft their own status bar.

Auxiliary Scripts

On the way towards creating a status bar, one may be tempted to create scripts to simplify processing some status information. Beware that calling external processes from status bars can be resource-intensive.

That warning given, here are two scripts which may be useful in other contexts than status bars, too:

ma_perc_bar – progress bar

Script ma_perc_bar is the absolute minimum of a status-bar script. It takes as input a number from 0 to 100 (both inclusive) and outputs a progress bar made of block characters.

Example:

$ ./ma_perc_bar 30
███░░░░░░░

The idea here is that the script may be used in rarely-called status scripts or may serve as a building block for conky configuration generation scripts (see section ma_genconkyconf_new)

ma_acpi_status – formatted ACPI output

Uses ma_perc_bar to format the output of the acpi command. This is intended to be called rarely (e. g. once per minute) to output Laptop battery status information as part of a possibly larger status bar.

Example:

$ ./ma_acpi_status
D █████████░ 96% 10:17:57

The Legacy

Old status bar for XFCE

The Ma_Sys.ma journey through status bars was roughly like this:

xond/ma_genconkyconf

The script in xond/ma_genconkyconf contains instructions to generate a status bar for standalone Conky usage which used to look like this:

Standalone conky with old configuration as generated by xond/ma_genconkyconf

Back then, conky had a different configuration file format which means that by now, the script is no longer compatible with new Conky versions and hence only of historic interest.

The following items were in the status bar.

First row

Second row

Evaluation

Most of the information selected for being displayed back then, is still considered interesting in the most recent Ma_Sys.ma status bar versions. However, some measures have been taken to reduce the space occupied for things which may not require large gauges. Today, you can really see that the design from xond/ma_genconkyconf was not intended to display more than four or eight processor cores.

Standalone conky works well for stacking window managers. Back then, Fluxbox was being used, but others are expected to work, too. For tiling window managers, there was often need for additional configuration, but at least i3 and spectrwm allow for conky to be used as a “standalone” status bar.

ma_genconkyconf_new

For about five years, this was the prevalent status bar used at the Ma_Sys.ma. It ran on a few physical as well as virtual machines and supported energy-efficient laptop as well as desktop usage.

Conky running as a child process of i3bar to render the status bar, configuration generated by ma_genconkyconf_new -j

To use screen space efficiently, this status bar uses only a single line. In terms of colors, it closely resembles its predecessor. The following information is displayed:

Some system-specific code allows special file systems to appear as additional gauges. Automatic detection of the apcupsd daemon or the use on a Laptop allow for battery monitoring gauges to appear on those systems, where they make sense.

The configuration format is already conky’s new format such that script ma_genconkyconf_new may still be used if one wants to create a similar status bar.

The disadvantage of the integration with i3bar is complexity: To generate the JSON output needed by i3bar, a very convoluted Conky configuration file is generated and one cannot run conky directly from i3bar – a wrapper script for displaying a leading {"version:1"}[ string is needed. Additionally, conky occasionally crashed when network interfaces were changing or ACPI information was garbled.

Other noteworthy features

ma_i3conkystatus

In case you are interested in running ma_genconkyconf_new in conjunction with i3bar, the steps are as follows:

  1. Generate a Conky configuration file: ma_genconkyconf_new -j > ~/.mdvl/conkyrc_i3
  2. Configure to use ma_i3conkystatus in i3. This script in turn invokes conky with the configuration file generated in the previous step and produces the static part of the necessary output for i3bar integration. Additionally, in case of conky crashes, it attempts to re-start conky without leaving i3bar in an error state.
  3. Restart/Reload i3 for the changes to take effect.

Here is an example of an i3 configuration file snippet to invoke ma_i3conkystatus.

bar {
    status_command /usr/bin/ma_i3conkystatus
    position top
    tray_output primary
    colors {
        #                   border  bg      fg
        focused_workspace   #cc4040 #cc4040 #ffffff
        active_workspace    #806060 #806060 #aaaaaa
        inactive_workspace  #201818 #201818 #505050
        urgent_workspace    #ffaa00 #ffaa00 #ffffff
        background                  #000000
        statusline                          #ffffff
        separator                           #333333
    }
}

Current Ma_Sys.ma i3bar

The current Ma_Sys.ma status bar is no longer dependent on conky. Instead, it is a Perl script which directly outputs JSON that can be processed by i3bar. Most notable change compared to the previous variants is the use of less colors: Instead of coloring different ressource types differntly, mai3bar colors resources depending on whether they can be considered to be in a critical, warning or normal state. This is intended to have the following advantages:

Additionally, no longer using conky, it becomes feasible to implement gauges which have text written on them. This allows for higher density in information. Additionally, actual figures can be presented for resources like disk space and RAM. While it might seem a minor detail, having these values as numbers is useful in the context of virtual and old machines where limits might be very low e.,g. for RAM or disk space compared to what one expects from modern physical systems.

Here are a few other newly added features compared to the previous status bars used at the Ma_Sys.ma. A few of them are somewhat experimental because they may not fit the common expectations of how values would appear in a status bar:

Screenshot of the Ma_Sys.ma i3bar on a typical VM, observe the RAM being in MiB

Screenshot of the Ma_Sys.ma i3bar on the Ma_Sys.ma main system pte5

Summary of items displayed:

Name Shortening Algorithm

In order to display the names of file systems and network interfaces in a recognizable and compact fashion, a special algorithm for shortening the names of file system mountpoints and network interfaces has been devised. It should still be considered experimental, but seems to work in many “common” cases so far.

The algorithm does the following steps:

  1. Given a list of names to process.
  2. Sort the list of names (lexicographically) to obtain a sorted list
  3. Process names starting from the first item in the sorted list. For the current and all subsequent names in the sorted list. Remove their longest common prefix.
  4. Continue with the prefix reduced list.
  5. Process each item in the prefix reduced list:
  6. Take the shortest prefix of the item such that it is not a prefix of any other item in the list.
  7. Output the resulting names.

Example shortenings:

Input Prefix Reduced List Output
eno1, ens1 o1, s1 o, s
eno1, eno2, ens1 o1, o2, s1 o1, o2, s
/*, /data, /, data, e01, ll /, d, e, l
/fs/e01, /fs/ll

*) As a special execption, an empty string is kept to be / instead of being reduced to the empty string for being a prefix of each other entry.


Ma_Sys.ma Website 5 (1.0.2) – no Flash, no JavaScript, no Webfont, no Copy Protection, no Mobile First. No bullshit. No GUI needed. Works with any browser.

Created: 2020/05/18 23:44:10 | Revised: 2022/09/18 21:18:03 | Tags: i3, i3bar, mdvl, package, perl, monitoring, statusbar | Version: 1.0.0 | SRC (Pandoc MD) | GPL

Copyright (c) 2020 Ma_Sys.ma. For further info send an e-mail to Ma_Sys.ma@web.de.

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.