Note to Self by notekunst

ただの備忘録です

Ubuntu 22.04 LTS を MacBook Pro (Retina, 15-inch, Late 2013) にインストールする

20.04のパーティションを消去して、22.04を新たにインストールしました。
インストール作業を再び行うときのために、作業内容を記録しました。
試行錯誤した作業を後から思い出しながらまとめたので、過不足があるかもしれません。

Ubuntu 22.04 のインストール

20.04のインストールと同じです。

  • Ubuntu の Bootable USBを MAC に接続
  • "option (⌥)" を押しながらMACを起動
  • Ubuntu インストーラを選択
  • Keyboard: 実機に合うものを選択します。私のキーボードは English (US)
  • Update ...:"Install third-party..."もチェックします (Wi-Fi用)
  • Installation Type:"something else" を選択して "Continue"
  • 次のメニューで Ubuntu用のパーティションを選択します。パーティションの設定画面で、以下の設定を行いました
  1. Size:変更せずにそのまま
  2. Use as:"Ext4 journaling ..."を選択
  3. Format the partition:チェックを入れる
  4. Mount Point: "/" に設定
  5. そして"OK"
  • メニュー下部の "Device for boot loader installation" で Ubuntuをインストールするパーティションを選択
  • ここで、念の為に、インストール用のパーティションを選択した状態にします
  • そして、"Install Now"

これで、Ubuntuを無事にインストールできました。再起動すると、Ubuntuが起動します。この状態で、Wi-Fiも動きました。
"option (⌥)" を押しながらMACを起動すると、macOSも起動します。

インストール後の設定

emacsのインストール

sudo apt install emacs-gtk
インストール前に"emacs"と入力するといろいろな候補が表示されます。他のパッケージは、簡易版などです。

open-sshのインストール

sudo apt install openssh-server

gufwのインストール

sudo apt install gufw

キーボードのCapsをCtrlに変更する

/etc/default/keyboard の以下の行を編集する

XKBOPTIONS="ctrl:nocaps"
("ctrl:nocaps"の代わりに"ctrl:swapcaps"でもよい)
FacetimeHDカメラのドライバのインストール

Patrik Jakobsson氏のツールを用います。
github.com
手順は、氏の以下の記事"Get Started"に書かれています。
Get Started · patjak/facetimehd Wiki · GitHub

ファームウェアの抽出

$ git clone https://github.com/patjak/facetimehd-firmware.git
$ sudo apt install make curl cpio
$ cd facetimehd-firmware/
$ make
Found matching hash from OS X, El Capitan 10.11.5
==> Extracting firmware...
 --> Decompressing the firmware using gzip...
 --> Deleting temporary files...
 --> Extracted firmware version 1.43.0
$ sudo make install
Copying firmware into '//usr/lib/firmware/facetimehd'

インストール

$ sudo add-apt-repository universe
$ sudo apt install kmod libssl-dev checkinstall
$ git clone https://github.com/patjak/bcwc_pcie.git
$ cd bcwc_pcie
$ make
$ sudo checkinstall
$ sudo depmod
$ sudo modprobe facetimehd

/etc/modulesに以下を記載

facetimehd
ログイン画面でユーザ名の表示を止める

/etc/gdm3/greeter.dconf-defaultsの

# disable-user-list=true

のコメントを外す。

Firefoxをsnap版からdeb版に変更する

これで、FirefoxGNOME Shell Extensions を管理できます。

$ sudo snap remove firefox
$ sudo apt-add-repository ppa:mozillateam/ppa

/etc/apt/preferences.d/mozilla-firefox に以下を記載

Package: *
Pin: release o=LP-PPA-mozillateam
Pin-Priority: 1001

Package: firefox*
Pin: release o=Ubuntu*
Pin-Priority: -1

/etc/apt/apt.conf.d/51unattended-upgrades-firefox に以下を記載

Unattended-Upgrade::Allowed-Origins:: "LP-PPA-mozillateam:${distro_codename}";
GNOME Shell Extensions のインストール
$ sudo apt install chrome-gnome-shell
$ sudo apt install gnome-shell-extension-prefs
$ sudo apt install gnome-shell-extension-manager

Firefox に add-on を追加
https://addons.mozilla.org/en-US/firefox/addon/gnome-shell-integration/
以下のウェブサイトから好みの拡張をインストールできます。
https://extensions.gnome.org/

fcitx5とmozcのインストール

