i3 4.3 on Slackware

I welcomed yesterday’s release of i3 4.3 with excitement. Having been busy elsewhere, I did not follow the ‘next’ branch of i3 git repository and, therefore, was not aware of what’s cooking. The moment I started building a new shiny package, my excitement somewhat subsided.

Pango support

Version 4.3 introduces pango support for rendering text, which would be a great news if not for the fact that an XCB backend support was still an experimental feature (and, therefore, disabled by default) in cairo 1.10.2, the version that Slackware (14rc5) ships with. In consequence, for i3 >= 4.3 to build on Slackware, one would have to upgrade the stock cairo package. The XCB backend has apparently reached a stable status and is enabled by default in cairo version 1.12.2+. As always, Pat is the person to decide whether it is mature enough for Slackware. Hopefully, it is and it’ll enter the -current branch of Slackware in the next development cycle. (Update: See Pat’s comments on the issue).

An alternative solution (which I have chosen) was to disable pango support in i3 4.3. As this feature is an integral part of i3wm 4.3, disabling it is not recommended by Michael Stapelberg, i3 author and main developer (4.3 release notes):

Another very important change is that we now support pango for rendering text. The default is still to use misc-fixed (X core fonts), but you can use a font specification starting with “xft:” now, such as “xft:DejaVu Sans Mono 10″ and i3 will use pango. The sole motivation for this is NOT to have fancier window decorations, but to support fonts which have more glyphs (think Japanese for example) and to support right-to-left rendering (open http://www.ftpal.net/ for an example). Supporting users from all over the planet is important, and as such I would strongly advise distribution packagers to leave pango support enabled. In case you are working on a very low-spec embedded device, it is easy enough to disable pango support, see common.mk.

Personally I do not need it so am going to run 4.3 (pango disabled) until cairo gets upgraded in Slackware (I’m not in a hurry:)). You can do the same but don’t say you haven’t been warned!!!

Here is my SlackBuild script for i3 v 4.3 (pango disabled). Please note that I pointed it to the master branch of i3′s git repository which basically is the latest stable release + bug fixes, which at the moment of writing is 4.3. Should a new version be released, eg. 4.4, the script will automatically pull it from the git repository. Unlike with standard SlackBuilds there’s no need to manually download the source code.

Feel free to use it but bear in mind that, at the moment of writing it, a recommended version of i3 to be run on Slackware is i3 4.2 which is available from SlackBuilds.org so if you don’t like living on the edge, please stop reading now and stay with 4.2!

Now for the fun part.

What’s new?

Apart from the above mentioned pango support (which we have disabled) there are lots of bug fixes and some new features available with this release. I particularly like the ability to specify the layout for the parent split container:

 for_window [class="XTerm"] layout tabbed

When I start i3 both Firefox and Thunderbird start on Window 2. Up until now it was not possible (or easy) to make them automatically open in a tabbed mode. This ensures that Window 2 (and only 2) starts in a tabbed mode.

assign [class="Firefox"] 2
assign [class="Thunderbird"] 2
for_window [class="Firefox"] layout tabbed
exec firefox
exec thunderbird

Layout toggle

In 4.3 you can still use the old “split h” and “split v” commands. On top of that, the old “layout default” command has been replaced with “layout toggle split”, which changes the orientation (horizontal/vertical) of windows. If you have an old config file, find “layout default” and change it to “layout toggle split”. On my system it’s bound to “Mod1+e”. Open a few terminal windows and play with this command changing the focused window from time to time.

Efficient CLI Navigation

The CLI (Command Line Interface) is a very powerful, flexible and extremely programmable environment that lets you do anything you can ever think of …well, perhaps except for slaying the Dragon of Isengard. To harness its power, one’s mind needs to be as clear as the cloudless hour, and thoughts as pure as mountain dew. Although the road to enlightenment is long and arduous, there are some shortcuts that will help keep what’s left of your sanity.

Below you’ll find some tips on efficient navigation in the CLI.

Go Back Home

The cd command takes you back to your /home directory:

$ pwd
/home/user/data/documents/work
$ cd
$ pwd
/home/user

Go Back to the Previous Directory

To go back to the previous directory, you can use cd with a dash (-):

$ pwd
/home/user/.i3/config
$ cd ~/data/projects/dotfiles/i3
$ pwd
/home/user/data/projects/dotfiles/i3
$ cd -
/home/user/.i3/config
$ pwd
/home/user/.i3/config

