Qtile
http://qtile.org より:
- Qtile はあらゆる機能を備え、ハックしやすい、Python で書かれたタイル型ウィンドウマネージャです。Qtile はシンプルで、小さく、そして拡張性があります。ユーザー定義レイアウト、ウィジェット、そしてビルトインコマンドを簡単に書くことができます。Python で全ての設定が出来るため、Python の能力を最大限に発揮することが可能です。
目次
インストール
以下のパッケージのどれかをインストールしてください:
- qtile: 最新の公式リリース。Python 3 で動作。
- qtile-python2AUR: 最新の公式リリース。Python 2 で動作。
- qtile-gitAUR: 最新の git コミット。Python 2 で動作。
開始
Xorg
Qtile を開始するには exec qtile を ~/.xinitrc に追加し、Xorg を起動します。デフォルト設定では Super+Enter を押すと xterm ターミナルが起動します。Qtile を終了するには Super+Ctrl+q です。
Wayland
Qtile は qtile start -b wayland として Wayland コンポジタとして起動することもできます。
Qtile の Wayland 開発の進捗状況については、https://github.com/qtile/qtile/discussions/2409 を参照してください。
設定
Configuration Lookup で説明されているように、Qtile ではユーザーが定義した設定ファイルがないときに使われるデフォルトの設定ファイルがあります。Qtile のカスタマイズを始めるときは、デフォルトの設定ファイルを ~/.config/qtile/config.py にコピーしてください:
$ mkdir -p ~/.config/qtile/ $ cp /usr/share/doc/qtile_dir/default_config.py ~/.config/qtile/config.py
qtile_dir はインストールした AUR パッケージの名前に置き換えてください。
もしくは、最新のデフォルト設定ファイルを git リポジトリの libqtile/resources/default_config.py からダウンロードすることもできます。
設定はすべて Python により、~/.config/qtile/config.py で行われます。極めて簡単な Python の解説は このチュートリアル を参照してください。Python の変数、関数、モジュール及び Qtile の設定をすぐに始めるために必要なことが解説されています。
Qtile を再起動するまえに設定ファイルにエラーが無いか次のコマンドで確認することができます:
$ python2 -m py_compile ~/.config/qtile/config.py
このコマンドが出力を行わない場合、設定ファイルは正しく記述されています。
グループ
Qtile では、ワークスペース (あるいはビュー) はグループと呼称します。以下のように設定します:
from libqtile.config import Group, Match
...
groups = [
Group("term"),
Group("irc"),
Group("web", match=Match(title=["Firefox"])),
]
...
グループルール
次の例は、title や wm_class などのプロパティに基づいてアプリケーションをワークスペースに自動的に移動する方法を示しています。これらを取得するために X 上で実行している場合は、xprop を使用するとよいでしょう。
from libqtile.config import Group, Match
...
def is_text_editor(window):
result = "neovim" in (window.name or "").lower()
return result
def is_terminal(window):
result = "kitty" in (window.name or "").lower() and not is_text_editor(window)
return result
...
groups = [
Group(name=str(idx), **group)
for idx, group in enumerate(
[
{
"label": "term",
# restrict layouts since tiling is handled by kitty
"layouts": [layout.Max()],
"matches": [
Match(func=is_terminal),
],
},
{
"label": "browser",
"matches": [
Match(role="browser"),
],
},
{
"label": "music",
"matches": [
Match(title="YouTube Music"),
],
},
{"label": "text editor", "matches": [Match(func=is_text_editor)]},
{"label": "other"},
],
start=1,
)
]
...
キー
ショートカットキーを Key クラスで記述できます。
これは Alt+Shift+q でウィンドウマネージャを終了するための設定例です。
from libqtile.config import Key
from libqtile.command import lazy
...
keys = [
Key(
["mod1", "shift"], "q",
lazy.shutdown())
]
...
Xmodmap コマンドを使うことで modX がどのキーと対応しているか調べることができます。
サウンド
ユーザーを追加 を audio グループに追加し、alsamixer コマンドラインを使用することで、音量と状態を簡単に制御するショートカットを追加できます。このインターフェースは、alsa-utils パッケージを通じてインストールできます。
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"))
]
言語
ショートカットを追加すると、setxkbmap を使用して、さまざまな言語のキーボードレイアウトを簡単に切り替えることができます。たとえば、次のようになります。
keys= [
...
# Language
Key([mod], "F1",
lazy.spawn("setxkbmap us"),
desc= "Change to US layout"),
Key([mod],"F2",
lazy.spawn("setxkbmap gr"),
desc= "Change to Greek layout"),
]
スクリーン
接続されているモニタそれぞれに対して Screen クラスを作成してください。Qtile のバーは Screen クラスで以下の例のように設定することができます:
from libqtile.config import Screen
from libqtile import bar, widget
...
screens = [
Screen(
bottom=bar.Bar([ # add a bar to the bottom of the screen
widget.GroupBox(), # display the current Group
widget.WindowName() # display the name of the window that currently has focus
], 30))
]
...
バーとウィジェット
すべての組み込みウィジェットのリストは、公式ドキュメント (または 代替ドキュメント)
バーにウィジェットを追加したい場合は、上記の例のようにただ追加するだけです (WindowName ウィジェットの場合) たとえば、
バッテリー通知を追加するには、Battery ウィジェットを使用できます。
from libqtile.config import Screen
from libqtile import bar, widget
...
screens = [
Screen(top=bar.Bar([
widget.GroupBox(), # display the current Group
widget.Battery() # display the battery state
], 30))
]
...
Polybar をメインバーとして使用する
デフォルトのバーの代わりに Polybar を使用するには、screen クラスのコンテンツを削除する必要があります。
from libqtile.config import Screen
from libqtile import bar, widget
...
screens = [
Screen()
]
...
Qtile を使用して Polybar を再起動するには、spawn コマンドを使用して Polybar の起動スクリプトを追加し、キー クラスの Key を再起動します。次に例を示します。
...
keys = [
Key([mod, "control"], "r", lazy.reload_config(), lazy.spawn("~/.config/polybar/launch.sh"),
]
...
スタートアップ
アプリケーションをフックで起動することが出来ます。具体的には startup フックを使います。利用可能なフックのリストは こちら を御覧ください。
以下はアプリケーションを一度だけ実行する例です:
import os
import subprocess
from libqtile import hook
@hook.subscribe.startup_once
def autostart():
home = os.path.expanduser('~')
subprocess.Popen([home + '/.config/qtile/autostart.sh'])
デバッグ
問題箇所を発見したい場合、以下をターミナルで実行してください:
echo "exec qtile" > /tmp/.start_qtile ; xinit /tmp/.start_qtile -- :2