Skip to content

Instantly share code, notes, and snippets.

@numpad0
Created July 7, 2020 13:50
Show Gist options
  • Save numpad0/5e70ab13cfb1322aa7ae5004fd3a5e13 to your computer and use it in GitHub Desktop.
Save numpad0/5e70ab13cfb1322aa7ae5004fd3a5e13 to your computer and use it in GitHub Desktop.

WSL2 + X410 + PulseAudio備忘録

目的

Windows 10上のWSL2でFirefox開いてYouTube見られるくらいまで持ってく。

免責

早くも記憶が薄れているので……

既知の問題点

  • Windowsを起動するごとに言語設定にUSキーボードが勝手に入る
    • X410が英語ロケールでビルドされてるとか何かそんなん
  • XプロトコルとPulseAudioの着信全部受けるのでIPが届くと軽くヤバい
    • X410: localhostからの接続に限定する(オン・オフ)しか選べない
    • PulseAudio: 172.24.0.0/12とかに絞れると思う

ネタ元ハイパーリンク

prereq

  1. X410: Microsoft Storeで買う。常態的に二重価格販売されている。フリーのVcXsrvでも変わらない気もする……
  2. PulseAudio: https://www.freedesktop.org/wiki/Software/PulseAudio/Ports/Windows/Support/

X410

  1. Storeから入れる

  2. スタートアップにショートカットを作成

    1. Win+Rを押して shell:AppsFolder [OK]
    2. Win+Rを押して shell:startup [OK]
    3. Applications から Startup へ右ドラッグ
  3. X410を設定

    1. トレイアイコン → ✔ Allow Public Access
    2. (任意) トレイアイコン → ✔ Windowed Apps
    3. ファイアウォール警告が出たら許可する
  4. WSL側作業

    • ~/.bashrc に以下を追加
    # Windows XSrv config
    export $(dbus-launch)
    export LIBGL_ALWAYS_INDIRECT=1
    
    export WSL_VERSION=$(wsl.exe -l -v | grep -a '[*]' | sed 's/[^0-9]*//g')
    export WSL_HOST=$(tail -1 /etc/resolv.conf | cut -d' ' -f2)
    export DISPLAY=$WSL_HOST:0
    
    # fcitx
    export GTK_IM_MODULE=fcitx
    export QT_IM_MODULE=fcitx
    export XMODIFIERS=@im=fcitx
    
    # pulseaudio
    export PULSE_SERVER=tcp:$WSL_HOST;
    

PulseAudio

  1. PulseAudio: C:\PULSE~1とか適当に展開する

  2. PULSE~1\etc\pulse\default.pa をに追記

    • 行41: load-module module-waveout sink_name=output source_name=input
    • 行61: load-module module-native-protocol-tcp auth-anonymous=1
    • * 録音無効にしなくても大丈夫ぽい
  3. PULSE~1\etc\pulse\daemon.conf に追記

    • 末尾: exit-idle-time = -1
    • * 接続待ちタイムアウトの無効化
  4. PULSE~1\pulseaudio.vbs を以下で新規作成

    Dim WinScriptHost
    Set WinScriptHost = CreateObject("WScript.Shell")
    WinScriptHost.Run Chr(34) & "C:\PULSE~1\bin\pulseaudio.exe" & Chr(34), 0
    Set WinScriptHost = Nothing
    

    VBSからWSH経由で叩くとウィンドウが出ない理由は謎。

  5. PULSE~1\pulseaudio.vbsへのショートカットをStartupフォルダに投げ込む

  6. WSL側作業

    • $ apt install pulseaudio
    • ~/.bashrc に以下を追記 (*X410の項で追記済)
    # export WSL_HOST=$(tail -1 /etc/resolv.conf | cut -d' ' -f2)
    export PULSE_SERVER=tcp:$WSL_HOST;
    

fcitx

あかん忘れてもうた。

  1. $ sudo apt install fcitx fcitx-mozc

  2. $ fcitx-configtool

    • Global Config - Trigger Input Method - Ctrl+Space を確認
  3. ~/.bashrc に以下を追記 (*X410の項で追記済)

    export GTK_IM_MODULE=fcitx
    export QT_IM_MODULE=fcitx
    export XMODIFIERS=@im=fcitx
    
  4. 使用時に必要に応じて: $ fcitx-autostart

  5. 使用時に必要に応じて: Ctrl+Space

firefox

  1. $ sudo apt install firefox
  2. $ firefox youtube.com
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment