概要
- Windowsの WSL2のUbuntuでFirefoxを使おうとすると、クリックがうまく動作しない。
- WaylandモードでFirefoxが動いてて、WSL2と相性が悪いらしい。
-
export MOZ_ENABLE_WAYLAND=0で、firfoxを起動すると、Waylandを使わないで、X11ので起動するが、Ubuntu環境でインストールしたFirefoxは、それをサポートしてない。
動機
- ず〜っとその環境を保持して、使ってきたけど、VHDXイメージも35GBくらいになってきたので、整理しようかな。
-
https://qiita.com/mt08/items/625780063e75fefd882e から、2年、だれか、うまい方法を見つけてるんではないかな?
- 2026年も
MOZ_ENABLE_WAYLAND=0を使うしかないっぽい。
- 2026年も
- ちなみに、いままでは、Ubuntuのデフォでインストールできるsnap版FirefoxとTABキーとかをつかって、キーボードで選択したりしてた。
方針
-
Mozzilaのサイトに書いてある方法で、Firefoxをインストールする。
-
前のFirefox環境(profile)をそのままコピーして、使用する。
-
日本語入力とJoplin(AppImage)をついでに。
-
日本語の設定は、https://astherier.com/blog/2021/07/windows11-wsl2-wslg-japanese/ から。
環境
- Windows 10
- WSL2 + Ubuntu / Ubutu-22.04
# 現時点でのバージョン (on Windows 10) PS C:\> wsl --version WSL version: 2.7.0.0 Kernel version: 6.6.114.1-1 WSLg version: 1.0.71 MSRDC version: 1.2.6676 Direct3D version: 1.611.1-81528511 DXCore version: 10.0.26100.1-240331-1435.ge-release Windows version: 10.0.19045.6456 PS C:\>
手順
-
wsl のインストール / アップデート
wsl.exe --install # wsl の更新 wsl.exe --update --pre-release # ディストリビューションのオンラインリスト wsl.exe -l -o # Ubuntuのインストール wsl.exe --install Ubuntu # Ubuntuの完全削除 wsl.exe --unregister Ubuntu -
wsl -d Ubuntu# Ubuntu起動 -
Firefoxインストール
# 1. APTリポジトリキーを格納するディレクトリ作成 sudo install -d -m 0755 /etc/apt/keyrings # 2. Mozilla APTリポジトリ署名キーのインポート wget -q https://packages.mozilla.org/apt/repo-signing-key.gpg -O- | sudo tee /etc/apt/keyrings/packages.mozilla.org.asc > /dev/null # 3. フィンガープリント 35BAA0B33E9EB396F59CA838C0BA5CE6DC6315A3 チェック gpg -n -q --import --import-options import-show /etc/apt/keyrings/packages.mozilla.org.asc | awk '/pub/{getline; gsub(/^ +| +$/,""); if($0 == "35BAA0B33E9EB396F59CA838C0BA5CE6DC6315A3") print "\nThe key fingerprint matches ("$0").\n"; else print "\nVerification failed: the fingerprint ("$0") does not match the expected one.\n"}' # 4. Mozilla APTリポジトリを追加. (公式ではhttpsだが、apt-cacher-ngをつかってるので、httpにしている) cat <<EOF | sudo tee /etc/apt/sources.list.d/mozilla.sources Types: deb URIs: http://packages.mozilla.org/apt Suites: mozilla Components: main Signed-By: /etc/apt/keyrings/packages.mozilla.org.asc EOF # 5. APTを設定してMozillaリポジトリからのパッケージを優先 echo ' Package: * Pin: origin packages.mozilla.org Pin-Priority: 1000 ' | sudo tee /etc/apt/preferences.d/mozilla # 6. インストール sudo apt update && sudo apt upgrade -y && sudo apt install -y firefox fcitx-mozc dbus-x11 fonts-noto && \ cat << 'EOS' | tee -a ~/.profile #Firefox for X11 export MOZ_ENABLE_WAYLAND=0 #Added by bash script from https://astherier.com/blog/2021/07/windows11-wsl2-wslg-japanese/ export GTK_IM_MODULE=fcitx export QT_IM_MODULE=fcitx export XMODIFIERS=@im=fcitx export DefaultIMModule=fcitx if [ $SHLVL = 1 ] ; then (fcitx-autostart > /dev/null 2>&1 &) xset -r 49 > /dev/null 2>&1 # 半角全角点滅防止 fi #Added by bash script: end EOS # 7. WSL Ubuntuを一旦終了して、再度起動 wsl.exe -t ${WSL_DISTRO_NAME} wsl -d Ubuntu # 8. mozcの設定、一旦終了して、再度起動 sed -i -e 's/.*IMName.*/IMName=mozc/g' -e 's/mozc:False/mozc:True/g' ~/.config/fcitx/profile wsl.exe -t ${WSL_DISTRO_NAME} wsl -d Ubuntu -
環境の引っ越し
# 1. 前の環境で、tarでアーカイブ作成 cd ~ tar cvf ~/snap_firefox_common.tar ./snap/firefox/common/ # snap環境のfirefox # 2. Explorer起動して、ファイルをコピー explorer.exe . # 3. 移行先の環境で、解凍 cd ~ tar xf snap_firefox_common.tar mkdir -p ~/.mozilla/firefox/ && cp -a ~/snap/firefox/common/.mozilla/firefox/* ~/.mozilla/firefox/ # 4. firefoxを-Pオプション付きで起動 => ユーザプロファイルが選択できる firefox -P -
Joplin(AppImage) のインストールとデータの移行
- github.com/laurent22/joplin/releases から、 Joplin-x.x.x.AppImage をダウンロード
-
chmod a+x Joplin-x.x.x.AppImage# 実行属性をつけて、うまいところに移動。 -
sudo apt install libfuse2t64 libnspr4 libnss3 -y必要なライブラリをインストール - Joplinでは、
.config/joplin-desktop/を移行すれば、よい。