Integrating widgets into awesome
| Languages: |
English • Deutsch |
This tutorial is a short introduction into text widgets for Awesome 2.3.x A little understanding of bash scripting helps a lot here.
Preparing a textbox
First, we add the new textbox to your ~/.awesomerc:
screen 0
{
general
{
...
}
...
statusbar mystatusbar
{
taglist mytaglist
{
...
}
### THE TEXTBOX STARTS HERE ###
textbox mytextbox
{
align = "right"
text_align = "right"
width = "120"
text = "foobar"
}
}
}
The 'width' parameter should be tweaked to fit the text contained by the box. If you just want a static textbox which doesn't change its content, you are done now. If you want the content to change from time to time, read on.
Dynamic data
If you want the content of your textbox to change, you can remove the 'text' property from the textbox above, as it will be set by an external shellscript.
For setting the content of a textbox to the output of some program, usually a command like the following is used:
echo <screen> widget_tell <statusbar> <textbox name> text `<program>` | awesome-client
<screen> is to be replaced by the screen the widget is on, starting with 0 <statusbar> is to be replaced by the name of the statusbar the widget is on, in our example the name is 'mystatusbar' <textbox name> is to be replaced by the textbox name, which is 'mytextbox' in the example <program> is to be replaced by the program to read from, the following example will use 'date +%H:%M:%S' for that
Now create the file ~/.awesome/widgets with the following content:
#!/bin/bash while true do echo 0 widget_tell mystatusbar mytextbox text "[`date +%H:%M:%S`]" | awesome-client sleep 1 done
This will update the time displayed by the widget every second ad infinitum.
Now make the file executable:
chmod +x ~/.awesome/widgets
And add it to your ~/.xsession or ~/.xinitrc:
~/.awesome/widgets & exec awesome
If you then log out and back in, the time should be shown in a new widget on your status bar.
Integrating graph widgets
This is an example to show the current RAM usage in the status bar:
graph mem {
width = "40"
data mem_used {
scale = false
max = 512
draw_style = bottom
}
}
Replace the '512' in that example with the actual size of your RAM in megabytes.
Now open up ~/.awesome/widgets and add the following line to the loop before the sleep statement:
echo 0 widget_tell mystatusbar mem data mem_used `free -m | tail -n 2 | head -n 1 | awk '{print $3}'` | awesome-client
After a logging out and back in, the RAM usage should be shown in your status bar.