Status Bar with Amazing

From awesome
Jump to: navigation, search

Contents

HOW-TO: Awesome WM and Amazing scripts used for CPU load, memory usage, network traffic graphs etc. in status bar of Awesome WM

Widgets in Awesome offer a flexible way of showing stuff like CPU load graph, memory usage progress bar or network usage... This was usually managed by piping the data to awesome-client, but there are Amazing ruby scripts which take care of that and make it simpler - mostly because number of pre-made widgets.

Awesome 2.3 and Amazing master (from git) should work.

Archlinux people can:

yaourt -S awesome-git amazing-git

(don't forget to change the branch in amazing-git pkgbuild).

awesomerc

If you installed Awesome right now:

cp /usr/share/awesome/awesomerc ~/.awesomerc

Now lets add some widgets. They are being added to the statusbar part of the configuration file (~/.awesomerc).

        emptybox "spacea" { width = 4 }
        progressbar "batt"
        {
           vertical = true
           height = 1
           width = 8
           data "battdata"
           {
               bordercolor = "#222222"
               fg = "#333333"
               bg = "#000000"
               fg_off = "#000000"
           }
        }
        emptybox "space1" { width = 4 }
        textbox "eth" 
        {
            style { font = "DejaVu Sans Mono 9" }
            text = "eth0"
        }

        emptybox "space3" { width = 4 }
        graph "cpu_usage"
        {
           height = 1
           bordercolor = "#222222"
           width = 20
           bg = "#000000"
           data "cpudata1"
           {
               scale = true
               max = 100
               fg = "#eebb00"
           }
           #data "cpudata2"
           #{
           #    scale = true
           #    max = 200
           #    fg = "#ffb400"
           #}
        }
        emptybox "space4" { width = 4 }
        progressbar "memusage"
        {
           vertical = true
           height = 1
           width = 8
           data "memdata"
           {
               bordercolor = "#222222"
               fg = "#992200"
               bg = "#000000"
               fg_off = "#000000"
           }
        }

For information about widgets, well ~/.awesomerc overall, do:

man awesomerc

After editing the ~/.awesomerc, always check if the configuration syntax is valid:

awesome -k

Amazing configuration

Now lets create a file ~/.amazing/config.rb which would contain Amazing configuration and be automatically loaded by Amazing.

awesome {
  set :statusbar => "mystatusbar"
  #here you set the name of your statusbar
 
  widget("cpu_usage") {
    #because of good naming, amazing already know what module to use
    set :property => "data cpudata1"
    #here we write what part of the widget to modify - cpudata1 is the name of the data object in .awesomerc
    set :interval => 0.5
    #interval says, how many seconds wait before getting the data again
  }

  widget("eth") {
    set :module => :net_traffic
    #here because of non-standard naming we have to specify, which Amazing module (a.k.a. widget data-miner) to use
    property("text"){ "d:%3d u:%3d" % [@download_rate, @upload_rate] }
    #here is where the transfer of data happens, different syntax then with the cpu graph
    #in the {} is the string which is sent (printf-like syntax)
    set :interval => 0.5
  }

  widget("batt") {
    set :module => :battery
    property("data battdata"){@percentage}
    set :interval => 5
  }

  widget("memusage") {
    set :module => :memory
    property("data memdata"){@usage}
    set :interval => 2
  }
}
You can list Amazing modules by:
amazing -w
and see information about it by:
amazing -w net_traffic
If you are using archlinux, you can do:
yaourt -Ql amazing-git | grep widgets

xinitrc

That was the hard part. Now only add Awesome and Amazing into .xinitrc, so it is launched on X start:

amazing &
awesome

Thats it!

Personal tools