「Hyprland」の版間の差分

提供: ArchWiki
ナビゲーションに移動 検索に移動
(Hyperland wikiのFAQページへのリンク切れを修正)
(→‎ヒントとテクニック: リンクを修正)
 
(4人の利用者による、間の33版が非表示)
6行目: 6行目:
 
{{Related articles end}}
 
{{Related articles end}}
   
'''Hyprland''' は C++ で書かれた wlroots ベースのタイリング [[Wayland]] コンポジタです。Hyprland の特筆すべき点は、ダイナミックタイリング、タブ付きウィンドウ、クリーンで読みやすい C++ コードベース、ウィンドウアニメーションや角丸、透明ウィンドウでの Dual-Kawase Blur を提供するカスタムレンダラーなどです。一般的な使い方や設定方法は、 [https://wiki.hyprland.org/ Hyprland GitHub wiki] に詳しく書かれています。
+
'''Hyprland''' は C++ で書かれた {{Pkg|wlroots}} ベースのタイリング [[Wayland#コンポジタ|Wayland コンポジタ]] です。Hyprland の特筆すべき点は、ダイナミックタイリング、タブ付きウィンドウ、クリーンで読みやすい C++ コードベース、ウィンドウアニメーションや角丸、透明ウィンドウでの Dual-Kawase Blur を提供するカスタムレンダラーなどです。一般的な使い方や設定方法は、 [https://wiki.hyprland.org/ Hyprland Wiki] に詳しく書かれています。
   
 
== インストール ==
 
== インストール ==
   
Hyprland は AUR ら[[インストール]]するか、ソースからビルドすることができます。source.
+
次のいずれインストールます:
   
  +
* {{Pkg|hyprland}} - 最新のアップストリームリリース。
Hyprland は独自のバージョンの wlroots をバンドルしており、{{AUR|wlroots-git}} に忠実に準拠しています。これは安定性を高め、他の wlroots ベースのコンポジターとの依存関係の衝突を避けることができます。
 
  +
* {{AUR|hyprland-git}} - master ブランチへの最新のコミット。
   
  +
Hyprland は、{{AUR|wlroots-git}} に厳密に従う独自のバージョンの wlroots をバンドルしています。これにより、安定性が向上すると同時に、他の wlroots ベースのコンポジターとの依存関係の競合も回避されます。
=== AUR から ===
 
   
  +
{{Note|
{{AUR|hyprland}}、{{AUR|hyprland-bin}} または {{AUR|hyprland-git}} パッケージをインストールします。
 
  +
* [[NVIDIA]] GPU ユーザーは、Hyprland を起動する前に、[https://wiki.hyprland.org/Nvidia upstream Wiki] のNVIDIA専用ページにも必ず従ってください。これを怠ると、ログインできない、ウィンドウが点滅する、CPU使用率が高いなど、多くのバグが発生する可能性があります。
  +
* Hyprland での NVIDIA GPU の使用はサポートされていません。問題が起きても全て自己責任でお願いします。
  +
}}
  +
  +
== 設定 ==
  +
  +
{{Note|リストされているオプションのほとんど (およびその他) は、[https://wiki.hyprland.org/Cconfiguring/Variables/upstream Wiki] の変数ページで詳しく説明されています。}}
  +
  +
設定は 1 つの設定ファイル、[https://github.com/vaxerski/Hyprland/blob/main/example/hyprland.conf hyprland.conf] を通して行われます。パッケージマネージャで Hyprland をインストールした場合、おそらく /usr/share/hyprland/hyprland.conf にあります。ソースからインストールした場合は、Hyprland をクローンしたレポジトリにあります。hyprland.conf を {{ic|~/.config/hypr/hyprland.conf}} にコピーしてください。
  +
  +
{{ic|hyprland.conf}} には、デバイス (モニタ、キーボード、マウス、トラックパッド) を設定するディレクティブと、アニメーション、装飾、レイアウトなどの設定が含まれています。キーバインディングやウィンドウのルールを設定したり、コマンドを実行したりできます (一度だけ、あるいはコンフィグが再読み込みされるたびに)
  +
  +
ファイルを更新するたびに設定が自動的にリロードされます。同じ効果を得るために {{ic|hyprctl reload}} を使うこともできます。いくつかの設定(特に入力設定)については、Hyprland セッションを再起動する必要があるかもしれません。
  +
  +
設定は {{ic|hyprctl}} を使用してその場で変更することもできますが、保存されません。
  +
  +
=== キーボード ===
   
=== スから ===
+
==== マップ ====
   
  +
デフォルトでは、Hyprland は {{ic|US Qwerty}} を使用します。次のように設定できます:
Hyprland は非常に活発なリポジトリです。現時点では、通常1日に数回のコミットがあります。
 
   
  +
{{hc|~/.config/hypr/hyprland.conf|2=
{{bc|1=
 
  +
# German Colemark layout
$ git clone --recursive https://github.com/vaxerski/Hyprland
 
  +
input {
$ cd Hyprland
 
  +
...
# make install
 
  +
kb_layout = de
  +
kb_variant = colemark
  +
...
  +
}
 
}}
 
}}
   
  +
利用可能なすべてのオプションについては、[https://wiki.hyprland.org/Cconfiguring/Variables/#input upstream's Wiki] を参照してください。
{{ic|recursive}} フラグは適切なバージョンの wlroots を取り出し、Hyprland のためにローカルにビルドします。
 
  +
  +
{{Note|Hyprland は [[ロケール]] 定義をオーバーライドするため、{{ic|US}} レイアウトキーボードを使用しない場合はキーマップを変更する必要があります。}}
  +
  +
==== 典型的な遅延と速度 ====
  +
  +
Xorg ユーザーはこの設定 [[Xorg/キーボード設定#オートリピートの遅延と速度の調整|サーバーレベルで定義]] を使用することに慣れていますが、Wayland では各コンポジターがそれを独自に処理します。
  +
  +
{{hc|~/.config/hypr/hyprland.conf|2=
  +
# Repeat rate and delay
  +
input {
  +
...
  +
repeat_rate = 25
  +
repeat_delay = 600
  +
...
  +
}
  +
}}
  +
  +
==== キーボードのバックライト ====
  +
  +
他の照明コントロールとは異なり、キーボードバックライトには {{ic|XF86}} キーシムがないため、従来のバインドを行う必要があります。
  +
  +
{{Pkg|brightnessctl}} を [[インストール]] します、次のバインドを追加します。
  +
  +
{{hc|~/.config/hypr/hyprland.conf|2=
  +
# Keyboard backlight
  +
bind = SUPER, F3, exec, brightnessctl -d *::kbd_backlight set +33%
  +
bind = SUPER, F2, exec, brightnessctl -d *::kbd_backlight set 33%-
  +
}}
  +
  +
変更が行われたときに [[Hyprland#画面上の通知|画面上の通知]] を実行することもできます。
  +
  +
{{Note|ラップトップにハードウェアキーボードバックライトコントロール (キーボードの {{ic|Fn}} キーを使用) がある場合、追加の手順なしで機能するはずです。}}
  +
  +
==== メディアキー ====
  +
  +
Hyprland でキーボードメディアコントロールを使用するには、{{ic|XF86Audio}} キーシムと、{{Pkg|pavucontrol}} または {{Pkg|pamixer}} や [[MPRIS#Playerctl|playerctl]] などの外部アプリケーションを利用することで可能です。
  +
  +
{{hc|~/.config/hypr/hyprland.conf|2=
  +
# Volume and Media Control
  +
bind = , XF86AudioRaiseVolume, exec, pamixer -i 5
  +
bind = , XF86AudioLowerVolume, exec, pamixer -d 5
  +
bind = , XF86AudioMicMute, exec, pamixer --default-source -m
  +
bind = , XF86AudioMute, exec, pamixer -t
  +
bind = , XF86AudioPlay, exec, playerctl play-pause
  +
bind = , XF86AudioPause, exec, playerctl play-pause
  +
bind = , XF86AudioNext, exec, playerctl next
  +
bind = , XF86AudioPrev, exec, playerctl previous
  +
}}
  +
  +
変更が行われたときに [[Hyprland#画面上の通知|通知]] を実行することもできます。
  +
  +
=== タッチパッドのジェスチャ ===
  +
  +
[[Wayland]] コンポジタである Hyprland はタッチパッドジェスチャを完全にサポートしていますが、デフォルトでは無効になっています。それらを有効にするには、次を編集します:
  +
  +
{{hc|~/.config/hypr/hyprland.conf|2=
  +
# Enable touchpad gestures
  +
gestures {
  +
workspace_swipe = true
  +
workspace_swipe_fingers = 3
  +
}
  +
}}
  +
  +
利用可能なすべてのオプションについては、[https://wiki.hyprland.org/Cconfiguring/Variables/#gestures upstream Wiki] を参照してください。
  +
  +
=== ディスプレイの設定 ===
  +
  +
==== 画面共有 ====
  +
  +
[https://wiki.hyprland.org/Useful-Utilities/Screen-Sharing/ Screen-sharing] を参照してください。
  +
  +
wlroots ベースのコンポジタとして、Hyprland は {{Pkg|xdg-desktop-portal-wlr}} を利用して、[[xdg-desktop-portal]] 経由でさまざまなアプリケーションで画面キャプチャを有効にすることができます。
  +
  +
Hyprland は、領域共有、ウィンドウ共有、グラフィカルピッカーユーティリティなどの機能を追加した wlr ポータルのフォークである {{Pkg|xdg-desktop-portal-hyprland}} も保守しています。ポータルの使用法については、[https://wiki.hyprland.org/Useful-Utilities/Hyprland-desktop-portal/ Hyprland wiki] で詳しく説明されています。
  +
  +
==== 画面解像度の設定 ====
  +
  +
Hyprland は画面解像度を自動的に検出しようとしますが、複数の画面が存在する場合やハイブリッドラップトップを使用している場合は、場合によっては失敗し、デフォルトでフェールセーフが設定されます。画面上のすべてが大きい場合は、デフォルトのモニターと解像度を設定する必要があります。
  +
  +
まず、''hyprctl'' を使用してデフォルトのモニターを見つけます:
  +
  +
{{hc|$ hyprctl monitors|2=
  +
Monitor '''eDP-1''' (ID 0):
  +
'''1920x1080@144'''.003006 at '''0x0'''
  +
description: Chimei Innolux Corporation 0x153C (eDP-1)
  +
...
  +
}}
  +
  +
次に、モニターを設定に追加します:
  +
  +
{{hc|~/.config/hypr/hyprland.conf|2=
  +
...
  +
# Monitor details
  +
monitor=eDP-1,1920x1080@144,0x0,1
  +
...}}
  +
  +
{{ic|0x0}} はマルチスクリーン設定に使用される位置オフセットで、最後の {{ic|1}} は画面のスケーリング係数です。
  +
  +
==== 画面のバックライト ====
  +
  +
{{Pkg|brightnessctl}} を [[インストール]] して、次のバインドを追加します。
  +
  +
{{hc|~/.config/hypr/hyprland.conf|2=
  +
# Screen brightness
  +
bind = , XF86MonBrightnessUp, exec, brightnessctl -s +5%
  +
bind = , XF86MonBrightnessDown, exec, brightnessctl -s 5%-
  +
}}
  +
  +
変更が行われたときに [[Hyprland#画面上の通知|通知]] を実行することもできます。
   
 
== 使用方法 ==
 
== 使用方法 ==
38行目: 169行目:
 
$ Hyprland
 
$ Hyprland
   
  +
[[ディスプレイマネージャ]] からの起動は公式にはサポートされていませんが、[[GDM]]、[[SDDM]]、その他からの起動に成功したとの報告があります。全ての Hyprland AUR パッケージは自動的にディスプレイマネージャーエントリーを生成します。ソースから手動でインストールする場合、ソースコードの example ディレクトリに {{ic|Hyprland.desktop}} ファイルのサンプルがあります、これを {{ic|/usr/share/wayland-sessions/}} にコピーしてディスプレイマネージャーのエントリーを提供することができます。
You can also execute a script of your own, e.g. setting [[環境変数]], that finishes with {{ic|exec Hyprland}}, '''for instance''' (adapt to your needs):
 
   
  +
どちらの方法でも、いくつかの環境変数やサービスを追加したり削除したりすることで、同じ結果を得ることができます
{{bc|1=
 
  +
  +
=== 自動ログイン ===
  +
  +
[[ディスプレイマネージャ]] または [[xinit#ログイン時に X を自動起動|シェルから]] ユーザーは自動的にログインできます。
  +
  +
=== hyprctl と IPC ===
  +
  +
''hyprctl'' は Hyprland にインストールされている、ディスプレイサーバーと通信するためのコマンドライン・ユーティリティです。サーバーにコマンドを送ったり (設定ファイルのコマンドと同じですが、構文が少し違います)、キーワードを設定したり、クエリ を送ったり、情報を要求したりすることができます。[https://github.com/vaxerski/Hyprland/wiki/Using-hyprctl full documentation] を参照してください。
  +
  +
Hyprland は [https://wiki.hyprland.org/IPC/ 2 つの UNIX ソケット] も公開しており、コードやコマンドライン・ユーティリティを使って Hyprland の情報を制御・取得することができます。これらのソケットはフォーカスの変更 (ウィンドウ、ワークスペース、モニター) やウィンドウ/ワークスペースの作成などのイベントをブロードキャストします。
  +
  +
''hyprctl'' と IPC ソケットは、複雑なタスクのために Hyprland を制御するスクリプトの中で効果的に使うことができます。
  +
  +
=== exec と exec-once の比較 ===
  +
  +
アプリケーションを起動するときは、正しいタイプのディスパッチャを使用することが重要です。{{ic|exec}} を誤って使用すると、アプリケーションが複数回起動されてシステムリソースが占有され、最悪の場合、競合状態が発生してシステムがクラッシュする可能性があります。
  +
  +
{{Note|[[Hyprland#設定|設定]] で説明したように、Hyprland は ''ファイルへの変更が保存されるたびに'' 自動的に {{ic|hyprland.conf}} を解析します。すべてに {{ic|exec}} を使用しないでください。
  +
  +
ほとんどの場合、起動時にアプリケーションとデーモンを起動するには、{{ic|exec-once}} を使用する必要があります。このコマンドはリロードで再度実行されないため、{{ic|exec}} は、絶対に実行する場合にのみ使用してください。リロードのたびにコマンドを再度実行することが '''確実な場合にのみ''' exec を使用してください。}}
  +
  +
=== 環境変数の設定 ===
  +
  +
''env'' キーワードを使用して、[[環境変数]] を {{ic|hyprland.conf}} に直接設定できます。このキーワードの構文は、シェルで使用される ''env'' UNIX コマンドとは異なります。
  +
  +
違いについては、[https://wiki.hyprland.org/Cconfiguring/Environment-variables/ upstream Wiki] で説明されています。
  +
  +
== ヒントとテクニック ==
  +
  +
{{Note|
  +
* 以下のすべてのセクションでは、通常、同様の結果を達成する方法が複数あります。ここで提供するものはすべて基本的な例です。
  +
* 代替手段の包括的なリストについては、[[アプリケーション一覧]] を参照してください。Hyprland 固有のリストは、[https://wiki.hyprland.org/Useful-Utilities/ upstream's Wiki] にあります。
  +
}}
  +
  +
=== ファイルマネージャー ===
  +
  +
グラフィカルなファイル管理が必要な場合、Hyprland には Wayland 互換の外部アプリケーションが必要です。例として {{Pkg|thunar}} を使用すると、次のようにキーバインドを割り当てるだけで済みます。
  +
  +
{{hc|~/.config/hypr/hyprland.conf|2=
  +
...
  +
bind = SUPER, E, exec, thunar
  +
...
  +
}}
  +
  +
=== アプリケーションランチャー ===
  +
  +
Hyprland では、アプリケーションを起動するために Wayland と互換性のある外部アプリケーションが必要です。例として {{Pkg|wofi}} を使用すると、次のようにキーバインドを割り当てるだけで済みます。
  +
  +
{{hc|~/.config/hypr/hyprland.conf|2=
  +
...
  +
bind = SUPER, F, exec, wofi
  +
...
  +
}}
  +
  +
=== アイドル状態 ===
  +
  +
Hyprland には、Wayland 互換の外部アイドル管理デーモンが必要です。最も一般的なセットアップは、{{Pkg|swayidle}} と {{Pkg|swaylock}} です。次のようにバインドを使用して画面を手動でロックできます。
  +
  +
{{hc|~/.config/hypr/hyprland.conf|2=
  +
...
  +
bind = SUPER, L, exec, swaylock -f -c 000000
  +
...
  +
}}
  +
  +
==== 自動画面ロックとサスペンド ====
  +
  +
次のスクリプトを作成します:
  +
  +
{{hc|~/.config/hypr/scripts/sleep.sh|2=
  +
swayidle -w timeout 300 'swaylock -f -c 000000' \
  +
timeout 600 'systemctl suspend' \
  +
before-sleep 'swaylock -f -c 000000' &
  +
}}
  +
  +
{{Tip|
  +
* 数値を編集することでタイムアウト期間を秒単位で調整できます。300 は 5 分、600 は 10 分などです。
  +
* スクリプトは [[ヘルプ:読み方#実行可能属性の付与|実行可能ファイル]] である必要があります。
  +
}}
  +
  +
次に、それを呼び出します:
  +
  +
{{hc|~/.config/hypr/hyprland.conf|2=
  +
...
  +
exec-once = ~/.config/hypr/scripts/sleep.sh
  +
...
  +
}}
  +
  +
==== タイムアウト期間後に DPMS を使用して画面をオフにする ====
  +
  +
Hyprland には DPMS リクエストを処理する組み込みディスパッチャがありますが、これを直接キーバインドとして使用することはお勧めできません。使用すると、画面を再びオンにできなくなり、再起動が必要になります。
  +
  +
上記のスクリプトを編集して次のように変更します:
  +
  +
{{hc|~/.config/hypr/scripts/sleep.sh|2=
  +
swayidle -w timeout 300 'swaylock -f -c 000000' \
  +
timeout 600 'hyprctl dispatch dpms off' \
  +
resume 'hyprctl dispatch dpms on' \
  +
timeout 900 'systemctl suspend' \
  +
before-sleep 'swaylock -f -c 000000' &
  +
}}
  +
  +
{{Tip|''resume'' コマンドは前のコマンドにリンクされているため、正しく機能するには、{{ic|hyprctldispatch dpms on}} コマンドをスクリプト内の {{ic|hyprctldispatch dpms off}} コマンドの直後に指定する必要があります。}}
  +
  +
===== アプリケーションの使用中に DPMS を停止する =====
  +
  +
上記の設定を行うと、ゲームをプレイしたり、ビデオを見たり、音楽を聴いたりするなど、タイムアウト期間を超えてシステムに触らない可能性のある作業を行っているときにモニターの電源がオフになります。
  +
  +
これを修正するには、{{ic|idleinhibit}} ルールを持つ [https://wiki.hyprland.org/Cconfiguring/Window-Rules#window-rules-v2 Window Rules V2] 関数に組み込まれた Hyprlands を使用するか、{{AUR|idlehack-git}} または {{AUR|sway-audio-idle-inhibit-git}} のいずれかをインストールします。前者は、[[Firefox]] または [[Chromium]] がオーディオ/ビデオを再生しているときは常に [[D-Bus]] を使用して Swayidle リクエストを防止します。後者は、アプリケーションがオーディオを再生しているときは常に Swayidle リクエストを阻止します。
  +
  +
=== ステータスバー ===
  +
  +
Hyprland でステータス バーを表示するには、Wayland 互換の外部アプリケーションが必要です。例として {{Pkg|waybar}} を使用すると、次のように呼び出すだけで済みます:
  +
  +
{{hc|~/.config/hypr/hyprland.conf|2=
  +
...
  +
exec-once = waybar -c ~/.config/waybar/waybar.conf
  +
...
  +
}}
  +
  +
==== ワークスペースの概要 ====
  +
  +
{{Pkg|waybar}} には、Hyprland ワークスペースの切り替えをネイティブにサポートする、完全にカスタマイズ可能なモジュールが組み込まれています。
  +
  +
詳細については、waybar Wiki [https://github.com/Alexays/Waybar/wiki/Module:-Workspaces] を参照してください。
  +
  +
=== Polkit 認証 ===
  +
  +
[[Polkit]] 認証には、外部 [[Polkit#Authentication エージェント|認証エージェント]] の使用が必要です。Hyprland では {{Pkg|polkit-kde-agent}} の使用を推奨していますが、どれでも機能するはずです。
  +
  +
次のように呼び出します:
  +
  +
{{hc|~/.config/hypr/hyprland.conf|2=
  +
...
  +
exec-once = /usr/lib/polkit-kde-authentication-agent-1
  +
...
  +
}}
  +
  +
=== デスクトップの壁紙 ===
  +
  +
Hyprland では、デスクトップの壁紙を管理するために、Wayland と互換性のある外部アプリケーションが必要です。例として {{AUR|swww}} を使用すると、次のように呼び出すだけで済みます:
  +
  +
{{hc|~/.config/hypr/hyprland.conf|2=
  +
...
  +
exec-once = swww init
  +
exec-once = swww img ''path/to/image''
  +
...
  +
}}
  +
  +
==== スクリプトを使用して X 分ごとに壁紙を変更する ====
  +
  +
次のスクリプトを作成し、[[ヘルプ:読み方#実行可能属性の付与|実行可能ファイル]] であることを確認します:
  +
  +
{{hc|~/.config/hypr/scripts/swww-random|2=<nowiki>
 
#!/bin/bash
 
#!/bin/bash
  +
export SDL_VIDEODRIVER=wayland
 
  +
# This script will randomly go through the files of a directory, setting it
export MOZ_ENABLE_WAYLAND=1
 
  +
# up as the wallpaper at regular intervals
export GTK_THEME=Catppuccin-blue:dark
 
  +
#
exec Hyprland
 
  +
# NOTE: this script uses bash (not POSIX shell) for the RANDOM variable
  +
  +
if [[ $# -lt 1 ]] || [[ ! -d $1 ]]; then
  +
echo "Usage:
  +
$0 <dir containing images>"
  +
exit 1
  +
fi
  +
  +
# Edit below to control the images transition
  +
export SWWW_TRANSITION_FPS=144
  +
export SWWW_TRANSITION_STEP=2
  +
export SWWW_TRANSITION_TYPE=random
  +
  +
# This controls (in seconds) when to switch to the next image
  +
INTERVAL=300
  +
  +
while true; do
  +
find "$1" \
  +
| while read -r img; do
  +
echo "$((RANDOM % 1000)):$img"
  +
done \
  +
| sort -n | cut -d':' -f2- \
  +
| while read -r img; do
  +
swww img "$img"
  +
sleep $INTERVAL
  +
done
  +
done
  +
</nowiki>
 
}}
 
}}
   
  +
次に、背景画像を保存する新しいフォルダーを作成します。{{ic|~/.config/hypr/backgrounds}} のようなフォルダーを作成し、そこに必要な画像を追加します。
While launching from a [[ディスプレイマネージャ]] is not officially supported, users have reported success launching from [[GDM]], [[SDDM]], and others. All Hyprland AUR packages will generate a display manager entry automatically. If manually installing from source, an example {{ic|Hyprland.desktop}} file is provided in the example directory of the source code, which may be copied to {{ic|/usr/share/wayland-sessions/}} to provide a display manager entry.
 
   
  +
最後にスクリプトを呼び出します:
Both methods provide identical results, plus or minus a few environment variables and services.
 
   
  +
{{hc|~/.config/hypr/hyprland.conf|2=
=== hyprctl and IPC ===
 
  +
...
  +
exec-once = swww init
  +
exec-once = ~/.config/hypr/scripts/swww-random ~/.config/hypr/background
  +
...
  +
}}
   
  +
=== 画面上の通知 ===
''hyprctl'' is a command line utility that comes installed with Hyprland to communicate with the display server. It allows you to dispatch commands to the server (equivalent to commands in the configuration file, but with a slightly different syntax), set keywords, send queries and request information. See the [https://github.com/vaxerski/Hyprland/wiki/Using-hyprctl full documentation].
 
   
  +
外部通知デーモンを使用すると、明るさや音量の変更などのアクションを画面上で通知できます。これは非常に複雑なトピックなので、完全に説明することはこのページの範囲を超えています。むしろ、このセクションでは {{Pkg|mako}} に焦点を当てますので、[[インストール]] してください。
Hyprland also exposes [https://github.com/vaxerski/Hyprland/wiki/IPC 2 UNIX Sockets], for controlling and getting information about Hyprland via code or command-line utilities. These sockets broadcast events on focus change (windows, workspaces, monitors), creation of windows/workspace, and so on.
 
   
  +
詳細な手順については [[デスクトップ通知]] を、代替手段のリストについては [[デスクトップ通知#スタンドアロン]] を参照してください。
Both ''hyprctl'' and the IPC sockets can be effectively used in scripts to control Hyprland for complex tasks.
 
   
  +
{{Note|
== 設定 ==
 
  +
* ここで提供されるすべてのスクリプトは例であり、セットアップに合わせて調整する必要があります。
  +
* このセクションのすべてのスクリプトは [[ヘルプ:読み方#実行可能属性の付与|実行可能ファイル]] である必要があります。
  +
}}
   
  +
==== Mako ====
設定は 1 つの設定ファイル、[https://github.com/vaxerski/Hyprland/blob/main/example/hyprland.conf hyprland.conf] を通して行われます。パッケージマネージャで Hyprland をインストールした場合、おそらく /usr/share/hyprland/hyprland.conf にあります。ソースからインストールした場合は、Hyprland をクローンしたレポジトリにあります。hyprland.conf を {{ic|~/.config/hypr/hyprland.conf}} にコピーしてください。
 
   
  +
Mako は軽量の通知デーモンです。詳細については、{{man|5|mako}} を参照してください。設定ファイルは {{ic|~/.config/mako/config}} で、OSD に使用されるアイコンは {{ic|~/.config/mako/icons/}} に保存されており、PNG 形式である必要があります。
{{ic|hyprland.conf}} には、デバイス (モニタ、キーボード、マウス、トラックパッド) を設定するディレクティブと、アニメーション、装飾、レイアウトなどの設定が含まれています。キーバインディングやウィンドウのルールを設定したり、コマンドを実行したりできます (一度だけ、あるいはコンフィグが再読み込みされるたびに)。
 
   
  +
このセクションの残りの部分では、スクリプトで使用されるすべてのイメージは [https://github.com/SolDoesTech/HyprV4/tree/main/HyprV/mako/icons この GitHub フォルダー] から入手できます。
ファイルを更新するたびに設定が自動的にリロードされます。同じ効果を得るために {{ic|hyprctl reload}} を使うこともできます。いくつかの設定(特に入力設定)については、Hyprland セッションを再起動する必要があるかもしれません。
 
   
  +
===== キーボードのバックライト通知 =====
設定は {{ic|hyprctl}} を使用してその場で変更することもできますが、保存されません。
 
  +
  +
まず次のスクリプトを作成します:
  +
  +
{{hc|~/.config/hypr/scripts/kbbacklight|2=
  +
<nowiki>
  +
#!/usr/bin/env bash
  +
  +
iDIR="$HOME/.config/mako/icons"
  +
  +
# Get brightness
  +
get_backlight() {
  +
LIGHT="$(cat /sys/class/leds/*::kbd_backlight/brightness)"
  +
echo "${LIGHT}"
  +
}
  +
  +
# Get icons
  +
get_icon() {
  +
current="$(cat /sys/class/leds/*::kbd_backlight/brightness)"
  +
  +
if [[ ("$current" -ge "0") && ("$current" -le "1") ]]; then
  +
icon="$iDIR/brightness-20.png"
  +
elif [[ ("$current" -ge "1") && ("$current" -le "2") ]]; then
  +
icon="$iDIR/brightness-60.png"
  +
elif [[ ("$current" -ge "2") && ("$current" -le "3") ]]; then
  +
icon="$iDIR/brightness-100.png"
  +
fi
  +
}
  +
  +
# Notify
  +
notify_user() {
  +
notify-send -h string:x-canonical-private-synchronous:sys-notify -u low -i "$icon" "Keyboard Brightness : $(brightnessctl -d '*::kbd_backlight' g)"
  +
}
  +
  +
# Increase brightness
  +
inc_backlight() {
  +
brightnessctl -d *::kbd_backlight set 33%+ && get_icon && notify_user
  +
}
  +
  +
# Decrease brightness
  +
dec_backlight() {
  +
brightnessctl -d *::kbd_backlight set 33%- && get_icon && notify_user
  +
}
  +
  +
# Zero brightness
  +
zero_backlight() {
  +
brightnessctl -d *::kbd_backlight s 0%
  +
}
  +
  +
# Full brightness
  +
full_backlight() {
  +
brightnessctl -d *::kbd_backlight s 100%
  +
}
  +
  +
# Execute accordingly
  +
if [[ "$1" == "--get" ]]; then
  +
brightnessctl -d '*::kbd_backlight' g
  +
elif [[ "$1" == "--inc" ]]; then
  +
inc_backlight
  +
elif [[ "$1" == "--dec" ]]; then
  +
dec_backlight
  +
elif [[ "$1" == "--zero" ]]; then
  +
zero_backlight
  +
elif [[ "$1" == "--full" ]]; then
  +
full_backlight
  +
  +
else
  +
get_backlight
  +
fi
  +
</nowiki>
  +
}}
  +
  +
次に、以下を追加します (または既存のバインドを編集します):
  +
  +
{{hc|~/.config/hypr/hyprland.conf|2=
  +
# Keyboard brightness
  +
bind = SUPER, F2, exec, ~/.config/hypr/scripts/kbbacklight --dec
  +
bind = SUPER, F3, exec, ~/.config/hypr/scripts/kbbacklight --inc
  +
}}
  +
  +
===== メディアキーの通知 =====
  +
  +
まず次のスクリプトを作成します:
  +
  +
{{hc|~/.config/hypr/scripts/volume|2=<nowiki>
  +
#!/usr/bin/env bash
  +
  +
iDIR="$HOME/.config/mako/icons"
  +
  +
# Get Volume
  +
get_volume() {
  +
volume=$(pamixer --get-volume)
  +
echo "$volume"
  +
}
  +
  +
# Get icons
  +
get_icon() {
  +
current=$(get_volume)
  +
if [[ "$current" -eq "0" ]]; then
  +
echo "$iDIR/volume-mute.png"
  +
elif [[ ("$current" -ge "0") && ("$current" -le "30") ]]; then
  +
echo "$iDIR/volume-low.png"
  +
elif [[ ("$current" -ge "30") && ("$current" -le "60") ]]; then
  +
echo "$iDIR/volume-mid.png"
  +
elif [[ ("$current" -ge "60") && ("$current" -le "100") ]]; then
  +
echo "$iDIR/volume-high.png"
  +
fi
  +
}
  +
  +
# Notify
  +
notify_user() {
  +
notify-send -h string:x-canonical-private-synchronous:sys-notify -u low -i "$(get_icon)" "Volume : $(get_volume) %"
  +
}
  +
  +
# Increase Volume
  +
inc_volume() {
  +
pamixer -i 5 && notify_user
  +
}
  +
  +
# Decrease Volume
  +
dec_volume() {
  +
pamixer -d 5 && notify_user
  +
}
  +
  +
# Toggle Mute
  +
toggle_mute() {
  +
if [ "$(pamixer --get-mute)" == "false" ]; then
  +
pamixer -m && notify-send -h string:x-canonical-private-synchronous:sys-notify -u low -i "$iDIR/volume-mute.png" "Volume Switched OFF"
  +
elif [ "$(pamixer --get-mute)" == "true" ]; then
  +
pamixer -u && notify-send -h string:x-canonical-private-synchronous:sys-notify -u low -i "$(get_icon)" "Volume Switched ON"
  +
fi
  +
}
  +
  +
# Toggle Mic
  +
toggle_mic() {
  +
if [ "$(pamixer --default-source --get-mute)" == "false" ]; then
  +
pamixer --default-source -m && notify-send -h string:x-canonical-private-synchronous:sys-notify -u low -i "$iDIR/microphone-mute.png" "Microphone Switched OFF"
  +
elif [ "$(pamixer --default-source --get-mute)" == "true" ]; then
  +
pamixer -u --default-source u && notify-send -h string:x-canonical-private-synchronous:sys-notify -u low -i "$iDIR/microphone.png" "Microphone Switched ON"
  +
fi
  +
}
  +
# Get icons
  +
get_mic_icon() {
  +
current=$(pamixer --default-source --get-volume)
  +
if [[ "$current" -eq "0" ]]; then
  +
echo "$iDIR/microphone.png"
  +
elif [[ ("$current" -ge "0") && ("$current" -le "30") ]]; then
  +
echo "$iDIR/microphone.png"
  +
elif [[ ("$current" -ge "30") && ("$current" -le "60") ]]; then
  +
echo "$iDIR/microphone.png"
  +
elif [[ ("$current" -ge "60") && ("$current" -le "100") ]]; then
  +
echo "$iDIR/microphone.png"
  +
fi
  +
}
  +
# Notify
  +
notify_mic_user() {
  +
notify-send -h string:x-canonical-private-synchronous:sys-notify -u low -i "$(get_mic_icon)" "Mic-Level : $(pamixer --default-source --get-volume) %"
  +
}
  +
  +
# Increase MIC Volume
  +
inc_mic_volume() {
  +
pamixer --default-source -i 5 && notify_mic_user
  +
}
  +
  +
# Decrease MIC Volume
  +
dec_mic_volume() {
  +
pamixer --default-source -d 5 && notify_mic_user
  +
}
  +
  +
# Execute accordingly
  +
if [[ "$1" == "--get" ]]; then
  +
get_volume
  +
elif [[ "$1" == "--inc" ]]; then
  +
inc_volume
  +
elif [[ "$1" == "--dec" ]]; then
  +
dec_volume
  +
elif [[ "$1" == "--toggle" ]]; then
  +
toggle_mute
  +
elif [[ "$1" == "--toggle-mic" ]]; then
  +
toggle_mic
  +
elif [[ "$1" == "--get-icon" ]]; then
  +
get_icon
  +
elif [[ "$1" == "--get-mic-icon" ]]; then
  +
get_mic_icon
  +
elif [[ "$1" == "--mic-inc" ]]; then
  +
inc_mic_volume
  +
elif [[ "$1" == "--mic-dec" ]]; then
  +
dec_mic_volume
  +
else
  +
get_volume
  +
fi
  +
</nowiki>}}
  +
  +
次に、以下を追加します (または既存のバインドを編集します):
  +
  +
{{hc|~/.config/hypr/hyprland.conf|2=
  +
# Volume
  +
bind = , XF86AudioRaiseVolume, exec, ~/.config/hypr/scripts/volume --inc
  +
bind = , XF86AudioLowerVolume, exec, ~/.config/hypr/scripts/volume --dec
  +
bind = , XF86AudioMicMute, exec, ~/.config/hypr/scripts/volume --toggle-mic
  +
bind = , XF86AudioMute, exec, ~/.config/hypr/scripts/volume --toggle
  +
}}
  +
  +
===== 画面のバックライト通知 =====
  +
  +
まず次のスクリプトを作成します:
  +
  +
{{hc|~/.config/hypr/scripts/backlight|2=<nowiki>
  +
!/usr/bin/env bash
  +
  +
iDIR="$HOME/.config/mako/icons"
  +
  +
# Get brightness
  +
get_backlight() {
  +
LIGHT=$(printf "%.0f\n" $(brightnessctl g))
  +
echo "${LIGHT}"
  +
}
  +
  +
# Get icons
  +
get_icon() {
  +
current="$(get_backlight)"
  +
if [[ ("$current" -ge "0") && ("$current" -le "19200") ]]; then
  +
icon="$iDIR/brightness-20.png"
  +
elif [[ ("$current" -ge "19200") && ("$current" -le "38400") ]]; then
  +
icon="$iDIR/brightness-40.png"
  +
elif [[ ("$current" -ge "38400") && ("$current" -le "57600") ]]; then
  +
icon="$iDIR/brightness-60.png"
  +
elif [[ ("$current" -ge "57600") && ("$current" -le "76800") ]]; then
  +
icon="$iDIR/brightness-80.png"
  +
elif [[ ("$current" -ge "76800") && ("$current" -le "96000") ]]; then
  +
icon="$iDIR/brightness-100.png"
  +
fi
  +
}
  +
  +
# Notify
  +
notify_user() {
  +
notify-send -h string:x-canonical-private-synchronous:sys-notify -u low -i "$icon" "Brightness : $(get_backlight)"
  +
}
  +
  +
# Increase brightness
  +
inc_backlight() {
  +
brightnessctl s +5% && get_icon && notify_user
  +
}
  +
  +
# Decrease brightness
  +
dec_backlight() {
  +
brightnessctl s 5%- && get_icon && notify_user
  +
}
  +
  +
# Execute accordingly
  +
if [[ "$1" == "--get" ]]; then
  +
get_backlight
  +
elif [[ "$1" == "--inc" ]]; then
  +
inc_backlight
  +
elif [[ "$1" == "--dec" ]]; then
  +
dec_backlight
  +
else
  +
get_backlight
  +
fi
  +
</nowiki>}}
  +
  +
次に、以下を追加します (または既存のバインドを編集します):
  +
  +
{{hc|~/.config/hypr/hyprland.conf|2=
  +
# Screen brightness
  +
bind = , XF86MonBrightnessUp, exec, ~/.config/hypr/scripts/backlight --inc
  +
bind = , XF86MonBrightnessDown, exec, ~/.config/hypr/scripts/backlight --dec
  +
}}
  +
  +
===== キーボード言語の通知 =====
  +
  +
このスクリプトを実行するには、コマンドライン JSON プロセッサ {{AUR|gojq}} が必要です。
  +
  +
まず次のスクリプトを作成します:
  +
  +
{{hc|~/.config/hypr/scripts/lang|2=<nowiki>
  +
#!/usr/bin/env bash
  +
  +
icon="$HOME/.config/mako/icons/language.png"
  +
  +
# Get language
  +
get_lang() {
  +
lang=$(hyprctl devices -j | gojq -r '.keyboards[] | select(.name == "at-translated-set-2-keyboard") | .active_keymap' | cut -c 1-2 | tr 'A-Z' 'a-z')
  +
case $lang in
  +
en)
  +
lang="English language"
  +
;;
  +
ru)
  +
lang="Русский язык"
  +
;;
  +
uk)
  +
lang="Українська мова"
  +
;;
  +
esac
  +
echo $lang
  +
}
  +
  +
# Notify
  +
notify-send -h string:x-canonical-private-synchronous:sys-notify -u low -i "$icon" "$(get_lang)"
  +
</nowiki>}}
  +
  +
次に、以下を追加します (または既存のバインドを編集します):
  +
  +
{{hc|~/.config/hypr/hyprland.conf|2=
  +
device:at-translated-set-2-keyboard {
  +
kb_layout = us,ru,ua
  +
kb_variant = lang
  +
kb_options = grp:win_space_toggle
  +
}
  +
  +
# Language
  +
bind = SUPER, SPACE, exec, ~/.config/hypr/scripts/lang
  +
}}
  +
  +
=== 電源制御 ===
  +
  +
Hyprland では、電源制御のために Wayland 互換の外部アプリケーションが必要です。例として {{AUR|nwg-bar}} を使用すると、次のようにバインドするだけで済みます:
  +
  +
{{hc|~/.config/hypr/hyprland.conf|2=
  +
...
  +
bind = SUPER, ESCAPE, exec, nwg-bar
  +
...
  +
}}
  +
  +
=== クリップボード ===
  +
  +
[[Wayland]] クリップボードの動作により、コピー元のアプリケーションを閉じるとデータが削除されます。他のデスクトップ環境では、専用のクリップボードマネージャーを使用することでこの問題を回避できますが、Hyprland には互換性のある選択肢が複数あります。詳細については、[https://wiki.hyprland.org/Useful-Utilities/Clipboard-Managers/ upstream's Wiki] を参照してください。
  +
  +
このセクションでは、テキストだけでなく画像のコピーもサポートしている {{Pkg|cliphist}} について説明します。まず、次の行を追加します:
  +
  +
{{hc|~/.config/hypr/hyprland.conf|2=
  +
...
  +
exec-once = wl-paste --type text --watch cliphist store
  +
exec-once = wl-paste --type image --watch cliphist store
  +
...
  +
}}
  +
  +
次に、選択した [[Hyprland#アプリケーションランチャー|アプリケーションランチャー]] の履歴を呼び出すバインドを作成します:
  +
  +
{{hc|~/.config/hypr/hyprland.conf|2=
  +
...
  +
bind = SUPER, V, exec, cliphist list {{!}} wofi --dmenu {{!}} cliphist decode {{!}} wl-copy
  +
...
  +
}}
  +
  +
{{ic|Super+v}} を押すと、{{ic|wofi}} ウィンドウが開き、クリップボード履歴リストが表示されます。
  +
  +
== トラブルシューティング ==
  +
  +
=== xdg-desktop-portal-hyprland が大量の CPU を使用する ===
   
  +
これは既知のバグ [https://github.com/hyprwm/xdg-desktop-portal-hyprland/issues/103] であり、最新の [[Git]] ビルドでは解決されているはずです。これを回避するには、[https://wiki.hyprland.org/Useful-Utilities/Hyprland-desktop-portal/#usage こちら] Hyprland wiki で説明されているように、スクリプトを {{ic|hyprland.conf}} ファイルで呼び出すことで回避できます。
設定方法は [https://github.com/vaxerski/Hyprland/wiki Hyprland wiki] に記載されています。
 
   
 
== 参照 ==
 
== 参照 ==
   
* [https://wiki.hyprland.org/FAQ/ Developer's wiki] on GitHub
+
* [https://hyprland.org/ Hyprland Web サイト]
  +
* [https://wiki.hyprland.org/ 公式ドキュメント]
  +
* [https://github.com/hyprwm/Hyprland/ Hyprland Github Page]
  +
* [https://github.com/hyprland-community/awesome-hyprland コミュニティが管理するツール、プラグイン、拡張機能のリスト]
  +
* [https://github.com/SolDoesTech/HyprV4 SolDoesTech - Github リポジトリ 通知スクリプト]
   
{{TranslationStatus|Hyprland|2022-07-22|732472}}
+
{{TranslationStatus|Hyprland|2023-12-31|764833}}

2023年12月31日 (日) 23:36時点における最新版

関連記事

Hyprland は C++ で書かれた wlroots ベースのタイリング Wayland コンポジタ です。Hyprland の特筆すべき点は、ダイナミックタイリング、タブ付きウィンドウ、クリーンで読みやすい C++ コードベース、ウィンドウアニメーションや角丸、透明ウィンドウでの Dual-Kawase Blur を提供するカスタムレンダラーなどです。一般的な使い方や設定方法は、 Hyprland Wiki に詳しく書かれています。

インストール

次のいずれかをインストールします:

  • hyprland - 最新のアップストリームリリース。
  • hyprland-gitAUR - master ブランチへの最新のコミット。

Hyprland は、wlroots-gitAUR に厳密に従う独自のバージョンの wlroots をバンドルしています。これにより、安定性が向上すると同時に、他の wlroots ベースのコンポジターとの依存関係の競合も回避されます。

ノート:
  • NVIDIA GPU ユーザーは、Hyprland を起動する前に、upstream Wiki のNVIDIA専用ページにも必ず従ってください。これを怠ると、ログインできない、ウィンドウが点滅する、CPU使用率が高いなど、多くのバグが発生する可能性があります。
  • Hyprland での NVIDIA GPU の使用はサポートされていません。問題が起きても全て自己責任でお願いします。

設定

ノート: リストされているオプションのほとんど (およびその他) は、Wiki の変数ページで詳しく説明されています。

設定は 1 つの設定ファイル、hyprland.conf を通して行われます。パッケージマネージャで Hyprland をインストールした場合、おそらく /usr/share/hyprland/hyprland.conf にあります。ソースからインストールした場合は、Hyprland をクローンしたレポジトリにあります。hyprland.conf を ~/.config/hypr/hyprland.conf にコピーしてください。

hyprland.conf には、デバイス (モニタ、キーボード、マウス、トラックパッド) を設定するディレクティブと、アニメーション、装飾、レイアウトなどの設定が含まれています。キーバインディングやウィンドウのルールを設定したり、コマンドを実行したりできます (一度だけ、あるいはコンフィグが再読み込みされるたびに)

ファイルを更新するたびに設定が自動的にリロードされます。同じ効果を得るために hyprctl reload を使うこともできます。いくつかの設定(特に入力設定)については、Hyprland セッションを再起動する必要があるかもしれません。

設定は hyprctl を使用してその場で変更することもできますが、保存されません。

キーボード

キーマップ

デフォルトでは、Hyprland は US Qwerty を使用します。次のように設定できます:

~/.config/hypr/hyprland.conf
# German Colemark layout
input {
    ...
    kb_layout = de
    kb_variant = colemark
    ...
    }

利用可能なすべてのオプションについては、upstream's Wiki を参照してください。

ノート: Hyprland は ロケール 定義をオーバーライドするため、US レイアウトキーボードを使用しない場合はキーマップを変更する必要があります。

典型的な遅延と速度

Xorg ユーザーはこの設定 サーバーレベルで定義 を使用することに慣れていますが、Wayland では各コンポジターがそれを独自に処理します。

~/.config/hypr/hyprland.conf
# Repeat rate and delay
input {
    ...
    repeat_rate = 25
    repeat_delay = 600
    ...
    }

キーボードのバックライト

他の照明コントロールとは異なり、キーボードバックライトには XF86 キーシムがないため、従来のバインドを行う必要があります。

brightnessctlインストール します、次のバインドを追加します。

~/.config/hypr/hyprland.conf
# Keyboard backlight
bind = SUPER, F3, exec, brightnessctl -d *::kbd_backlight set +33%
bind = SUPER, F2, exec, brightnessctl -d *::kbd_backlight set 33%-

変更が行われたときに 画面上の通知 を実行することもできます。

ノート: ラップトップにハードウェアキーボードバックライトコントロール (キーボードの Fn キーを使用) がある場合、追加の手順なしで機能するはずです。

メディアキー

Hyprland でキーボードメディアコントロールを使用するには、XF86Audio キーシムと、pavucontrol または pamixerplayerctl などの外部アプリケーションを利用することで可能です。

~/.config/hypr/hyprland.conf
# Volume and Media Control
bind = , XF86AudioRaiseVolume, exec, pamixer -i 5 
bind = , XF86AudioLowerVolume, exec, pamixer -d 5 
bind = , XF86AudioMicMute, exec, pamixer --default-source -m
bind = , XF86AudioMute, exec, pamixer -t
bind = , XF86AudioPlay, exec, playerctl play-pause
bind = , XF86AudioPause, exec, playerctl play-pause
bind = , XF86AudioNext, exec, playerctl next
bind = , XF86AudioPrev, exec, playerctl previous

変更が行われたときに 通知 を実行することもできます。

タッチパッドのジェスチャ

Wayland コンポジタである Hyprland はタッチパッドジェスチャを完全にサポートしていますが、デフォルトでは無効になっています。それらを有効にするには、次を編集します:

~/.config/hypr/hyprland.conf
# Enable touchpad gestures
gestures {
    workspace_swipe = true
    workspace_swipe_fingers = 3
}

利用可能なすべてのオプションについては、upstream Wiki を参照してください。

ディスプレイの設定

画面共有

Screen-sharing を参照してください。

wlroots ベースのコンポジタとして、Hyprland は xdg-desktop-portal-wlr を利用して、xdg-desktop-portal 経由でさまざまなアプリケーションで画面キャプチャを有効にすることができます。

Hyprland は、領域共有、ウィンドウ共有、グラフィカルピッカーユーティリティなどの機能を追加した wlr ポータルのフォークである xdg-desktop-portal-hyprland も保守しています。ポータルの使用法については、Hyprland wiki で詳しく説明されています。

画面解像度の設定

Hyprland は画面解像度を自動的に検出しようとしますが、複数の画面が存在する場合やハイブリッドラップトップを使用している場合は、場合によっては失敗し、デフォルトでフェールセーフが設定されます。画面上のすべてが大きい場合は、デフォルトのモニターと解像度を設定する必要があります。

まず、hyprctl を使用してデフォルトのモニターを見つけます:

$ hyprctl monitors
Monitor eDP-1 (ID 0):
        1920x1080@144.003006 at 0x0
        description: Chimei Innolux Corporation 0x153C (eDP-1)
        ...

次に、モニターを設定に追加します:

~/.config/hypr/hyprland.conf
...
# Monitor details
monitor=eDP-1,1920x1080@144,0x0,1
...

0x0 はマルチスクリーン設定に使用される位置オフセットで、最後の 1 は画面のスケーリング係数です。

画面のバックライト

brightnessctlインストール して、次のバインドを追加します。

~/.config/hypr/hyprland.conf
# Screen brightness
bind = , XF86MonBrightnessUp, exec, brightnessctl -s +5%
bind = , XF86MonBrightnessDown, exec, brightnessctl -s 5%-

変更が行われたときに 通知 を実行することもできます。

使用方法

起動

現在、Hyprland は TTY から起動することを推奨しています。

$ Hyprland

ディスプレイマネージャ からの起動は公式にはサポートされていませんが、GDMSDDM、その他からの起動に成功したとの報告があります。全ての Hyprland AUR パッケージは自動的にディスプレイマネージャーエントリーを生成します。ソースから手動でインストールする場合、ソースコードの example ディレクトリに Hyprland.desktop ファイルのサンプルがあります、これを /usr/share/wayland-sessions/ にコピーしてディスプレイマネージャーのエントリーを提供することができます。

どちらの方法でも、いくつかの環境変数やサービスを追加したり削除したりすることで、同じ結果を得ることができます

自動ログイン

ディスプレイマネージャ または シェルから ユーザーは自動的にログインできます。

hyprctl と IPC

hyprctl は Hyprland にインストールされている、ディスプレイサーバーと通信するためのコマンドライン・ユーティリティです。サーバーにコマンドを送ったり (設定ファイルのコマンドと同じですが、構文が少し違います)、キーワードを設定したり、クエリ を送ったり、情報を要求したりすることができます。full documentation を参照してください。

Hyprland は 2 つの UNIX ソケット も公開しており、コードやコマンドライン・ユーティリティを使って Hyprland の情報を制御・取得することができます。これらのソケットはフォーカスの変更 (ウィンドウ、ワークスペース、モニター) やウィンドウ/ワークスペースの作成などのイベントをブロードキャストします。

hyprctl と IPC ソケットは、複雑なタスクのために Hyprland を制御するスクリプトの中で効果的に使うことができます。

exec と exec-once の比較

アプリケーションを起動するときは、正しいタイプのディスパッチャを使用することが重要です。exec を誤って使用すると、アプリケーションが複数回起動されてシステムリソースが占有され、最悪の場合、競合状態が発生してシステムがクラッシュする可能性があります。

ノート: 設定 で説明したように、Hyprland は ファイルへの変更が保存されるたびに 自動的に hyprland.conf を解析します。すべてに exec を使用しないでください。 ほとんどの場合、起動時にアプリケーションとデーモンを起動するには、exec-once を使用する必要があります。このコマンドはリロードで再度実行されないため、exec は、絶対に実行する場合にのみ使用してください。リロードのたびにコマンドを再度実行することが 確実な場合にのみ exec を使用してください。

環境変数の設定

env キーワードを使用して、環境変数hyprland.conf に直接設定できます。このキーワードの構文は、シェルで使用される env UNIX コマンドとは異なります。

違いについては、upstream Wiki で説明されています。

ヒントとテクニック

ノート:
  • 以下のすべてのセクションでは、通常、同様の結果を達成する方法が複数あります。ここで提供するものはすべて基本的な例です。
  • 代替手段の包括的なリストについては、アプリケーション一覧 を参照してください。Hyprland 固有のリストは、upstream's Wiki にあります。

ファイルマネージャー

グラフィカルなファイル管理が必要な場合、Hyprland には Wayland 互換の外部アプリケーションが必要です。例として thunar を使用すると、次のようにキーバインドを割り当てるだけで済みます。

~/.config/hypr/hyprland.conf
...
bind = SUPER, E, exec, thunar
...

アプリケーションランチャー

Hyprland では、アプリケーションを起動するために Wayland と互換性のある外部アプリケーションが必要です。例として wofi を使用すると、次のようにキーバインドを割り当てるだけで済みます。

~/.config/hypr/hyprland.conf
...
bind = SUPER, F, exec, wofi
...

アイドル状態

Hyprland には、Wayland 互換の外部アイドル管理デーモンが必要です。最も一般的なセットアップは、swayidleswaylock です。次のようにバインドを使用して画面を手動でロックできます。

~/.config/hypr/hyprland.conf
...
bind = SUPER, L, exec, swaylock -f -c 000000
...

自動画面ロックとサスペンド

次のスクリプトを作成します:

~/.config/hypr/scripts/sleep.sh
swayidle -w timeout 300 'swaylock -f -c 000000' \
            timeout 600 'systemctl suspend' \
            before-sleep 'swaylock -f -c 000000' &
ヒント:
  • 数値を編集することでタイムアウト期間を秒単位で調整できます。300 は 5 分、600 は 10 分などです。
  • スクリプトは 実行可能ファイル である必要があります。

次に、それを呼び出します:

~/.config/hypr/hyprland.conf
...
exec-once = ~/.config/hypr/scripts/sleep.sh
...

タイムアウト期間後に DPMS を使用して画面をオフにする

Hyprland には DPMS リクエストを処理する組み込みディスパッチャがありますが、これを直接キーバインドとして使用することはお勧めできません。使用すると、画面を再びオンにできなくなり、再起動が必要になります。

上記のスクリプトを編集して次のように変更します:

~/.config/hypr/scripts/sleep.sh
swayidle -w timeout 300 'swaylock -f -c 000000' \
            timeout 600 'hyprctl dispatch dpms off' \
            resume 'hyprctl dispatch dpms on' \
            timeout 900 'systemctl suspend' \
            before-sleep 'swaylock -f -c 000000' &
ヒント: resume コマンドは前のコマンドにリンクされているため、正しく機能するには、hyprctldispatch dpms on コマンドをスクリプト内の hyprctldispatch dpms off コマンドの直後に指定する必要があります。
アプリケーションの使用中に DPMS を停止する

上記の設定を行うと、ゲームをプレイしたり、ビデオを見たり、音楽を聴いたりするなど、タイムアウト期間を超えてシステムに触らない可能性のある作業を行っているときにモニターの電源がオフになります。

これを修正するには、idleinhibit ルールを持つ Window Rules V2 関数に組み込まれた Hyprlands を使用するか、idlehack-gitAUR または sway-audio-idle-inhibit-gitAUR のいずれかをインストールします。前者は、Firefox または Chromium がオーディオ/ビデオを再生しているときは常に D-Bus を使用して Swayidle リクエストを防止します。後者は、アプリケーションがオーディオを再生しているときは常に Swayidle リクエストを阻止します。

ステータスバー

Hyprland でステータス バーを表示するには、Wayland 互換の外部アプリケーションが必要です。例として waybar を使用すると、次のように呼び出すだけで済みます:

~/.config/hypr/hyprland.conf
...
exec-once = waybar -c ~/.config/waybar/waybar.conf
...

ワークスペースの概要

waybar には、Hyprland ワークスペースの切り替えをネイティブにサポートする、完全にカスタマイズ可能なモジュールが組み込まれています。

詳細については、waybar Wiki [1] を参照してください。

Polkit 認証

Polkit 認証には、外部 認証エージェント の使用が必要です。Hyprland では polkit-kde-agent の使用を推奨していますが、どれでも機能するはずです。

次のように呼び出します:

~/.config/hypr/hyprland.conf
...
exec-once = /usr/lib/polkit-kde-authentication-agent-1
...

デスクトップの壁紙

Hyprland では、デスクトップの壁紙を管理するために、Wayland と互換性のある外部アプリケーションが必要です。例として swwwAUR を使用すると、次のように呼び出すだけで済みます:

~/.config/hypr/hyprland.conf
...
exec-once = swww init
exec-once = swww img path/to/image
...

スクリプトを使用して X 分ごとに壁紙を変更する

次のスクリプトを作成し、実行可能ファイル であることを確認します:

~/.config/hypr/scripts/swww-random
#!/bin/bash

# This script will randomly go through the files of a directory, setting it
# up as the wallpaper at regular intervals
#
# NOTE: this script uses bash (not POSIX shell) for the RANDOM variable

if [[ $# -lt 1 ]] || [[ ! -d $1   ]]; then
	echo "Usage:
	$0 <dir containing images>"
	exit 1
fi

# Edit below to control the images transition
export SWWW_TRANSITION_FPS=144
export SWWW_TRANSITION_STEP=2
export SWWW_TRANSITION_TYPE=random

# This controls (in seconds) when to switch to the next image
INTERVAL=300

while true; do
	find "$1" \
		| while read -r img; do
			echo "$((RANDOM % 1000)):$img"
		done \
		| sort -n | cut -d':' -f2- \
		| while read -r img; do
			swww img "$img"
			sleep $INTERVAL
		done
done

次に、背景画像を保存する新しいフォルダーを作成します。~/.config/hypr/backgrounds のようなフォルダーを作成し、そこに必要な画像を追加します。

最後にスクリプトを呼び出します:

~/.config/hypr/hyprland.conf
...
exec-once = swww init
exec-once = ~/.config/hypr/scripts/swww-random ~/.config/hypr/background
...

画面上の通知

外部通知デーモンを使用すると、明るさや音量の変更などのアクションを画面上で通知できます。これは非常に複雑なトピックなので、完全に説明することはこのページの範囲を超えています。むしろ、このセクションでは mako に焦点を当てますので、インストール してください。

詳細な手順については デスクトップ通知 を、代替手段のリストについては デスクトップ通知#スタンドアロン を参照してください。

ノート:
  • ここで提供されるすべてのスクリプトは例であり、セットアップに合わせて調整する必要があります。
  • このセクションのすべてのスクリプトは 実行可能ファイル である必要があります。

Mako

Mako は軽量の通知デーモンです。詳細については、mako(5) を参照してください。設定ファイルは ~/.config/mako/config で、OSD に使用されるアイコンは ~/.config/mako/icons/ に保存されており、PNG 形式である必要があります。

このセクションの残りの部分では、スクリプトで使用されるすべてのイメージは この GitHub フォルダー から入手できます。

キーボードのバックライト通知

まず次のスクリプトを作成します:

~/.config/hypr/scripts/kbbacklight
#!/usr/bin/env bash

iDIR="$HOME/.config/mako/icons"

# Get brightness
get_backlight() {
	LIGHT="$(cat /sys/class/leds/*::kbd_backlight/brightness)"
	echo "${LIGHT}"
}

# Get icons
get_icon() {
	current="$(cat /sys/class/leds/*::kbd_backlight/brightness)"

	if [[ ("$current" -ge "0") && ("$current" -le "1") ]]; then
		icon="$iDIR/brightness-20.png"
	elif [[ ("$current" -ge "1") && ("$current" -le "2") ]]; then
		icon="$iDIR/brightness-60.png"
	elif [[ ("$current" -ge "2") && ("$current" -le "3") ]]; then
		icon="$iDIR/brightness-100.png"
	fi
}

# Notify
notify_user() {
	notify-send -h string:x-canonical-private-synchronous:sys-notify -u low -i "$icon" "Keyboard Brightness : $(brightnessctl -d '*::kbd_backlight' g)"
}

# Increase brightness
inc_backlight() {
	brightnessctl -d *::kbd_backlight set 33%+ && get_icon && notify_user
}

# Decrease brightness
dec_backlight() {
	brightnessctl -d *::kbd_backlight set 33%- && get_icon && notify_user
}

# Zero brightness
zero_backlight() {
	brightnessctl -d *::kbd_backlight s 0%
}

# Full brightness
full_backlight() {
	brightnessctl -d *::kbd_backlight s 100%
}

# Execute accordingly
if [[ "$1" == "--get" ]]; then
	brightnessctl -d '*::kbd_backlight' g
elif [[ "$1" == "--inc" ]]; then
	inc_backlight
elif [[ "$1" == "--dec" ]]; then
	dec_backlight
elif [[ "$1" == "--zero" ]]; then
	zero_backlight
elif [[ "$1" == "--full" ]]; then
	full_backlight

else
	get_backlight
fi

次に、以下を追加します (または既存のバインドを編集します):

~/.config/hypr/hyprland.conf
# Keyboard brightness
bind = SUPER, F2, exec, ~/.config/hypr/scripts/kbbacklight --dec
bind = SUPER, F3, exec, ~/.config/hypr/scripts/kbbacklight --inc
メディアキーの通知

まず次のスクリプトを作成します:

~/.config/hypr/scripts/volume
#!/usr/bin/env bash

iDIR="$HOME/.config/mako/icons"

# Get Volume
get_volume() {
	volume=$(pamixer --get-volume)
	echo "$volume"
}

# Get icons
get_icon() {
	current=$(get_volume)
	if [[ "$current" -eq "0" ]]; then
		echo "$iDIR/volume-mute.png"
	elif [[ ("$current" -ge "0") && ("$current" -le "30") ]]; then
		echo "$iDIR/volume-low.png"
	elif [[ ("$current" -ge "30") && ("$current" -le "60") ]]; then
		echo "$iDIR/volume-mid.png"
	elif [[ ("$current" -ge "60") && ("$current" -le "100") ]]; then
		echo "$iDIR/volume-high.png"
	fi
}

# Notify
notify_user() {
	notify-send -h string:x-canonical-private-synchronous:sys-notify -u low -i "$(get_icon)" "Volume : $(get_volume) %"
}

# Increase Volume
inc_volume() {
	pamixer -i 5 && notify_user
}

# Decrease Volume
dec_volume() {
	pamixer -d 5 && notify_user
}

# Toggle Mute
toggle_mute() {
	if [ "$(pamixer --get-mute)" == "false" ]; then
		pamixer -m && notify-send -h string:x-canonical-private-synchronous:sys-notify -u low -i "$iDIR/volume-mute.png" "Volume Switched OFF"
	elif [ "$(pamixer --get-mute)" == "true" ]; then
		pamixer -u && notify-send -h string:x-canonical-private-synchronous:sys-notify -u low -i "$(get_icon)" "Volume Switched ON"
	fi
}

# Toggle Mic
toggle_mic() {
	if [ "$(pamixer --default-source --get-mute)" == "false" ]; then
		pamixer --default-source -m && notify-send -h string:x-canonical-private-synchronous:sys-notify -u low -i "$iDIR/microphone-mute.png" "Microphone Switched OFF"
	elif [ "$(pamixer --default-source --get-mute)" == "true" ]; then
		pamixer -u --default-source u && notify-send -h string:x-canonical-private-synchronous:sys-notify -u low -i "$iDIR/microphone.png" "Microphone Switched ON"
	fi
}
# Get icons
get_mic_icon() {
	current=$(pamixer --default-source --get-volume)
	if [[ "$current" -eq "0" ]]; then
		echo "$iDIR/microphone.png"
	elif [[ ("$current" -ge "0") && ("$current" -le "30") ]]; then
		echo "$iDIR/microphone.png"
	elif [[ ("$current" -ge "30") && ("$current" -le "60") ]]; then
		echo "$iDIR/microphone.png"
	elif [[ ("$current" -ge "60") && ("$current" -le "100") ]]; then
		echo "$iDIR/microphone.png"
	fi
}
# Notify
notify_mic_user() {
	notify-send -h string:x-canonical-private-synchronous:sys-notify -u low -i "$(get_mic_icon)" "Mic-Level : $(pamixer --default-source --get-volume) %"
}

# Increase MIC Volume
inc_mic_volume() {
	pamixer --default-source -i 5 && notify_mic_user
}

# Decrease MIC Volume
dec_mic_volume() {
	pamixer --default-source -d 5 && notify_mic_user
}

# Execute accordingly
if [[ "$1" == "--get" ]]; then
	get_volume
elif [[ "$1" == "--inc" ]]; then
	inc_volume
elif [[ "$1" == "--dec" ]]; then
	dec_volume
elif [[ "$1" == "--toggle" ]]; then
	toggle_mute
elif [[ "$1" == "--toggle-mic" ]]; then
	toggle_mic
elif [[ "$1" == "--get-icon" ]]; then
	get_icon
elif [[ "$1" == "--get-mic-icon" ]]; then
	get_mic_icon
elif [[ "$1" == "--mic-inc" ]]; then
	inc_mic_volume
elif [[ "$1" == "--mic-dec" ]]; then
	dec_mic_volume
else
	get_volume
fi

次に、以下を追加します (または既存のバインドを編集します):

~/.config/hypr/hyprland.conf
# Volume
bind = , XF86AudioRaiseVolume, exec, ~/.config/hypr/scripts/volume --inc 
bind = , XF86AudioLowerVolume, exec, ~/.config/hypr/scripts/volume --dec 
bind = , XF86AudioMicMute, exec, ~/.config/hypr/scripts/volume --toggle-mic 
bind = , XF86AudioMute, exec, ~/.config/hypr/scripts/volume --toggle
画面のバックライト通知

まず次のスクリプトを作成します:

~/.config/hypr/scripts/backlight
!/usr/bin/env bash

iDIR="$HOME/.config/mako/icons"

# Get brightness
get_backlight() {
	LIGHT=$(printf "%.0f\n" $(brightnessctl g))
	echo "${LIGHT}"
}

# Get icons
get_icon() {
	current="$(get_backlight)"
	if [[ ("$current" -ge "0") && ("$current" -le "19200") ]]; then
		icon="$iDIR/brightness-20.png"
	elif [[ ("$current" -ge "19200") && ("$current" -le "38400") ]]; then
		icon="$iDIR/brightness-40.png"
	elif [[ ("$current" -ge "38400") && ("$current" -le "57600") ]]; then
		icon="$iDIR/brightness-60.png"
	elif [[ ("$current" -ge "57600") && ("$current" -le "76800") ]]; then
		icon="$iDIR/brightness-80.png"
	elif [[ ("$current" -ge "76800") && ("$current" -le "96000") ]]; then
		icon="$iDIR/brightness-100.png"
	fi
}

# Notify
notify_user() {
	notify-send -h string:x-canonical-private-synchronous:sys-notify -u low -i "$icon" "Brightness : $(get_backlight)"
}

# Increase brightness
inc_backlight() {
	brightnessctl s +5% && get_icon && notify_user
}

# Decrease brightness
dec_backlight() {
	brightnessctl s 5%- && get_icon && notify_user
}

# Execute accordingly
if [[ "$1" == "--get" ]]; then
	get_backlight
elif [[ "$1" == "--inc" ]]; then
	inc_backlight
elif [[ "$1" == "--dec" ]]; then
	dec_backlight
else
	get_backlight
fi

次に、以下を追加します (または既存のバインドを編集します):

~/.config/hypr/hyprland.conf
# Screen brightness
bind = , XF86MonBrightnessUp, exec, ~/.config/hypr/scripts/backlight --inc 
bind = , XF86MonBrightnessDown, exec, ~/.config/hypr/scripts/backlight --dec
キーボード言語の通知

このスクリプトを実行するには、コマンドライン JSON プロセッサ gojqAUR が必要です。

まず次のスクリプトを作成します:

~/.config/hypr/scripts/lang
#!/usr/bin/env bash

icon="$HOME/.config/mako/icons/language.png"

# Get language
get_lang() {
	lang=$(hyprctl devices -j | gojq -r '.keyboards[] | select(.name == "at-translated-set-2-keyboard") | .active_keymap' | cut -c 1-2 | tr 'A-Z' 'a-z')
	case $lang in
		en)
			lang="English language"
			;;
		ru)
			lang="Русский язык"
			;;
		uk)
			lang="Українська мова"
			;;
	esac
	echo $lang
}

# Notify
notify-send -h string:x-canonical-private-synchronous:sys-notify -u low -i "$icon" "$(get_lang)"

次に、以下を追加します (または既存のバインドを編集します):

~/.config/hypr/hyprland.conf
device:at-translated-set-2-keyboard {
    kb_layout = us,ru,ua
    kb_variant = lang
    kb_options = grp:win_space_toggle
}

# Language
bind = SUPER, SPACE, exec, ~/.config/hypr/scripts/lang

電源制御

Hyprland では、電源制御のために Wayland 互換の外部アプリケーションが必要です。例として nwg-barAUR を使用すると、次のようにバインドするだけで済みます:

~/.config/hypr/hyprland.conf
...
bind = SUPER, ESCAPE, exec, nwg-bar
...

クリップボード

Wayland クリップボードの動作により、コピー元のアプリケーションを閉じるとデータが削除されます。他のデスクトップ環境では、専用のクリップボードマネージャーを使用することでこの問題を回避できますが、Hyprland には互換性のある選択肢が複数あります。詳細については、upstream's Wiki を参照してください。

このセクションでは、テキストだけでなく画像のコピーもサポートしている cliphist について説明します。まず、次の行を追加します:

~/.config/hypr/hyprland.conf
...
exec-once = wl-paste --type text --watch cliphist store 
exec-once = wl-paste --type image --watch cliphist store
...

次に、選択した アプリケーションランチャー の履歴を呼び出すバインドを作成します:

~/.config/hypr/hyprland.conf
...
bind = SUPER, V, exec, cliphist list | wofi --dmenu | cliphist decode | wl-copy
...

Super+v を押すと、wofi ウィンドウが開き、クリップボード履歴リストが表示されます。

トラブルシューティング

xdg-desktop-portal-hyprland が大量の CPU を使用する

これは既知のバグ [2] であり、最新の Git ビルドでは解決されているはずです。これを回避するには、こちら Hyprland wiki で説明されているように、スクリプトを hyprland.conf ファイルで呼び出すことで回避できます。

参照

翻訳ステータス: このページは en:Hyprland の翻訳バージョンです。最後の翻訳日は 2023-12-31 です。もし英語版に 変更 があれば、翻訳の同期を手伝うことができます。