Organizing windows in Linux with bspwm


The ‘window manager’ is the software that ensures that windows can be drawn on your screen. Do you open the browser on your PC? Do you drag the window or drop it somewhere else? All are interactions with the window manager. Often the manager does little more than facilitate the display and manipulation of these windows. However, there is a class of window managers that can greatly increase your productivity: the tiling window manager. The window manager we use here is called ‘Binary Space Partitioning Window Manager’, ‘bspwm’ for short.

Such tools automatically arrange and rearrange windows according to how many you have open. Do you open a Word file while you already have the browser open? Then the screen will automatically be divided in two, without you having to hold the computer mouse. A subsequent application will then split the new Word window in half, unless you have configured the window manager differently. However, there are no tiling window managers available for Microsoft Windows. If you want to be more productive on the computer, you will first have to install Linux. There are plenty of options, including ‘awesome’ and ‘i3’. Please note that these managers will only work if you use the X Window System on your installation. If you use Wayland, a manager like ‘Sway’ is the preferred option. This workshop was written for systems running Ubuntu or a derivative of it with the X Window System.

This is what bspwm looks like if you open three windows in a row.

Step 1: Install the necessary packages

Before you can install bspwm it is necessary to download the necessary packages. The most obvious way to do this is through the package manager. You can also find the code on Github and download it directly from there. In the latter case you will still have to look for a number of programs that are otherwise simply included. For the easiest experience, open a terminal window and type in the following:

sudo apt install bspwm feh suckless-tools

That way you install bspwm and some other programs that will make your life a lot easier.

Step 2: Create configuration files

Bspwm gets its instructions from a configuration file. To make sure everything works, you can use the default values. You can then adjust it so that the system reacts exactly the way you want it to. In addition to bspwm, the ‘Simple X Hotkey Daemon’ (sxhkd) was also installed in the previous step. This program controls all hotkeys and also gets its instructions from a configuration file. So you will also want to copy this. You also need to make sure that the bspwm configuration file is executable – otherwise the window manager won’t be able to do much with it.

mkdir $HOME/.config/bspwm && mkdir $HOME/.config/sxhkd

cp /usr/share/doc/bspwm/examples/bspwmrc $HOME/.config/bspwm/

chmod +x $HOME/.config/bspwm/bspwmrc

cp /usr/share/doc/bspwm/examples/sxhkdrc $HOME/.config/sxhkd/

Step 3: Modify configuration file bspwm

In its default configuration, bspwm is not particularly attractive. However, you can easily change that: a number of settings make the user experience a lot better. It is best to use your original desktop environment or a TTY terminal for this. To do this, first open the configuration file with a text editor of your choice. ‘Gedit’ is a good option, as it comes bundled with Ubuntu by default.

gedit $HOME/.config/bspwm/bspwmrc

Once you have opened the file, you can add settings. You can add this at the top of the configuration file, under ‘#! /bin/bash’. This is also where you set your desktop background – so make sure you know where it is. It is recommended to keep the backgrounds in a separate and recognizable folder.

xsetroot – cursor_name left_ptr

feh –bg-scale $HOME/Pictures/Desktop wallpapers/background.jpg

You also want to make sure that sxhkd can work. You also put this in bspwmrc, the configuration file we are currently working on. If you tap on a QWERTY keyboard, you can call up sxhkd in the configuration file and move it to the background with ‘sxhkkd &’. If you are using an AZERTY keyboard, put the following under ‘#! /bin/bash’. This way the program knows that some keys are different.

sxhkd -m -1 &

Step 4: Choose a terminal emulator

Before you are ready to take your first steps with bspwm it is a good idea to edit the configuration files for sxhkd. We are currently adjusting one setting – the rest is for later, once you can get started with bspwm.

More specifically, you want to make sure that you can also open a terminal window in bspwm. By default, the software points to urxvt. If you have installed this, you can leave it. Otherwise you really have to adjust this. To do this, open the configuration file with a text editor and change the value ‘urxvt’ to ‘x-terminal-emulator’.

gedit $HOME/.config/sxhkd/sxhkdrc

Step 5: bspwm for the first boot

To start bspwm for the first time, log out or reboot the system. On the login screen, where you have to enter the password, you will see that a gear has been added at the bottom right. If you click on this, a menu will appear. Here you select ‘bspwm’. Then you can log in as you always do.

Step 6: Configure sxhkd

In bspwm, the keyboard is the most common way to navigate the system. So you will use a lot of shortcuts. For the most optimal user experience, it is therefore recommended that you set those shortcuts in a way that you can handle them. To do this, open your terminal emulator. If you did step 4 correctly, you can do this by pressing the Windows key and enter at the same time. Then navigate to the sxhkdrc configuration file and adjust the settings as desired. You can also continue to use the default configuration. The configuration file is then useful to check which hotkey is associated with which action.

gedit $HOME/.config/sxhkd/sxhkdrc

For example, we like to make the keyboard shortcuts somewhat similar to how they function in MacOS. In other words, the super key (here it’s the Windows button) in combination with ‘w’ closes windows, while super+q closes a program completely. In the screenshot below you can see the result before and after.

The default setting is on the left. Ours is on the right.

Step 7: Open Programs

You may have noticed that in bspwm there is nothing on the desktop. So you will have to use the keyboard. By default, sxhkd allows you to open a launcher called ‘dmenu’ by tapping Windows and the space bar. There you can type (the beginning of) the name of a program and press enter. Whether it’s Firefox, Nautilus (the default file browser in Ubuntu) or a script you wrote yourself.

Step 8: personalize

The handy thing about bspwm is that you can not only configure the entire window manager yourself, but also program the hotkeys and the associated actions with sxhkd. Would you like a status bar? Then you can make it yourself with programs like ‘lemonbar’ or ‘polybar’. ‘Dunst’ is a program with which you can activate notifications. Looking for a more visually appealing alternative to dmenu? Then take a look at ‘rofi’. Do you need inspiration? On Reddit, there’s an entire subreddit (r/unixporn) dedicated to customizing your system.

About admin

Check Also

Xiaomi is launching four new robot vacuum cleaners

Xiaomi is announcing new AIoT products to enhance the indoor and outdoor smart experience at …

Bir cevap yazın

E-posta hesabınız yayımlanmayacak. Gerekli alanlar * ile işaretlenmişlerdir