「Qtile」の版間の差分
Kusakata.bot (トーク | 投稿記録) Pkg/AUR テンプレートの更新 |
Kusanaginoturugi (トーク | 投稿記録) 校正(でき・出来) |
||
| (4人の利用者による、間の17版が非表示) | |||
| 7行目: | 7行目: | ||
{{Related|ウィンドウマネージャ}} |
{{Related|ウィンドウマネージャ}} |
||
{{Related articles end}} |
{{Related articles end}} |
||
[http://qtile.org |
[http://qtile.org プロジェクトのウェブサイトより]: |
||
:''Qtile はあらゆる機能を備え、ハックしやすい、Python で書かれたタイル型ウィンドウマネージャです。Qtile はシンプルで、小さく、そして拡張性があります。ユーザー定義レイアウト、ウィジェット、そしてビルトインコマンドを簡単に書くことができます。Python で全ての設定が出来るため、Python の能力を最大限に発揮することが可能です。'' |
|||
Qtile はあらゆる機能を備え、ハックしやすい、Python で書かれたタイル型ウィンドウマネージャです。Qtile はシンプルで、小さく、そして拡張性があります。ユーザー定義レイアウト、ウィジェット、そしてビルトインコマンドを簡単に書くことができます。これは完全に Python で記述および設定されているため、言語の能力と柔軟性を最大限に活用してそれぞれのニーズに合わせることができます。 |
|||
== インストール == |
== インストール == |
||
以下のパッケージのどれかを[[インストール]]してください: |
|||
以下のパッケージのどれかを [[インストール]] してください: |
|||
* {{Pkg|qtile}}: 最新の公式リリース。Python 3 で動作。 |
|||
* {{AUR|qtile-python2}}: 最新の公式リリース。Python 2 で動作。 |
|||
* {{AUR|qtile-python3-git}}: 最新の git コミット。Python 3 で動作。 |
|||
* {{AUR|qtile-git}}: 最新の git コミット。Python 2 で動作。 |
|||
* {{Pkg|qtile}} 最新の公式リリース |
|||
== Qtile の開始 == |
|||
* {{AUR|qtile-git}} 開発版 |
|||
Qtile を開始するには {{ic|exec qtile}} を {{ic|~/.xinitrc}} に追加し、[[Xorg]] を起動します。デフォルト設定では {{ic|Super+Enter}} を押すと {{ic|xterm}} ターミナルが起動します。Qtile を終了するには {{ic|Super+Ctrl+q}} です。 |
|||
Qtile を [[Wayland]] コンポジターとして実行するには、{{Pkg|python-pywlroots}} をインストールする必要があります。 |
|||
== 開始 == |
|||
=== Xorg === |
|||
Qtile を [[X11]] ウィンドウマネージャーとして実行するには、[[xinit]] を指定して {{ic|qtile start}} を実行します。 |
|||
=== Wayland === |
|||
Qtile は {{ic|qtile start -b wayland}} として [[Wayland]] コンポジタとして起動することもできます。 |
|||
Qtile の Wayland 開発の進捗状況については、https://github.com/qtile/qtile/discussions/2409 を参照してください。 |
|||
== 設定 == |
== 設定 == |
||
{{Note|この章では Qtile の基本的な設定のみ紹介しています。より完全な情報については [http://docs.qtile.org/en/latest/ 公式ドキュメント] を御覧ください。}} |
{{Note|この章では Qtile の基本的な設定のみ紹介しています。より完全な情報については [http://docs.qtile.org/en/latest/ 公式ドキュメント] を御覧ください。}} |
||
[ |
[https://docs.qtile.org/en/latest/manual/config/#configuration-lookup Configuration Lookup] (または [https://qtile.readthedocs.io/en/stable/manual/config/index.html#configuration-lookup-order 代替ドキュメント]) で説明されているとおり、Qtile は、ユーザー定義の設定ファイルがない場合にデフォルトの設定ファイルを提供します。 |
||
デフォルト設定には、新しいターミナル ([https://github.com/qtile/qtile/blob/e762cfeda7b65e80fd7c9a5896ac8832475035ab/libqtile/utils.py#L291 hardcoded list)] を開くためのショートカット {{ic|Super+Enter}} が含まれています、{{ic|Super+Ctrl+q}} を押して Qtile を終了します。 |
|||
Qtile のカスタマイズを始めるときは、デフォルトの設定ファイルを {{ic|~/.config/qtile/config.py}} にコピーしてください: |
|||
$ mkdir -p ~/.config/qtile/ |
$ mkdir -p ~/.config/qtile/ |
||
| 36行目: | 52行目: | ||
Qtile を再起動するまえに設定ファイルにエラーが無いか次のコマンドで確認することができます: |
Qtile を再起動するまえに設定ファイルにエラーが無いか次のコマンドで確認することができます: |
||
$ |
$ python -m py_compile ~/.config/qtile/config.py |
||
このコマンドが出力を行わない場合、設定ファイルは正しく記述されています。 |
このコマンドが出力を行わない場合、設定ファイルは正しく記述されています。 |
||
=== グループ === |
=== グループ === |
||
Qtile では、ワークスペース (あるいはビュー) は'''グループ'''と呼称します。以下のように設定します: |
Qtile では、ワークスペース (あるいはビュー) は'''グループ'''と呼称します。以下のように設定します: |
||
{{bc|<nowiki> |
|||
{{bc|1= |
|||
from libqtile.config import Group, Match |
from libqtile.config import Group, Match |
||
... |
... |
||
| 47行目: | 65行目: | ||
Group("term"), |
Group("term"), |
||
Group("irc"), |
Group("irc"), |
||
Group("web", |
Group("web", matches=[Match(title=["Firefox"])]), |
||
] |
] |
||
... |
... |
||
}} |
|||
=== グループルール === |
|||
次の例は、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, |
|||
) |
|||
] |
|||
... |
|||
}} |
}} |
||
=== キー === |
=== キー === |
||
ショートカットキーを '''Key''' クラスで記述できます。 |
ショートカットキーを '''Key''' クラスで記述できます。 |
||
これは {{ic|Alt+Shift+q}} でウィンドウマネージャを終了するための設定例です。 |
これは {{ic|Alt+Shift+q}} でウィンドウマネージャを終了するための設定例です。 |
||
| 68行目: | 135行目: | ||
[[Xmodmap]] コマンドを使うことで {{ic|modX}} がどのキーと対応しているか調べることができます。 |
[[Xmodmap]] コマンドを使うことで {{ic|modX}} がどのキーと対応しているか調べることができます。 |
||
=== |
==== サウンド ==== |
||
[[ユーザーとグループ#グループ管理|ユーザーを追加]] を ''audio'' グループに追加し、{{ic|alsamixer}} コマンドラインを使用することで、音量と状態を簡単に制御するショートカットを追加できます。このインターフェースは、{{Pkg|alsa-utils}} パッケージを通じてインストールできます。 |
|||
{{bc|1= |
|||
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]] を使用して、さまざまな言語のキーボードレイアウトを簡単に切り替えることができます。たとえば、次のようになります。 |
|||
{{bc|1= |
|||
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''' クラスで以下の例のように設定することができます: |
接続されているモニタそれぞれに対して '''Screen''' クラスを作成してください。Qtile のバーは '''Screen''' クラスで以下の例のように設定することができます: |
||
{{bc|<nowiki> |
{{bc|<nowiki> |
||
| 84行目: | 183行目: | ||
}} |
}} |
||
=== ウィジェット === |
==== バーとウィジェット ==== |
||
[http://docs.qtile.org/en/latest/manual/ref/widgets.html 公式ドキュメント] ですべてのビルトインウィジェットを確認することができます。 |
|||
すべての組み込みウィジェットのリストは、[https://docs.qtile.org/en/latest/manual/ref/widgets.html 公式ドキュメント] (または [https://qtile.readthedocs.io/en/stable/manual/ref/widgets.html 代替ドキュメント]) |
|||
もしバーにウィジェットを追加したい場合、単にそのウィジェットを以下のように {{ic|WindowName}} に記述することで出来ます。例えば、バッテリー通知を行いたい場合、{{ic|Battery}} ウィジェットを使うことができます: |
|||
{{bc|<nowiki> |
|||
バーにウィジェットを追加したい場合は、上記の例のようにただ追加するだけです ({{ic|WindowName}} ウィジェットの場合) たとえば、 |
|||
バッテリー通知を追加するには、{{ic|Battery}} ウィジェットを使用できます。 |
|||
{{bc|1= |
|||
from libqtile.config import Screen |
from libqtile.config import Screen |
||
from libqtile import bar, widget |
from libqtile import bar, widget |
||
| 98行目: | 200行目: | ||
], 30)) |
], 30)) |
||
] |
] |
||
... |
... |
||
}} |
}} |
||
==== Polybar をメインバーとして使用する ==== |
|||
=== スタートアップ === |
|||
アプリケーションを'''フック'''で起動することが出来ます。具体的には {{ic|startup}} フックを使います。利用可能なフックのリストは [http://docs.qtile.org/en/latest/manual/ref/hooks.html こちら] を御覧ください。 |
|||
デフォルトのバーの代わりに [https://github.com/polybar/polybar Polybar] を使用するには、''screen'' クラスのコンテンツを削除する必要があります。 |
|||
以下はアプリケーションを一度だけ実行する例です: |
|||
{{bc|<nowiki> |
|||
import subprocess, re |
|||
{{bc|1= |
|||
def is_running(process): |
|||
from libqtile.config import Screen |
|||
s = subprocess.Popen(["ps", "axw"], stdout=subprocess.PIPE) |
|||
from libqtile import bar, widget |
|||
for x in s.stdout: |
|||
... |
|||
if re.search(process, x): |
|||
screens = [ |
|||
return True |
|||
Screen() |
|||
] |
|||
... |
|||
}} |
|||
Qtile を使用して Polybar を再起動するには、{{ic|spawn}} コマンドを使用して Polybar の起動スクリプトを追加し、[[Qtile#キー|キー]] クラスの ''Key'' を再起動します。次に例を示します。 |
|||
def execute_once(process): |
|||
if not is_running(process): |
|||
return subprocess.Popen(process.split()) |
|||
{{bc|1= |
|||
# start the applications at Qtile startup |
|||
... |
|||
@hook.subscribe.startup |
|||
keys = [ |
|||
def startup(): |
|||
Key([mod, "control"], "r", lazy.reload_config(), lazy.spawn("~/.config/polybar/launch.sh"), |
|||
execute_once("parcellite") |
|||
] |
|||
execute_once("nm-applet") |
|||
... |
|||
execute_once("dropboxd") |
|||
execute_once("feh --bg-scale ~/Pictures/wallpapers.jpg")</nowiki> |
|||
}} |
}} |
||
=== |
=== スタートアップ === |
||
'''audio''' グループに[[ユーザーとグループ#グループ管理|ユーザーを追加]]して {{ic|alsamixer}} のコマンドラインインタフェースを使うことで、音量と状態を簡単に操作するためのショートカットが使えます: |
|||
アプリケーションを'''フック'''で起動することができます。具体的には {{ic|startup}} フックを使います。利用可能なフックのリストは [http://docs.qtile.org/en/latest/manual/ref/hooks.html こちら] を参照ください。(またはこちらの [https://qtile.readthedocs.io/en/stable/manual/ref/hooks.html 代替ドキュメント]) |
|||
{{bc|<nowiki> |
|||
keys= [ |
|||
以下はアプリケーションを一度だけ実行する例です: |
|||
... |
|||
# Sound |
|||
{{bc|1= |
|||
Key([], "XF86AudioMute", lazy.spawn("amixer -q set Master toggle")), |
|||
import os |
|||
Key([], "XF86AudioLowerVolume", lazy.spawn("amixer -c 0 sset Master 1- unmute")), |
|||
import subprocess |
|||
Key([], "XF86AudioRaiseVolume", lazy.spawn("amixer -c 0 sset Master 1+ unmute")) |
|||
from libqtile import hook |
|||
]</nowiki> |
|||
@hook.subscribe.startup_once |
|||
def autostart(): |
|||
home = os.path.expanduser('~') |
|||
subprocess.Popen([home + '/.config/qtile/autostart.sh']) |
|||
}} |
}} |
||
== デバッグ == |
== デバッグ == |
||
問題箇所を発見したい場合、以下をターミナルで実行してください: |
|||
Qtile はログを {{ic|~/.local/share/qtile/qtile.log}} に書き込みます。 |
|||
echo "exec qtile" > /tmp/.start_qtile ; xinit /tmp/.start_qtile -- :2 |
|||
=== xinit === |
|||
別の ターミナル で Qtile を開始すると、問題の診断に役立ちます。 |
|||
$ echo "exec qtile start" > /tmp/.start_qtile; xinit /tmp/.start_qtile -- :2 |
|||
=== Xephyr === |
|||
Qtile は [https://github.com/qtile/qtile/blob/master/scripts/xephyr Xephyr 開発スクリプト] を提供しており、以下を置き換えることでシステムにインストールされたパッケージをインスタンス化するように簡単に変更できます。 |
|||
env DISPLAY=${XDISPLAY} QTILE_XEPHYR=1 ${PYTHON} "${HERE}"/../bin/qtile start -l ${LOG_LEVEL} $@ & |
|||
と |
|||
env DISPLAY=${XDISPLAY} QTILE_XEPHYR=1 qtile start -l ${LOG_LEVEL} $@ & |
|||
== 参照 == |
== 参照 == |
||
* [http://qtile.org/ Qtile ウェブサイト] |
* [http://qtile.org/ Qtile ウェブサイト] |
||
* [http://docs.qtile.org/en/latest/ 公式ドキュメント] |
* [http://docs.qtile.org/en/latest/ 公式ドキュメント] |
||
* [https://qtile.readthedocs.io/en/stable/ 公式ドキュメントの代替ソース] これは、[https://github.com/qtile/qtile/issues/4295 issue 4295] に見られるように、"docs.qtile.org" がダウンしているときに便利です。 |
|||
* [https://github.com/qtile/qtile-examples/ Qtile サンプル] |
|||
2024年7月10日 (水) 20:41時点における最新版
Qtile はあらゆる機能を備え、ハックしやすい、Python で書かれたタイル型ウィンドウマネージャです。Qtile はシンプルで、小さく、そして拡張性があります。ユーザー定義レイアウト、ウィジェット、そしてビルトインコマンドを簡単に書くことができます。これは完全に Python で記述および設定されているため、言語の能力と柔軟性を最大限に活用してそれぞれのニーズに合わせることができます。
インストール
以下のパッケージのどれかを インストール してください:
Qtile を Wayland コンポジターとして実行するには、python-pywlroots をインストールする必要があります。
開始
Xorg
Qtile を X11 ウィンドウマネージャーとして実行するには、xinit を指定して qtile start を実行します。
Wayland
Qtile は qtile start -b wayland として Wayland コンポジタとして起動することもできます。
Qtile の Wayland 開発の進捗状況については、https://github.com/qtile/qtile/discussions/2409 を参照してください。
設定
Configuration Lookup (または 代替ドキュメント) で説明されているとおり、Qtile は、ユーザー定義の設定ファイルがない場合にデフォルトの設定ファイルを提供します。
デフォルト設定には、新しいターミナル (hardcoded list) を開くためのショートカット Super+Enter が含まれています、Super+Ctrl+q を押して 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 を再起動するまえに設定ファイルにエラーが無いか次のコマンドで確認することができます:
$ python -m py_compile ~/.config/qtile/config.py
このコマンドが出力を行わない場合、設定ファイルは正しく記述されています。
グループ
Qtile では、ワークスペース (あるいはビュー) はグループと呼称します。以下のように設定します:
from libqtile.config import Group, Match
...
groups = [
Group("term"),
Group("irc"),
Group("web", matches=[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'])
デバッグ
Qtile はログを ~/.local/share/qtile/qtile.log に書き込みます。
xinit
別の ターミナル で Qtile を開始すると、問題の診断に役立ちます。
$ echo "exec qtile start" > /tmp/.start_qtile; xinit /tmp/.start_qtile -- :2
Xephyr
Qtile は Xephyr 開発スクリプト を提供しており、以下を置き換えることでシステムにインストールされたパッケージをインスタンス化するように簡単に変更できます。
env DISPLAY=${XDISPLAY} QTILE_XEPHYR=1 ${PYTHON} "${HERE}"/../bin/qtile start -l ${LOG_LEVEL} $@ &
と
env DISPLAY=${XDISPLAY} QTILE_XEPHYR=1 qtile start -l ${LOG_LEVEL} $@ &
参照
- Qtile ウェブサイト
- 公式ドキュメント
- 公式ドキュメントの代替ソース これは、issue 4295 に見られるように、"docs.qtile.org" がダウンしているときに便利です。
- Qtile サンプル