Use the Last Argument of the Previous Command

The $_ variable returns the last argument of the previous command. This can be helpful in a variety of scenarios:

$ pwd
/home/user/downloads/
$ cp i3status.tar.gz ~/data/builds/i3/i3status
$ cd $_
$ pwd
/home/user/data/builds/i3/i3status
$ chmod +x /path/to/my/script/script.sh
$ $_
(This will execute script.sh)

Bash Aliases

You can make your life easier by creating aliases (= shortcuts) for commands that you use often. The syntax is very simple:

name_of_the_alias='value'

You can place your aliases in ~/.bashrc. You might need to create this file. Each time you edit this file you need to source it afterwards for the changes to take effect:

source ~/.bashrc

or

. ~/.bashrc

When it comes to navigation, one could, for example, create a few aliases to speed up navigating up the directory tree:

alias 1.='cd .. ; pwd'
alias 2.='cd ../.. ; pwd'
alias 3.='cd ../../.. ; pwd'
alias 4.='cd ../../../.. ; pwd'

The value of an alias can be quite complex. As you can see, 4. will first change directories (cd ../../../..) and then print the current working directory – pwd. Please note a semi-colon (;) separating the commands.

$ cd data/projects/python-dir/euler/
$ 4.
/home/user
$ cd -
/home/user/data/projects/python-dir/euler
$ 3.
/home/user/data

Aliases can be used in a number of different ways. A few more examples:

alias epyt='emacs -nw /home/user/data/projects/python-dir/32-problem.py'
alias slacktop='ssh user@slacktop'

Directory Stack

BASH features some helpful directory stack buildins that help you navigate recently visited directories.

pushd – push a directory into the directory stack and cd to it.
popd – remove a directory from the directory stack and cd to it.
dirs – display the list of the directories in the stack.

How does it work in practice?

First of all, add a directory to the stack. Please note that it also automatically switches to the directory (the -n flag suppresses this behaviour).

user@darkstar:~$ pushd data/projects/programming/
~/data/projects/programming ~
user@darkstar:~/data/projects/programming$

Alternatively, you can cd to a given directory and issue:

pushd .

After adding a few directories you can display the content of the stack:

user@darkstar:~$ dirs -v
0 ~/projects/web-develop/project-eden/includes
1 ~/projects/web-develop/project-eden/includes
2 ~/projects/web-develop/project-eden/pages/en
3 ~/projects/web-develop/project-eden/css
4 ~/projects/designs
5 ~/projects/notes
6 ~/public_html/project_eden

Please note that the first entry always displays the current working directory so if it also sits at the top of the stack, you’ll see what seems like duplicate lines. The -v flag is responsible for a nicely indexed output.

To switch to one of the directories in the stack you could issue:

user@darkstar:~$ cd $(dirs +2 -l)
user@darkstar:~/projects/web-develop/project-eden/pages/en$

Admittedly, this is not the most concise way of changing directories. To make it shorter we can add an alias and a function to the ~/.bashrc file.

alias dv='dirs -v'

List the current stack by simply typing dv.

cdd()
{
    position=$1
    if [ -z $position ]; then
        echo "You need to specify a directory in the stack"
    else
        cd $(dirs +$1 -l)
    fi
}

The cdd function (based on this one) makes it possible to cd to a given directory from the stack by typing:

cdd 3

Hope this will help you in your quest to become a CLI wizard.

ThinkPad E530 with Slackware

Recently I have purchased Lenovo ThinkPad E530. Unfortunately, I can see a big difference between it and my previous Lenovo laptop, ThinkPad T410. Straight away you notice that they belong to different categories. But then again, as opposed to a budget class E530, the T-series is a business class model (and is therefore appropriately priced) so the comparison would not be fair.

Still, I like it; especially the fact that everything seems to work out of the box on Slackware 14 (still -current at the moment of writing). It appears that the purchase was timed quite well. E530 features the following wifi chip:

03:00:0 Network controller: Intel Corporation Centrino Wireless-N 2230 (rev c4)

The iwlwifi module supporting this chip has been added with kernel 3.2.0 so it looks like the wifi card wouldn’t work out of the box on Slackware 13.37 and older.

Thunar doesn’t automount usb drives in i3 (Slackware-current)

