Skip to content

Instantly share code, notes, and snippets.

@kazuho
Last active November 8, 2023 21:18
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save kazuho/2432b0dce057b34488de4e5e7b356cad to your computer and use it in GitHub Desktop.
Save kazuho/2432b0dce057b34488de4e5e7b356cad to your computer and use it in GitHub Desktop.
Meta Quest 3のlinuxセットアップ

想定読者

  • linuxに関する基本的な知識があるソフトウェアエンジニアもしくはヘビーユーザで、Quest 3のlinuxをGUI環境で使いたい人
  • apkのインストールとか説明しませんが、Quest 3に入れたやつは、アプリ一覧からカテゴリでUntrusted Sourcesみたいなのを選ぶと出てきます
  • termuxの上にlinux distroを載せるのは、遅いのでやりません(下記ベンチマーク参照)。prefixed-rootだろうがシングルユーザだろうがmusl libcだろうが我々なら大丈夫だ!
  • linuxアプリのインストールは特記事項ない限り省略します。勝手にpkg installとかして

ベンチマーク

Summary of SystemBenchmarks Index Score:

single-core multi-core
Oculus Quest 3 (termux) 551.4 2086.0
Oculus Quest 3 (termux + proot(manjaro)) 254.0 1197.9
Ryzen 4750G (ubuntu 22.04) 2181.5 18262.5
MacBook Pro 16" 2019 (VMware Fusion + ubuntu 22.04) 684.8 3142.1

詳細は https://gist.github.com/kazuho/f5e7aec2824167513cbeedd54f65fa46

基本セットアップ

  1. TermuxのレポのReleasesから最新のapkを取ってきて入れる
  2. Termux-x11のレポのActionsから、Build Artifactで最新のtermux-x11.apkを探して入れる
  3. Termux起動して
$ pkg install x11-repo termux-x11-nightly xfce4
$ termux-x11 :1 -xstartup xfce4-session
  1. AndroidのPhantom Process Killerを止めとかないと、X内でプロセスぱかぱか立ててTermux丸ごと死にます。なので下記を実行 (出典: https://github.com/HardcodedCat/termux-monet#Phantom-Process-Killer)
$ adb shell "/system/bin/device_config set_sync_disabled_for_tests persistent"
$ adb shell "/system/bin/device_config put activity_manager max_phantom_processes 2147483647"
$ adb shell settings put global settings_enable_monitor_phantom_procs false
  1. アプリをTermux-x11に切り替えるとXが起動してるはず

vscode

Termux User Repository (TUR)からOSS版入れる

% pkg install tur-repo
% pkg install code-oss

かな漢字変換 (fictx5 + anthy)

mozcはビルド環境作るのが大変そうなのでanthy。

まずfictx5入れて、

% pkg install fictx5

次にanthy-unicode

anthy-unicode.termux.patchあててから

./configure --prefix=$PREFIX && make && make install

fictx5-anthyはパッチあてる必要なくて

cmake -DCMAKE_INSTALL_PREFIX=$PREFIX && make && make install

で、fictx5をコマンドラインから起動すると、/anthy.dicがないっていう。これはanthy-unicode.confを違うところに探しにいってるからなので

% cd $PREFIX/share/anthy-unicode && ln -s ../../etc/anthy-unicode.conf

して、fictx5コマンドラインから再実行してうまくいくこと確認。うまくいかないならstrace fictx5とかして、どこに何を探しにいってるか確認するとよい。

tailscale VPN

Android PhoneでGoogle Playからtailscaleのアプリとってきて、apk抜いて、Quest 3に入れて設定するだけ。

GPUアクセラレーション (virgl)

pkg install virglrenderer-android

そして、TermuxでXを起動する前に

virgl_test_server_android &
export GALLIUM_DRIVER=virpipe

するようにする。

ベンチマークに使うteapotは pkg install mesa-demos で入る。ただしそのままでteapot起動すると、必要な画像ファイルがないって言われるので/data/data/com.termux/files/usr/share/mesa-demos/が../dataになるように適当にsymlink貼るなりなんなりしてから実行する必要がある。

cf. termux/termux-packages#15639

サウンド

まず

% pkg install pulseaudio espeak sox

後2者はテスト用。

次に$PREFIX/etcpulse/default.paを開いてunix socketの設定を

load-module module-native-protocol-unix socket=/data/data/com.termux/files/usr/tmp/pulseserver auth-anonymous=1

に変更。

mkdir -p $PREFIX/etc/pulse/default.pa.d

$PREFIX/etc/pulse/daemon.confのexit-idle-timeをアンコメントし-1に設定。

そしてTermuxで

% pulseaudio --start &
% espeak -w /dev/stdout 'hell world' | PULSE_SERVER=$PREFIX/tmp/pulseserver play -

てやって、サウンドが聞こえるか確認。

聞こえるなら、Xを起動する前に

% pulseaudio --start &
% export PULSE_SERVER=$PREFIX/tmp/pulseserver

が実行されるよう設定し、X再起動。

ここで、termuxをフロントで実行したままtermux-x11に切り替えるとX側でも音がなるはず。termuxの画面が消えると音がなくなる(バックグランド再生はできない)。まあAndroidアプリ同時三面表示できるからいいよね...いいのか?

vscode

TUR (termux user repositories)からcode-ossを入れてもいいんだけど、動かないプラグインとか多い(glibc前提のネイティブコード内蔵してたりとか)。MS純正のやつないし。ってことで、以下はubuntuなproot-distroに入れるやりかた。

  1. vscode公式サイトからdebとってくる
  2. dpkg -i する。依存関係ないってエラー出る
  3. apt upgrade。これで依存関係全部入る
% proot-distro login --user USERNAME --shared-tmp ubuntu

してから

% DISPLAY=:1 code --no-sandbox --verbose

で起動。あとはプラグインとか入る。/data/data/com.termux/filesはproot内でも見れるからいいね!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment