Statusbar configuration of wmfs windows manager

After the installation of Arch Linux I decided to use WMFS Windows Manager as windows manager. In the wiki you can find a statusbar configuration section but for me it doesn’t work.

So I tried to write a configuration status.sh file, you can find it in /home/user/.config/wmfs/ directory otherwise you can create it.

  • To setup time and date:The date and time is simply determinated with the command date that you can set using the follow syntax ( for a more complete command syntax see this post or type man date on the terminal ):

    > %y – to print the abbreviated year (%Y for full year);

    > %b – to print the abbreviated month name (%B for full month name);

    > %m – to print the current month number;

    > %d – to print the current day number;

    > %a – to print the current day of the week;

    > %H – to print the hour in 24h format;

    > %I – to print the hour in 12h format (use %p to print AM or PM);

    > %M – to print the minutes;

    > %S – to print the seconds;

    To use it in the configuration script is necessary to create a function to print, an example is mine here:

    #date/time
    dte(){
        dte="$(date +"%a %d/%m")"
        echo "$dte"
    }
    tme(){
        tme="$(date +"%H:%M")"
        echo "$tme"
    }

 

  • To setup power status:
    The power status is determinable by two different ways: the first is using acpi command and the second is through the informations on power and energy located in /sys/class/power_supply/BAT0/.

    1. USING ACPI
      Installing the package acpi and using the namesake command. It will give to you all the information as in the example here:

      [[email protected]] ~ $ acpi
      Battery 0: Charging, 63%, 00:16:41 until charged
      Battery 1: Unknown, 79%

      I have two batteries but for only one is the same. So if you want, for example, to select only the percentage or the time remaining to complete charge (or complete discharge) you need just to use grep and awk commands as follow:

      [[email protected]] ~ $ acpi | grep "Battery 0" | awk {'print $5'}
      00:16:41

      So to use in the script I wrote a function for each battery that look like follow:

    2. ALTERNATIVE METHOD If you don't want to use acpi for some reasons I wrote a script that do the same thing but it can be simply setting by the user. It take power data from the directory /sys/class/power_supply/BAT0/ and through simple physics consideration it will print current capacity, time to full charge/discharge. The script for the "Battery 0" is the follow:

 

  • To setup capslock flag:
    The caps lock in the windows manager bar is very useful if you don't have a led on keyboard that indicates the status of it (like Lenovo T440s as mine). To do that we will use the command xset with the option 'q' that print out status information about all I/O hardwares. So if you type xset -q the result will be almost the follow:

    [[email protected]] ~ $ xset q
    Keyboard Control:
      auto repeat:  on    key click percent:  0    LED mask:  00000000
      XKB indicators:
        00: Caps Lock:   off    01: Num Lock:    off    02: Scroll Lock: off
        03: Compose:     off    04: Kana:        off    05: Sleep:       off
        06: Suspend:     off    07: Mute:        off    08: Misc:        off
        09: Mail:        off    10: Charging:    off    11: Shift Lock:  off
        12: Group 2:     off    13: Mouse Keys:  off
      auto repeat delay:  660    repeat rate:  25
      auto repeating keys:  00ffffffdffffbbf
                            fadfffefffedffff
                            9fffffffffffffff
                            fff7ffffffffffff
      bell percent:  50    bell pitch:  400    bell duration:  100
    Pointer Control:
      acceleration:  2/1    threshold:  4
    Screen Saver:
      prefer blanking:  yes    allow exposures:  yes
      timeout:  600    cycle:  600
    Colors:
      default colormap:  0x22    BlackPixel:  0x0    WhitePixel:  0xffffff
    Font Path:
      /usr/share/fonts/misc/,/usr/share/fonts/TTF/,/usr/share/fonts/Type1/,built-ins
    DPMS (Energy Star):
      Standby: 600    Suspend: 600    Off: 600
      DPMS is Enabled
      Monitor is On

    where in the 3rd line there is a flag with value "00000000", when the capslock is disable and equal to "00000001" when it is enable. So using this command and with grep and awk is possible to select the flag and easy to print a string ('ON' or 'OFF') in the statusbar. My script to do that is:

Now you need to edit the file ~/.config/wmfs/status.sh (or create it if do not exist) and use all the below stuff. To print out in the WMFS (as indicates the wiki) the command is:

wmfs -s "What ever you want to be displayed"

So to use the functions below:

TIMING=2

statustext()
{
    wmfs -s status "Nibble | $(caps) | $(pow1) | $(pow2) | $(dte)-$(tme)"
}

while true;
do
    statustext
    sleep $TIMING
done

where the TIMING is to set the frequency to execute script in the while. You are free to setup wmfs command following the wiki and just change the part under quotes (like "Nibble" in my case).

Happy hacking!

About Daniele Dalla Torre

I'm a Civil Engineering student but I love to learn everything about technology, from the basics to the new frontiers! Here my gpg public key!

Leave a Reply

Your email address will not be published.

*