/home/amgsk

i3wmで効率よくゲームする

· amgsk

ArchLinux + i3wm 環境でゲームをプレイする際に、知っておくと便利な設定など。
gamemode は Linuxゲーミング環境でよく使われる最適化ツール。
これを活用して CPU の governorperformance に設定したり、スクリーンロックを無効化したりなど、ゲームする準備を自動化することができる。

1
2
3
4
5
6
7
8
9
[general]
desiredgov=performance
renice=10
ioprio=2
inhibit_screensaver=1

[custom]
start=/home/user/.config/gamemode/start.sh
end=/home/user/.config/gamemode/end.sh

軽量なi3wmとはいえ、picom などのコンポジターはゲーム時にパフォーマンスに影響を与える。
特に、影・透過・ぼかし・アニメーションの描写コストは高い。

gamemodeの開始時に自動でpicomを無効化し、終了時に再度有効化するようにする。
環境変数$HOME展開できない場合があるので注意。フルパスで書くようにする。

start.sh

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
#!/bin/bash

export DISPLAY=:0
i3-msg mode "gaming"

pkill picom

sleep 0.5
if pgrep -x picom > /dev/null; then
    pkill -9 picom
fi

end.sh

1
2
3
4
5
6
#!/bin/bash

export DISPLAY=:0
picom --daemon --config /home/user/.config/picom/picom.conf

i3-msg mode "default"

i3/config

i3wmには以下のように空のモードを指定しておく。 このモードの配下ではi3によって設定した$mod$mod+BackSpace以外のマッピングは無効化されている。

1
2
3
4
5
6
...
mode "gaming" {
    bindsym $mod+BackSpace mode "default"
}
bindsym $mod+BackSpace mode "gaming"
...

設定した後は、以下のコマンドでテストをしておく。

 1amgsk@arch-desk ~> gamemoded -t
 2: Loading config
 3Loading config file [/home/amgsk/.config/gamemode.ini]
 4: Running tests
 5:: Basic client tests
 6:: Passed
 7:: Dual client tests
 8gamemode request succeeded and is active
 9Quitting by request...
10:: Passed
11:: Gamemoderun and reaper thread tests
12...Waiting for child to quit...
13...Waiting for reaper thread (reaper_frequency set to 5 seconds)...
14:: Passed
15:: Supervisor tests
16:: Passed
17:: Feature tests
18::: Verifying CPU governor setting
19::: Passed
20::: Verifying Scripts
21:::: Running start script [/home/amgsk/.config/gamemode/start.sh]
22:::: Passed
23:::: Running end script [/home/amgsk/.config/gamemode/end.sh]
24:::: Passed
25::: Passed
26::: Verifying GPU Optimisations
27::: Passed (gpu optimisations not configured to run)
28::: Verifying renice
29::: Passed
30::: Verifying ioprio
31::: Passed
32:: Passed
33: All Tests Passed!

そしてSteamの起動オプションに以下を設定する。

1
gamemoderun %command%
Steam起動オプションの設定

すべての Steam ゲームの起動オプションを変更する必要がないようにするには、gamemode で Steam を直接起動する。 これはお好きに。

1
gamemoderun steam-runtime

あとは実際にゲームを起動して、ステータスがアクティブになっていることやi3wmのモード変更が正しく動作するかを確認する。

1
gamemoded -s

そんな感じ。

0
0