Monitoring Slackware’s irc channel has always been a pleasurable experience. Most of the time it is also extremely informative. Yesterday on #slackware someone reported that Thunar doesn’t automount usb drives under i3 any longer. It also applies to some other window managers. The solution involves adding dbus-launch –exit-with-session to your .xinitrc:

# Start the window manager:
if [ -z "$DESKTOP_SESSION" -a -x /usr/bin/ck-launch-session ]; then
  exec ck-launch-session dbus-launch --exit-with-session /usr/bin/i3
else
  exec /usr/bin/i3
fi

Task integration into the i3 statusbar

Recently I have been playing with TaskWarrior which is a very powerful command line todo list manager. I’ve decided to integrate it with my i3 statusbar and enable key bindings for some basic list management.

Here’s a very basic sample of Task’s output:

[sycamorex]~% task ls

ID Project Pri Description
4         H   Create a blog post
1             Configure Mutt
2             id3 tags
3             Email Linus T.
5             zsh prompt

5 tasks

i3status bar configuration
I’ve added some customised code to the i3statusbar.conf file to display the most urgent task in the statusbar.

Please note that the LG line below might safely be removed as it’s responsible for printing they current keyboard layout.

#!/bin/sh
i3status | while :
do
    read line
    echo "TODO:$(task ls | sed -n '4s/[[:blank:]]\+/ /pg' )\
| LG: $(setxkbmap -print | grep xkb_symbols | awk -F"+" '{print $2}') \
| $line" || exit 1
done

The above file will be executed from i3′s main config file ~/i3/config:

bar {
        status_command ~/.i3/i3status.sh
}

i3statusbar

As you can see from the screenshot, it is task number 4. The H letter after the task number indicates that the task is of a high priority which results in it being displayed at the top.

Furthermore, you can use some keybindings to mark the task completed and therefore remove it from the status bar displaying another task in the queue.

bindsym $ms+Shift+D exec task $(task ls | awk 'NR==4  { print $1 }') done
bindsym $ms+t exec urxvt -title taskwin -e sh ~/.i3/display_tasks.sh
for_window [title="taskwin"] floating enable

As you can see, I have also created a keybinding (MS + t) to quickly view all my task in a floating window. It works similarly to i3′s idea of scratchpad and I might actually have used it here. Below is the contents of display_tasks.sh:

#!/bin/sh
task ls
read -p "Press Enter to close the window."

It all works fine if you use a simple and linear structure of todo lists. If, on the other hand, they include a number of projects/categories with each of them having their own set of priorities, you could modify the task command. The following command will display the most urgent task from the “work” project/category.

task project:work ls | sed -n '4s/[[:blank:]]\+/ /pg'

A better approach would be to be able to switch between categories using keys but that’s not what I personally need.

HTH

Slackware current ISO size

For the last year or so I have used Eric’s excellent mirror-slackware-current script (as a cronjob). This is a great way of staying up to date with the development in the -current branch of Slackware, as well as creating ISO images of Slackware-current snapshots. As Slackware is getting bigger, so is its ISO image. Fortunately, Eric has updated his script to make it possible to exclude some directories from the DVD. Before the upgrade, a Slackware-current’s ISO image exceeded 5GB of data. This obviously wasn’t ideal bearing in mind that a standard DVD medium can only hold 4.x GB. After the exclusion of /testing and /pasture the image takes as little as 2.2GB. Here’s the relevant snippet of the script:

# If you want to exclude more from the DVD ISO than just the ./testing                                    
# directory, you can add the directories to DVD_EXCLUDES.                                                
# The pathnames must be local to the top level and must start with ./                                    
DVD_EXCLUDES=${DVD_EXCLUDES:-"-x ./testing -x ./pasture -x ./source"}

Thanks Eric.

Simple CLI Minecraft Server Manager

Recently I have set up a Minecraft server on Slackware 13.37. Multiplayer takes a crafting joy to a new level. What I found a pain in the back was the necessity to manually edit the config file each time I wanted to change the world I’m in. The lack of any kind of world management encouraged me to write a basic ncurses world management script. At the moment it has the following functionality:

Minecraft Server Manager

Not much but it does exactly what I want it to do:) If you’d like to try it out, make sure you modify the script options.

Installing i3 wm 4.2 on Slackware

