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.

What is using my space on Linux?

I have previously written about ways of identifying directories that take up most space using command line. There are a number of ways you can pipe commands to find out directories large directories.

Today, however, I’d like to discuss a useful little program with an ncurses frontend, ncdu. Not only does it display directories in your chosen order (ascending/descending, by size/name), but also lets you interactively browse (and be careful: delete) them. To make sure you don’t delete something by accident, you can run the program in the read-only mode calling it with the -r flag.

Apart from ordering the files/directories by size or name, there are also a number of interesting display options like showing percentage or graph, showing/hiding hidden or excluded files and directories (you can exclude certain directories or files if you want.)

Although it is not part of the stock Slackware, it can be easily installed from slackbuilds.org (it does not have any additional dependencies.)

A new release of i3 window manager

Last week the i3 development team released version 4.2 of their superb tiling window manager. Among a number of new features, there was one that particularly caught my attention, a scratchpad command. The command creates a scratchpad container where any of your windows can be placed and displayed on demand. The scratchpad container gets displayed in the centre of a window in a floating mode. It’s a convenient place for windows that you do not want displayed all the time. Personally, I can think of the following uses of the scratchpad container: ncmpcpp, mc, bash prompt, email, REPL, or simply, as the name suggests, a scratchpad with emacs inside. Yes, you can have more than one scratchpad container.

How to use the scratchpad

First you need to edit your i3 config file (~/.i3/config)

# Make the currently focused window a scratchpad
bindsym $mod+o move scratchpad
# Show the first scratchpad window
bindsym $mod+i scratchpad show

First you move a currently focused window to a scratchpad with Alt+o, then you can toggle show/hide with Alt+i to see how it works. You can move more windows to the scratchpad. If you work on a dual-monitor setup, you can move the scratchpad between the screens with the standard move command as well as bring a window back to a normal tiling flow by disabling a floating mode on it.

Slackware – check installed packages with Python

Querying installed package is something I do every now and then. It’s usually needed to find out if all the necessary dependencies of a package have been met. On Slackware it is usually accomplished with a simple:

ls /var/log/packages | grep -i package

For example:

$ ls /var/log/packages | grep -i gconf
GConf-2.32.1-x86_64-1
perl-extutils-pkgconfig-1.12-x86_64-1_SBo

As a way of practising programming, I decided to simulate the above command in Python 3. Here’s what I’ve coded:


#!/usr/bin/env python3

import glob, os, sys

if len(sys.argv) != 2:
        '''Check if the user provided the required argument'''
        print('The {0} command takes exactly 1 argument!'.format(sys.argv[0]))
else:
        packages_directory = '/var/log/packages/'
        package = sys.argv[1].lower()
        for files in glob.glob(packages_directory + '*' + package + '*'):
            print(os.path.basename(files))

It might be slightly slower than using Bash but it does the job. As I’m not a seasoned Python programmer, there’ll probably be ways of optimising the code, which I obviously welcome. Feel free to provide feedback.