Building My Work Environment (Part 3)

Part 3 - Oh, what's that Window Manager?

Openbox used to be my de facto window manager for my systems for years. You can see some of my posts related to Openbox here. I have nothing but praises for its lightweight and solid performance (Not to mention it's highly customizable).

Then, I learned about Tiling window manager by chance. Tiling WM is designed to arrange windows in a way that they don't overlap each other. Also, it supports key-bindings to operate around keystrokes instead of using a mouse. That reminded me of vi/vim editor. Those facts piqued my interest.

I first started using Awesome Window Manager because it was a tiling window manger but also supported the floating option, which somewhat gave me a peace of mind. Awesome wm was highly configurable from a configuration file written in lua language. I quickly got around and configured it the way I wanted. However, a few months after, I noticed some keybindings stopped working and/or didn't behave the ways they should.

Then, I moved onto i3 window manager. It was next logical thing to try this wm as I read so many positive inputs about it. No regrets. It's easier to configure than Awesome wm because its configuration file is plain text, and it just worked. I've been using it a little more than a few months but I don't think I could go back to Awesome wm or stacking/floating window manager like Openbox ever again!

Disclaimer:
The information in this site is the result of my researches in the Internet and of my experiences. This information below is solely used for my purpose and may not be suitable for others.

Installation:

Installation of i3wm isn't that difficult with Slackware. Go to slackbuilds.org, download all dependencies, and install them one by one.... Installation of dependencies ... $ tar -xzvf i3.tar.gz i3/ i3/slack-desc i3/README i3/i3.SlackBuild i3/i3.info i3/doinst.sh i3/xinitrc.i3 $ mv i3-4.15.tar.bz2 i3/ # cd i3/ # ./i3.SlackBuild ... Slackware package /tmp/i3-4.15-x86_64-1_SBo.tgz created. # installpkg /tmp/i3-4.15-x86_64-1_SBo.tgz ... Executing install script for i3-4.15-x86_64-1_SBo.tgz. Package i3-4.15-x86_64-1_SBo.tgz installed.

At the beginning, I referred i3 like vi/vim. It's just like that. If you know right key combinations, your productivity would increase. But if you are not familiar with it, it's just so hard to deal with. In my humble opinion, although its learning curve is steep, it's worth learning how to properly use it.

To set i3 as your default windows manager, you'd need to run xwmconfig. $ xwmconfig

Config File:

i3's config file is located at ~/.config/i3/config, and it's a plain text file. It should be fairly easy to understand because of all the comments there. One thing you do need to remember is to reload the config file with $Mod+Shift+r each time the file has been modified.
=====
~/.config/i3/config
=====

Status Bar:

By default, i3 does not offer a status bar unless you install one. I tried with i3blocks and configured it with mpd/ncmpcpp support and everything I wanted to show in my status bar on my notebook with Debian stretch; however, to install i3blocks on Slackware, you need to go through ridiculous number of dependencies. For that reason, I gave up on installing i3blocks. Instead, I installed i3pystatus. i3pystatus was so easy to set up and manage it because each piece is a module, and it didn't take me long to configure it as I wanted.

Before i3pystatus can properly display, some python modules need to be installed: $ pip3 install --upgrade pip ... $ pip3 install netifaces \ > psutil \ > colour ... $

The i3pystatus version I downloaded from slackbuilds.org is 3.35. I'm not sure if this problem only applies to this version but when memory usage is displayed with {used_mem}, it displays a negative value. After reading up on different forums, I figured out that its source code for mem.py did not support newer version of psutil. Within the code, to get the value of used memory, it was subtracting cached and buffers values from used value. This was ok for psutil version before 4.4.0. With newer psutil (> 4.4.0), getting the used value itself was good enough, I guess.

To prove my point, this is what's going on: $ python3 >>> import psutil >>> psutil.__version__ '5.4.5' >>> mem = psutil.virtual_memory() svmem(total=...) >>> print(mem.used - mem.cached - mem.buffers) <== This is what's done in the code -311427072 <== Gives a negative value >>> print(mem.used) <== For newer psutil version, this is all you need 301985792

Now, we need to edit the source code to take care of newer version for psutil. 1) Change 2nd line from this:from psutil import virtual_memory to: import psutil 2) On line 45 and 46, there is a piece of code to get used memory. That should be changed from:memory_usage = virtual_memory() used = memory_usage.used - memory_usage.cached - memory_usage.buffers to:memory_usage = psutil.virtual_memory() if psutil.version_info < (4, 4, 0): used = memory_usage.used - memory_usage.cached - memory_usage.buffers else: used = memory_usage.used This should take care of displaying a negative value for used memory in i3pystatus.

=====
~/.config/i3/i3pystatusconf.py
=====

Screen Lock:

I use i3lock to lock the screen. It's simple and customizable.

Shutdown, Reboot, and Logout:

The official way of getting out of i3 is to press $Mod+Shift+e simultaneously. This will show a message bar on top of the screen. Then click on yes, exit i3 to exit. I found this step a bit cumbersome. I could type sudo /sbin/shutdown -h now in a terminal but I'd need to open one if I'm in say web browser workspace. So, I created a i3 mode to handle key combinations to logout, lock screen, reboot, or shutdown (referenced Arch Linux Wiki).

For this to work, sudoer needs to be enabled for a regular user to run the shutdown or reboot command.# visudo ------------------------ [user_name] ALL=NOPASSWD: /sbin/shutdown,/sbin/reboot

In next article, let's talk about changing the look and feel of i3 window manager.

That's all!
-gibb

Post a comment

You may use the following HTML:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>