Qtile

From ArchWiki
Revision as of 19:56, 28 December 2012 by Myle (Talk | contribs) (Configuration: Sound)

Jump to: navigation, search

From Qtile web site:

Qtile is a full-featured, hackable tiling window manager written in Python. Qtile is simple, small, and extensible. It's easy to write your own layouts, widgets, and built-in commands.It is written and configured entirely in Python, which means you can leverage the full power and flexibility of the language to make it fit your needs.

Installing

Qtile (git version) is available in the AUR: qtile-gitAUR.

A default configuration file is provided on the git repository. Copy it in ~/.config/qtile/config.py.

An easy way to do this is:

$ mkdir -p ~/.config/qtile/
$ wget https://raw.github.com/qtile/qtile/master/libqtile/resources/default_config.py -O - > ~/.config/qtile/config.py

Starting Qtile

To start Qtile add exec qtile to your ~/.xinitrc and launch Xorg. The default configuration includes the shortcut Template:Keypress to open a new xterm terminal.

Configuration

Note: This chapter only explains the basics of the configuration of Qtile. For more complete information, look at the official documentation.

The configuration is fully done in python in the file ~/.config/qtile/config.py. The indentation is very important in python, therefore respect it.

Before restarting Qtile you can test your config file for syntax error with the command:

$ python2 ~/.config/qtile/config.py

Groups

In Qtile the workspaces (or views) are called Groups. They can be defined as following for instance:

from libqtile.manager import Group
groups = [
    Group("term"),
    Group("web"),
    Group("irc"),
]

Keys

You can configure your shortcuts with the function Key. Here is an example of the shortcut Template:Keypress to quit the Windows Manager.

from libqtile.manager import Key
from libqtile.command import lazy
keys = [
    Key(
        ["shift","mod1"], "q",
        lazy.shutdown()
    ),
]

You can find out which modX corresponds to which key with the command xmodmap.

Screens and Bars

Create one Screen function for every monitor you have. The bars of Qtile are configured in the Screen function as in the following example:

from libqtile.manager import Screen
from libqtile import bar, widget
screens = [
    Screen(
        bottom=bar.Bar([
            widget.GroupBox(),
            widget.WindowName()
            ], 30))
]

Widgets

You can find information on the widgets in the documentation.

Some of the widgets (such as BatteryIcon and Notify) are not included in the default git repository, but you can download them here and copy them in /usr/lib/python2.7/site-packages/libqtile/widget/.

Then modify /usr/lib/python2.7/site-packages/libqtile/widget/__init__.py to import the new widgets. Here is an example for BatteryIcon and Notify widgets:

/usr/lib/python2.7/site-packages/libqtile/widget/__init__.py
[...]
from battery import Battery,BatteryIcon
from notify import Notify
[...]

Startup

You can start up applications using the corresponding hook.

Here is an example where an application starts only once:

import subprocess,re

def is_running(process):
    s = subprocess.Popen(["ps", "axw"], stdout=subprocess.PIPE)
    for x in s.stdout:
        if re.search(process, x):
            return True
    return False


def execute_once(process):
    if not is_running(process):
        return subprocess.Popen(process.split())


@hook.subscribe.startup
def startup():
    execute_once("parcellite")
    execute_once("nm-applet")
    execute_once("dropboxd")
    execute_once("feh --bg-scale ~/Pictures/wallpapers.jpg")

Sound

An easy way to configure your sound is to add a user to the audio group and use the alsamixer command line interface.

keys= [#...
    # Sound
    Key([], "XF86AudioMute", lazy.spawn("amixer -q set Master toggle")),
    Key([], "XF86AudioLowerVolume", lazy.spawn("amixer -c 0 sset Master 1- unmute")),
    Key([], "XF86AudioRaiseVolume", lazy.spawn("amixer -c 0 sset Master 1+ unmute"))
]

See Also