Update: I’ve taken over the maintenance of i3 and i3status on SlackBuilds.org so the scripts there have been updated and ready for you to use.

Everybody knows that tiling window managers are the cure to all the world’s problems. Not everybody knows, though, that i3 windows manager offers much more than that. It additionally offers a highly customisable working environment that lets you effectively do your work without any distractions. Both happiness and a productive working environment are just a few keystrokes away. Follow the next few paragraphs to reach the state of programming nirvana.

As SlackBuilds.org still offers version 3.x of i3 window manager, I decided to write a SlackBuild for version 4.2. Despite the fact that there are some fundamental configuration differences between versions 3.x and 4.x, the installation processes are almost identical. For that reason I decided to adapt the official i3 slackbuild to work with 4.2 (the latest stable release as of the moment of writing.)

i3wm Installation Process

The installation process is pretty straightforward. First of all, you need to install necessary dependencies: libev, yajl and dmenu (all of them available on slackbuilds.org). There are also optional dependencies that will greatly improve i3′s functionality (I’ll cover them in a separate section as they can be installed later.)

Having installed the required dependencies, you can either download my updated installation scripts and i3 source code or a precompiled binary package (x86_64 only):

Update: Please do not use the scripts below. They are only here for archival reasons. Please visit the SlackBuilds website for the latest versions of the scripts.
i3-4.2 source
i3 slackbuild
i3 package (64-bit)

Optional dependencies (highly recommended – especially i3status)

Optional dependencies include i3lock (a screen locker) and i3status (a status bar generator.)

i3lock

As far as i3lock is concerned, I didn’t bother even trying to install it as it requires PAM which is not included in Slackware. Instead I use slock (available from slackbuilds). The usage of slock is amazingly simple: run it (through dmenu, terminal or previously assigned keybindings) to lock the screen, and type your password to unlock it (if you mistype your password, press Esc to clear it and type the password again.)

i3status

i3status is a status bar generator which will help you display all sorts of information. You could stick to version 2.1 which is available from slackbuilds.org.
In that case you might need to set the option: output_format = none. Otherwise I’d recommend installing i3status 2.5.1. Regardless of the version you choose, you need to install ‘confuse’ (available from slackbuilds.org). Please note that you don’t have to install dzen2 with the latest versions of i3/i3status. If you decide to install v. 2.5.1, you can use my slackbuild scripts or a precompiled package (64-bit only):

Update: Please do not use the scripts below. They are only here for archival reasons. Please visit the SlackBuilds website for the latest versions of the scripts.
i3status source
i3status slackbuild
i3status slackware package (64-bit)

Once you’ve installed all the packages, you can set up the default X environment by issuing xwconfig as a standard user and run startx. If no previous i3 configuration is present, you’ll go through a short configuration wizard. You can accept the default settings. They are reasonable and a great starting point for your customisations. The project website offers great documentation (link), as well as a recently opened stackexchange-like FAQ section.

You should see a status bar at the bottom of the screen. To start your modifications, copy /etc/i3status.conf to ~/.i3status.conf where you can place your changes.

Slackware website update

Good news. It seems that the Slackware website saga has come to a happy ending. According to the -current changelogs, the old code has been updated:

Sat Jun 2 01:03:42 UTC 2012
As you’ve possibly noticed by now, slackware.com is back on the air, and
I’d like to take this opportunity to give a hearty thanks to Mark Post of
Slack/390 fame for updating the PHP code to make it happen! Eric Hameleers
and the rest of the crew also pitched in to help get it installed and
running on our other server. Thanks as well to all the folks who emailed
with offers of hardware, help porting, and other support for the site.
We really appreciated it. Viva la vie Slackware!

I welcome this news with relief. Despite the fact that for some time it has been clear that the problems only affect the website and the project itself is in no danger, the whole situation unnecessarily sidetracked users’ attention from what should matter most, ie. the distro itself. Hopefully, from now on we’ll be able to focus entirely on the development of the current branch. If you look at the changelogs, recently there have been quite a few udates.

Today’s bunch of updates brings a new little tool called iftop which, according to its website, is a network equivalent of the top command.

iftop does for network usage what top(1) does for CPU usage. It listens to network traffic on a named interface and displays a table of current bandwidth usage by pairs of hosts. Handy for answering the question “why is our ADSL link so slow?”.

It looks like a handy tool to use with the conky output.