「Qtile」の版間の差分
Kusanaginoturugi (トーク | 投稿記録) (→Qtile の開始: タイトルを変更) |
(→設定: グループルールを翻訳して追加) |
||
| 57行目: | 57行目: | ||
] |
] |
||
...</nowiki> |
...</nowiki> |
||
| + | }} |
||
| + | |||
| + | === グループルール === |
||
| + | |||
| + | 次の例は、title や wm_class などのプロパティに基づいてアプリケーションをワークスペースに自動的に移動する方法を示しています。これらを取得するために X 上で実行している場合は、''xprop'' を使用するとよいでしょう。 |
||
| + | |||
| + | {{bc|1= |
||
| + | 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, |
||
| + | ) |
||
| + | ] |
||
| + | ... |
||
}} |
}} |
||
2023年8月23日 (水) 12:27時点における版
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 がどのキーと対応しているか調べることができます。
スクリーンとバー
接続されているモニタそれぞれに対して 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))
]
...
スタートアップ
アプリケーションをフックで起動することが出来ます。具体的には startup フックを使います。利用可能なフックのリストは こちら を御覧ください。
以下はアプリケーションを一度だけ実行する例です:
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())
# start the applications at Qtile startup
@hook.subscribe.startup
def startup():
execute_once("parcellite")
execute_once("nm-applet")
execute_once("dropboxd")
execute_once("feh --bg-scale ~/Pictures/wallpapers.jpg")
サウンド
audio グループにユーザーを追加して alsamixer のコマンドラインインタフェースを使うことで、音量と状態を簡単に操作するためのショートカットが使えます:
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"))
]
デバッグ
問題箇所を発見したい場合、以下をターミナルで実行してください:
echo "exec qtile" > /tmp/.start_qtile ; xinit /tmp/.start_qtile -- :2