以下の記事が参考になります。
gihyo.jp

  • sudo apt install fcitx5-mozc
  • im-config -n fcitx5
  • gnomeの"Settings"を起動
  • "Settings"画面内の左欄の "Region & Language" をクリック
  • 右欄の "Manage Installed Languages"ボタンをクリック
  • もし、"The Language support is not installed completely" と表示されたら "Install"ボタンをクリック
  • 表示されている "Language Support"画面の"Language"タブの"Keyboard input method system"のプルダウンメニューで "fcitx 5" を選択。そして、"Close"
  • sudo apt -y purge ibus (念のため)
  • システムを再起動
  • "Fcitx Configuration" を起動(Dockの"Show Applications"ボタンから起動できます)
  • "Input Method"タブを選択し、以下の手順で"Mozc"を追加
  1. 右側のリストから"Mozc"を選択(見当たらない場合、"Only Show Current Language" のチェックを外すといいかもしれません)
  2. 中央の"<"ボタンをクリックして"Mozc"を左のリストに移動させる
  • "Global Options"タブを選択
  • "Trigger Input Method"の右のボタンをクリックして、入力言語切り替えのキー組み合わせを入力し、"Apply"をクリック。私は、"Alt+`" を入力しました。

このキー組み合わせは、gnomeの設定と競合するので、gnomeの設定を変更します。

  • gnomeの"Settings"を起動
  • "Settings"画面内の左欄の "Keyboard"をクリック
  • 右欄の"Keyboard Shortcuts"の下の"View and Customize Shortcuts"をクリック
  • 検索欄に"Super"と入力して候補を絞ります。
  • 競合する"Super+`"に対応する"Switch windows of an application" の設定を、競合しない組み合わせ(e.g. "Alt+F1")に変更
  • "Settings"画面を閉じる。
gnome desktop の背景を画像から単色に変更
$ gsettings set org.gnome.desktop.background picture-uri ''
$ gsettings set org.gnome.desktop.background color-shading-type 'solid'
$ gsettings set org.gnome.desktop.background primary-color '#2d7d9a'
スクロールバーを常に表示する
$ gsettings set org.gnome.desktop.interface overlay-scrolling false
スクロールバー領域のクリックを、その位置へのワープから1ページ移動に変更する

~/.config/gtk-3.0/settings.ini に以下を記載

[Settings]
gtk-primary-button-warps-slider = false
Dockの"Show Applications"を上(左)に移動させる
$ gsettings set org.gnome.shell.extensions.dash-to-dock show-apps-at-top true
デスクトップにゴミ箱を表示する
$ gsettings set org.gnome.shell.extensions.ding show-trash true
xrdpのインストールと設定

以下の記事を参考にしました。
gihyo.jp
この記事は、Ubuntu 20.04向けのものですが、22.04でも同じ設定で動作しました。
この記事では、複数の設定ファイルをスクリプトを使って一度に処理しています。
私は、ファイル毎に設定を手動で書き込みました。

まず、xrdpをインストールします。

sudo apt install xrdp

ファイル"/etc/xrdp/startubuntu.sh"に、以下の内容を書き込みます。

#!/bin/sh
export GNOME_SHELL_SESSION_MODE=ubuntu
export XDG_CURRENT_DESKTOP=ubuntu:GNOME
exec /etc/xrdp/startwm.sh

誰でも実行できるようにパーミッションを設定します。

sudo chmod a+x /etc/xrdp/startubuntu.sh

ファイル"/etc/xrdp/sesman.ini"の中の"startwm"を"startubuntu"に置換します。私の場合、以下の2行を編集しました。

; UserWindowManager=startwm.sh (元の行をコメントアウト)
UserWindowManager=startubuntu.sh (新たに追加)

; DefaultWindowManager=startwm.sh (元の行をコメントアウト)
DefaultWindowManager=startubuntu.sh (新たに追加)

同じファイル"/etc/xrdp/sesman.ini"の中の"FuseMountName=thinclient_drives"を"FuseMountName=shared-drives"に置換します。私の場合、以下の1行を編集しました。

# FuseMountName=thinclient_drives (元の行をコメントアウト)
FuseMountName=shared-drives (新たに追加)

ファイル"/etc/X11/Xwrapper.config"の許可ユーザを編集します。

# allowed_users=console (元の行をコメントアウト)
allowed_users=anybody (新たに追加)

ファイル"/etc/polkit-1/localauthority/50-local.d/45-allow-colord.pkla"に、以下の内容を書き込みます。

[Allow Colord all Users]
Identity=unix-user:*
Action=org.freedesktop.color-manager.create-device;org.freedesktop.color-manager.create-profile;org.freedesktop.color-manager.delete-device;org.freedesktop.color-manager.delete-profile;org.freedesktop.color-manager.modify-device;org.freedesktop.color-manager.modify-profile
ResultAny=no
ResultInactive=no
ResultActive=yes

ファイル"/etc/polkit-1/localauthority/50-local.d/46-allow-update-repo.pkla"に、以下の内容を書き込みます。

[Allow Package Management all Users]
Identity=unix-user:*
Action=org.freedesktop.packagekit.system-sources-refresh
ResultAny=yes
ResultInactive=yes
ResultActive=yes

必要に応じて、"/etc/xrdp/xrdp.ini"を編集してポート番号を変更します。

port=XXXXX (XXXXXは、ポート番号)

gufwでxrdpのためのルールを追加します。

サーバを起動します。

sudo systemctl restart xrdp.service