0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

[メモ] WSL2 + Ubuntu-24.04 + Firefox + fcitx4 +mozc (2026年1月)

Posted at

概要

  • 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 を使うしかないっぽい。
  • ちなみに、いままでは、Ubuntuのデフォでインストールできるsnap版FirefoxとTABキーとかをつかって、キーボードで選択したりしてた。

方針

環境

  • 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:\>
    

手順

  1. wsl のインストール / アップデート

    wsl.exe --install
    
    # wsl の更新
    wsl.exe --update --pre-release
    
    # ディストリビューションのオンラインリスト
    wsl.exe -l -o
    
    # Ubuntuのインストール
    wsl.exe --install Ubuntu
    
    # Ubuntuの完全削除
    wsl.exe --unregister Ubuntu
    
  2. wsl -d Ubuntu # Ubuntu起動

  3. 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
    
  4. 環境の引っ越し

    # 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
    
  5. 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/ を移行すれば、よい。
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?