AwesomeWM Tutorial
NOTE - This tutorial was made considering you have a basic experience is lua
This tutorial requires awesome-git
and imagemagick
. I am using nixos and if you use it too, you can install it via nixpkgs-f2k.
helpers.lua
file with these functionstheme/init.lua
fileSo let us start without wasting any more time. You need some libraries to implement this. Add this on the top of your file:
awesome.connect_signal()
: This function is used to create a callback for a specific signal. When that signal is called, the callback function is executed
awesome.emit_signal()
: This function is used to trigger a signal. When this function is called, all the registered callbacks associated with it are called
This is an example of how signals work
awful.spawn
is a function that allows the execution of external commands or programs. great thing about them is that they do not block io.popen
like os.execute
Now that we have learned the basics of signals and spawn we can define our commands
wibox is simple UI element in awesomewm that can be turned into anything you want. for now we want it to be a widget
woah this is a lot of code, let us break down what happen
well this is required to render your widget in all the screens you have
wibox
exit is the main the big widget that we are going to display on the screen. to set its background to transparent i have added 00
to the current background color
exit:setup
is required to put widgets inside this widget to actually display something other than a blank box
awful.placement.centered
places the widget at the center of the screen.
At the end you will see that I have used signals again. This time they are being used to make a signal for toggling the exit
wibox.
To make this work with a keybind add this to your keybind files
To create widgets that we will add to our main wibox, we use wibox.widget
. To make a button to close and open, we use:
Exaplaining the code -
widget = wibox.container.place
:This tells us what type of widget are we trying to display. Every widget requires atleast 1 widget
or layout
property. wibox.container.place
allows to place smaller widgets into larger space.
halign
Stands for horizontal alignment that can only be used with wibox.container.place
. The left
part should be pretty clear. (hint: it moves the element to the left side)
buttons
This is used to add mouse interactions. The 2nd argument specifies what type of argument. 1 means left click, 3 means right, 2 means middle, 4 means scroll up and 5 means scroll down. The third arguments lets us tell what we actually wanna execute.
Now instead of create 5 wibox.widgets
, we can create one function to make them for us
Now we can add all of our elements in a single big element
to make this structure a bit less confusing here what is actually happening
This is where imagemagick
comes into play. But first we will have to make a widget for it
Now we will execute a command with awful.spawn.easy_async_with_shell
to use imagemagick
to convert our wallpaper into a blurred image. easy_async_with_shell
will help us set the background image after the image has been converted
now we can update the exit:setup
to be:
the wibox.layout.stack
allows widget to be placed on top of each other
to listen for keypresses we can use the awful.keygrabber()
. This will help us to execute the comands without using mouse.
as we want it start right after opening our widget we set the auto_start
to true
To start and end the keygrabber, we can edit the toggle signals as follows:
And we are done! Congratulations on making it this far! This is the full code
And now to make it work, you can require the whole thing in your main file
Namish
( っ˶´ ˘ `)っ made out of ❤️ and boredom
built with astro