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.

Slacker, grab your towel and don’t panic!

Over the last few days there has been some unnecessary drama around Slackware. Some Slackware users (including myself) might have slightly overreacted to Eric’s comment. This, together with some poor journalling practices of a certain individual have opened a debate, not necessarily about Slackware’s future – because it doesn’t seem endangered in any way, but about Slackware website. Despite its negative aspects, the situation has shown how dedicated to Slackware its users are with their donations. I’m sure Pat will put these extra few dollars to a good use. I have learned so much using Slackware that it’d be inappropriate not to donate money.

Thank you Pat and the rest of the Slackware crew.

Python 3 shell in Emacs

If you’d like to run a Python 3 shell within Emacs you could issue the following command:

C-u M-x run-python

It’ll then prompt you to confirm which Python version you’d want to run. You can just type 3 and click Enter again. If you use it a lot, however, it’s not going to be the most convenient of the solutions. You could automate the whole process by adding the following 2 lines to your ~/.emacs file:

(defun run-python3 () (interactive) (run-python "python3"))
(global-set-key [f5] 'run-python3)

The second line assigns a keybinding to the command. In the example above it is the F5 key.

NTS#2

“Any sufficiently complicated C or Fortran program contains an ad hoc, informally-specified, bug-ridden, slow implementation of half of Common Lisp.”

Greenspun’s tenth rule of programming