This guide will mostly about awm’s widgeting system, if you wanna learn about other things about awm, check out this guide by Stella. I am assuming you are using awesome-git and know thebasics of lua. The code for this can be found in this repo. Let’s just start with no bullshit.
Quick Setup
Ensure you are using awesome-git.
First remove the default rc.lua and replace it with this modularized config.
Add your wallpaper to theme/wall.jpg
Edit the contents of theme/init.lua
Add in colors, fonts and some gaps
Create a helpers.lua file
And now if you will restart awm, you will get something bland and tiny like this
Looks bad, but a perfect canvas for us to work on.
Pro tip: Testing
If you do not want to restart your wm everytime to test a change, you can use Xephyr to test it. According to the arch wiki: ‘Xephyr is a nested X server that runs as an X application.‘
The Bar
First lets remove everything from bar and delete every file in ui/wibar/module except ui/wibar/module/init.lua
wibox.container.place is used to set the valign and halign properties on widgets. halign can be set to left, center and right while valign can be set to top, bottom and center.
wibox.layout.align takes in exactly 3 elements, first for the left, then the center and then the right, as we do not want anything in the center of the bar, we will put nil there.
We have also increased that height of the r to 50px.
Right Side
First of all, let’s create a module for showing time in the bar. Let us create the file
Awm has a built in widget called wibox.widget.textclock to display the time. Now:
And the last step to add it to the bar.
As I will have multiple modules on the right side of my bar, I have wrapped it in a wibox.layout.fixed.horizontal, which is essentially a horizontal line, also I have wrapped the entire right section in a wibox.container.margin to the section some margin.
Test/Restart awm to see a tiny clock on the right.
Making the clock look better.
Well we got our clock, but it still looks a bit boring. So let us make the hour bolder and blue in color and also give it a background color as well.
For this we will use the helpers.colorizeText() from our helper functions. It takes the text and a color.
format in textclock and markup in textbox allows the use of Pango markup so, <b> and < /b> gives bold text.
Now modifying what we return we get:
This is just a background widget, which uses one of our helper functions to give a suble rounded rectangle. Inside this background widget, we have a container for margin, which is 5, and inside the margin container their is the time which is placed in a horizontal layout.
Wifi and Bluetooth Symbols
First, install svg icons of wifi connected, disconnected and bluetooh connected and disconnected from any icon set you want. My choice is Phosphor Icons. Now we will define them in the theme/init.lua file and also recolour them to white.
Before using these images, we need some sort of signal to indicate whether wifi/blueooth is on or not. Here is how to make one for wifi.
The code above is fairly easy to understand, every 2 seconds, a function is called which executes the following process bash -c 'nmcli networking connectivity check'. If the output of the command does not has none in it, it emits a signal called signal::network with the value true, if the output of the command has none in it, the value is false.
Now lets make one for bluetooth
And now to call them in the main file
We can now finally start creating the actual widgets. Let’s create two image boxes
You will notice their is an id prop in the imagebox widget in both of them, we will see in the next step as to how to use them to change the image. Now we would like to connect to the signals we just made so to change the image. For that we would use awesome.connect_signal.
We cannot directly access the imagebox element of wifi/bluetooth, to do that we need to use get_children_by_id(id) which returns an array of all elements with that id.
Progress bars
The next thing we will be making would be a ttery and a volume indicator. Let us create a new file for that called ui/wibar/module/progress.lua and also include it in the module/init.lua file
We should also just create a sic progress file and we will add elements in them later.
and then also add this to the bar.
Services for Battery and Volume
For battery, we will read the file /sys/class/power_supply/BAT0/capacity to get the charge of laptop and /sys/class/power_supply/BAT0/status to get the status of charging of laptop. And then we refresh it like the other signals with gears.timer.
For volume, I will be using the program pamixer to get the level. You are free to use your own program.
Finally, inlclude these in your init.lua
Using the services
For battery we will use the in builtin widget wibox.widget.progressbar. If we closely see the shape of your battery, it is actually a horizontal layout with progress as the battery and a little stick as the bulb. To recreate that in awm, we can do
At this point, I think the code is self explantory. The progress bar on default goes from left to right, to make it go right to left, we use wibox.container.rotate and set the direction to “south”, whihch essentially rotates it by 180 degrees.
For volume, we will be using circular progress bars. This is also an inbuilt widget in awesome called arcchart, here is how we will implement it.
And now let us add them into the widget we return
Quick Profile Picture
Also let us add a profile picture at the end of our bar. Since we may use it multiple times on many widgets, it is best to define it in the theme itself.
Let us define the widget at ui/wibar/module/profile.lua. Here instead of shape,we will be using clip_shape to make our images rounded.
I will leave it as task for you to add it to the end of the bar. Now lets add a systray to wrap up the right side of our bar.
Yup, that is basically it, it is that easy to create a systray. And from now I will leave it upto you to add these modules into the bar.
This is how out bar looks right now.
Left Side
Launcher Button
Lets create a launcher that can be later used to open the appmenu, dashboard, whatever you want. It is basically circle in a circle, To create it
Be Sure to add it to the LEFT SIDE of the bar.
Taglist
First configure the tags in config/user.lua, I’m going to numbers 5 tags. Clone this folder from my repo called mods/animation in module/animation. It is going to help up with animations. The taglist uses some colors from our theme/init.lua to color the taglist. As we do not need text, we will only set the background colors
How the animation module work?
Now let us actually create the taglist. The file will return a function that takes in screen as a parameter.
Now you know a lot of things already, so I will be giving you the challenge to create a layout box by yourself. No worries, if you cannot do it, It would be in the repo. Here are some things additional things that would be used:
If you successfully did it, we would be left with a bar like this:
Bonus: Titlebars
The titlebars look bad, do let us make them look good and minimal at the same time. But first we will need to download icons. I will once again use phosphor for this, you are allowed to use your own icons. Then we need to add them in our theme.lua
Now let us edit modify the existing titlebar in ui/titlebar/normal.lua
Restart the WM and you get some rather good looking titlebars! And your basic tutorial is complete.
This could be a series but these are very time consuming and energy draining tasks. But it could be one series.
Thanks for reading this, I hope it made your awesome journey easier.
Credits
gw for their starter config. (give him a follow, great guy)
naina_ on unixporn discord from whom this rice is loosely copied.