「Kanshi」の版間の差分
編集の要約なし |
翻訳 |
||
| 6行目: | 6行目: | ||
{{Related articles end}} |
{{Related articles end}} |
||
[https://gitlab.freedesktop.org/emersion/kanshi kanshi] を使用すると、ホットプラグに応じて自動的に有効・無効が切り替わる出力プロファイルを定義できます。例えば、ノートパソコンをドックに接続した際に内蔵スクリーンをオフにする、といった設定が可能です。 |
|||
[https://gitlab.freedesktop.org/emersion/kanshi kanshi] allows you to define output profiles that are automatically enabled and disabled on hotplug. For instance, this can be used to turn a laptop's internal screen off when docked. |
|||
これは、[https://github.com/phillipberndt/autorandr autorandr] などのツールのWayland版に相当します。kanshiは、wlr-output-management プロトコルをサポートしている Wayland コンポジタで使用できます。 |
|||
== |
== インストール == |
||
{{Pkg|kanshi}} パッケージ、または {{AUR|kanshi-git}} を[[インストール]]してください。 |
|||
== |
== 設定 == |
||
=== |
=== 基本設定 === |
||
kanshiの設定ファイルを作成します: |
|||
Create kanshi configuration file: |
|||
{{hc|1=~/.config/kanshi/config|2= |
{{hc|1=~/.config/kanshi/config|2= |
||
profile { |
profile { |
||
output LVDS-1 disable |
|||
output "Some Company ASDF 4242" mode 1600x900 position 0,0 |
|||
} |
} |
||
profile { |
profile { |
||
output LVDS-1 enable scale 2 |
|||
} |
} |
||
}} |
}} |
||
各出力プロファイルはブラケット(波括弧)で区切られます。その中には複数の出力ディレクティブが含まれます(構文は {{man|5|sway-output}} と同様です) リストされているすべての出力が接続されている場合に、そのプロファイルが有効になります。 |
|||
Each output profile is delimited by brackets. It contains several output directives (whose syntax is similar to {{man|5|sway-output}}). A profile will be enabled if all of the listed outputs are connected. |
|||
{{Tip| |
{{Tip|出力名や詳細情報のリストを取得するには、{{ic|wlr-randr}} や {{ic|swaymsg -t get_outputs}} などのコマンドを使用するか、GUIアプリケーションである {{AUR|wdisplays-git}} または {{AUR|wdisplays-persistent}} を使用してください。これらは、kanshiの設定ファイルに直接書き込むことも可能です。}} |
||
=== |
=== 応用設定 === |
||
複数のセットアップ (例:ノート PC 本体のみ、自宅でモニター1台に接続、職場でモニター2台に接続、など) を簡単に管理するために、プロファイル内で使用する出力のデフォルト値を定義し、エイリアスを割り当てることができます。デフォルト値は、その出力が言及されているすべてのプロファイルに適用されます。詳細は {{man|5|kanshi}} を参照してください。 |
|||
For easier management of multiple setups ''(e.g. Internal laptop monitor only, Docked to one monitor at home, Docked to two work monitors, ...)'' you can define defaults for the outputs used inside profiles and assign them aliases. The defaults will apply to all profiles where the respective output is mentioned. For more see {{man|5|kanshi}}). |
|||
{{hc|1=~/.config/kanshi/config|2= |
{{hc|1=~/.config/kanshi/config|2= |
||
output "Dell Inc. DELL S2721DGF G52TR83" { |
output "Dell Inc. DELL S2721DGF G52TR83" { |
||
mode 2560x1440@165.08 |
|||
position 1280,0 |
|||
scale 2 |
|||
alias $HOME_1 |
|||
} |
} |
||
output "LG Display 0x058B Unknown" { |
output "LG Display 0x058B Unknown" { |
||
mode 2560x1440@59.99800 |
|||
position 0,0 |
|||
scale 2 |
|||
alias $INTERNAL |
|||
} |
} |
||
profile home_1 { |
profile home_1 { |
||
output $INTERNAL disable |
|||
output $HOME_1 enable |
|||
} |
} |
||
}} |
}} |
||
これらの値は、[https://wiki.hyprland.org/Configuring/Using-hyprctl/ hyprctl monitors] のようなコマンドで確認できます。実行すると、以下のように出力されます。 |
|||
You can find out these values with a command like [https://wiki.hyprland.org/Configuring/Using-hyprctl/ hyprctl monitors] which will display all three of those in its output. |
|||
{{hc|1=hyprctl monitors|2= |
{{hc|1=hyprctl monitors|2= |
||
| 69行目: | 68行目: | ||
}} |
}} |
||
また、exec ディレクティブを使用することで、プロファイルが正常に適用された後にコマンドを実行し、ワークフローとさらに統合させることも可能です。 |
|||
It is also possible to further integrate kanshi with your workflow by using the ''exec'' directive to execute a command once the profile was successfully applied. |
|||
{{hc|1=~/.config/kanshi/config|2= |
{{hc|1=~/.config/kanshi/config|2= |
||
profile home_1 { |
profile home_1 { |
||
output $INTERNAL disable |
|||
output $HOME_1 enable |
|||
exec uwsm app -- $HOME/.config/hypr/scripts/move-workspaces.sh "LG Display 0x058B" |
|||
} |
} |
||
}} |
}} |
||
== |
== 使用方法 == |
||
次のコマンドを実行します: |
|||
Run the command: |
|||
$ kanshi |
$ kanshi |
||
自動的に実行する方法については、[[#systemd で kanshi を管理する]] を参照してください。 |
|||
See [[#Manage kanshi with systemd]] for an automated usage. |
|||
== ヒントとテクニック == |
|||
== Tips and tricks == |
|||
=== |
=== systemd で kanshi を管理する === |
||
[[Sway#systemd で sway 固有のデーモンを管理する]] の手順に従って、{{ic|~/.config/systemd/user/sway-session.target}} を作成し、起動してください (未作成の場合) |
|||
次に、{{ic|kanshi.service}} ファイルを作成します: |
|||
{{hc|1=~/.config/systemd/user/kanshi.service|2= |
{{hc|1=~/.config/systemd/user/kanshi.service|2= |
||
| 109行目: | 108行目: | ||
}} |
}} |
||
この[[ユーザーユニット]]を[[有効化]]してください。これにより、Sway の実行中にのみ有効になり、Sway が停止すると無効になります。 |
|||
[[Enable]] this [[user unit]]. It is only activated when Sway is running and deactivated when Sway stops. |
|||
== トラブルシューティング == |
|||
== Troubleshooting == |
|||
=== スリープ復帰後、外部モニターのワークスペース番号が2から始まる === |
|||
=== Workspace number starts from 2 in external monitor after wake up === |
|||
[[#設定|上記]]のような設定をしている場合、2番目のディスプレイを接続した際、最初のディスプレイが無効化されているため、2番目のディスプレイのワークスペースは「1」から始まるはずです。初回接続時やシステム起動直後はその通りになりますが、スリープ復帰後にこの番号が「2」になってしまうことがあります。この場合は、kanshi の設定ファイルにディレクティブを追加して、最初のワークスペースをそのモニターに移動させるようにしてください: |
|||
If you have a configuration like [[#Configuration|above]], when you connected a second display to your computer, the workspace in the second display should start from 1 since the first display is disabled. This should be the case when you plugged your monitor in the first time or after starting the system. But after sleep, this number might be 2. In this case just move the first workspace to this monitor by adding a directive to the kanshi configuration file: |
|||
{{hc|1=~/.config/kanshi/config|2= |
{{hc|1=~/.config/kanshi/config|2= |
||
profile { |
profile { |
||
output LVDS-1 disable |
|||
output "Some Company ASDF 4242" mode 1600x900 position 0,0 |
|||
# 以下のディレクティブを追加します(出力名は適宜書き換えてください): |
|||
# We've added this directive here (do not forget to update the output name): |
|||
exec swaymsg workspace 1, move workspace to HDMI-A-1 |
|||
} |
} |
||
profile { |
profile { |
||
output LVDS-1 enable scale 2 |
|||
} |
} |
||
}} |
}} |
||
== |
== 参照 == |
||
* [https://gitlab.freedesktop.org/emersion/kanshi |
* [https://gitlab.freedesktop.org/emersion/kanshi ソースコードとドキュメント] |
||
2026年2月20日 (金) 14:51時点における最新版
関連記事
kanshi を使用すると、ホットプラグに応じて自動的に有効・無効が切り替わる出力プロファイルを定義できます。例えば、ノートパソコンをドックに接続した際に内蔵スクリーンをオフにする、といった設定が可能です。
これは、autorandr などのツールのWayland版に相当します。kanshiは、wlr-output-management プロトコルをサポートしている Wayland コンポジタで使用できます。
インストール
kanshi パッケージ、または kanshi-gitAUR をインストールしてください。
設定
基本設定
kanshiの設定ファイルを作成します:
~/.config/kanshi/config
profile {
output LVDS-1 disable
output "Some Company ASDF 4242" mode 1600x900 position 0,0
}
profile {
output LVDS-1 enable scale 2
}
各出力プロファイルはブラケット(波括弧)で区切られます。その中には複数の出力ディレクティブが含まれます(構文は sway-output(5) と同様です) リストされているすべての出力が接続されている場合に、そのプロファイルが有効になります。
wlr-randr や swaymsg -t get_outputs などのコマンドを使用するか、GUIアプリケーションである wdisplays-gitAUR または wdisplays-persistentAUR を使用してください。これらは、kanshiの設定ファイルに直接書き込むことも可能です。応用設定
複数のセットアップ (例:ノート PC 本体のみ、自宅でモニター1台に接続、職場でモニター2台に接続、など) を簡単に管理するために、プロファイル内で使用する出力のデフォルト値を定義し、エイリアスを割り当てることができます。デフォルト値は、その出力が言及されているすべてのプロファイルに適用されます。詳細は kanshi(5) を参照してください。
~/.config/kanshi/config
output "Dell Inc. DELL S2721DGF G52TR83" {
mode 2560x1440@165.08
position 1280,0
scale 2
alias $HOME_1
}
output "LG Display 0x058B Unknown" {
mode 2560x1440@59.99800
position 0,0
scale 2
alias $INTERNAL
}
profile home_1 {
output $INTERNAL disable
output $HOME_1 enable
}
これらの値は、hyprctl monitors のようなコマンドで確認できます。実行すると、以下のように出力されます。
hyprctl monitors
make: LG Display model: 0x058B serial:
また、exec ディレクティブを使用することで、プロファイルが正常に適用された後にコマンドを実行し、ワークフローとさらに統合させることも可能です。
~/.config/kanshi/config
profile home_1 {
output $INTERNAL disable
output $HOME_1 enable
exec uwsm app -- $HOME/.config/hypr/scripts/move-workspaces.sh "LG Display 0x058B"
}
使用方法
次のコマンドを実行します:
$ kanshi
自動的に実行する方法については、#systemd で kanshi を管理する を参照してください。
ヒントとテクニック
systemd で kanshi を管理する
Sway#systemd で sway 固有のデーモンを管理する の手順に従って、~/.config/systemd/user/sway-session.target を作成し、起動してください (未作成の場合)
次に、kanshi.service ファイルを作成します:
~/.config/systemd/user/kanshi.service
[Unit] Description=Dynamic output configuration for Wayland compositors Documentation=man:kanshi(1) BindsTo=sway-session.target [Service] Type=simple ExecStart=/usr/bin/kanshi [Install] WantedBy=sway-session.target
このユーザーユニットを有効化してください。これにより、Sway の実行中にのみ有効になり、Sway が停止すると無効になります。
トラブルシューティング
スリープ復帰後、外部モニターのワークスペース番号が2から始まる
上記のような設定をしている場合、2番目のディスプレイを接続した際、最初のディスプレイが無効化されているため、2番目のディスプレイのワークスペースは「1」から始まるはずです。初回接続時やシステム起動直後はその通りになりますが、スリープ復帰後にこの番号が「2」になってしまうことがあります。この場合は、kanshi の設定ファイルにディレクティブを追加して、最初のワークスペースをそのモニターに移動させるようにしてください:
~/.config/kanshi/config
profile {
output LVDS-1 disable
output "Some Company ASDF 4242" mode 1600x900 position 0,0
# 以下のディレクティブを追加します(出力名は適宜書き換えてください):
exec swaymsg workspace 1, move workspace to HDMI-A-1
}
profile {
output LVDS-1 enable scale 2
}